Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 - InformationMessage Component + replacement in main/page.tsx #532

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import SectionRenderer from "src/utils/renderSection";
import { loadQuery } from "studio/lib/store";
import { Metadata } from "next";
import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo";
import CustomErrorMessage from "src/blog/components/customErrorMessage/CustomErrorMessage";
import InformationSection from "src/blog/components/informationSection/InformationSection";
import { LinkType } from "studio/lib/payloads/navigation";

export async function generateMetadata(): Promise<Metadata> {
const { data: landingId } = await loadQuery<string>(LANDING_QUERY);
const seo = await fetchSeoData(SEO_PAGE_QUERY, { id: landingId });

return generateMetadataFromSeo(seo);
}

Expand Down Expand Up @@ -43,9 +42,11 @@ const Home = async () => {

if (!landingId) {
return (
<CustomErrorMessage
title="Landing Page Has Not Been Set"
body="It looks like there's no page set as your landing page in the Studio. Head over to the Studio to select a landing page and guide visitors to the right place!"
<InformationSection
title="Welcome! Velkommen! Välkommen!"
body={
"It looks like there's no page set as your landing page in the Studio.\nHead over to the Studio to select a landing page and guide visitors to the right place!"
}
link={navigationManagerLink}
/>
);
Expand All @@ -59,9 +60,9 @@ const Home = async () => {

if (!initialLandingPage.data) {
return (
<CustomErrorMessage
<InformationSection
title="Landing Page is Missing Content"
body={`Your landing page is set, but it looks like there’s no content yet. Visit the Studio to start adding content and make your landing page come to life!`}
body={`Your landing page is set, but it looks like there’s no content yet.\n Visit the Studio to start adding content and make your landing page come to life!`}
link={pagesLink}
/>
);
Expand Down
5 changes: 2 additions & 3 deletions src/blog/Blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import BlogHero from "./components/hero/BlogHero";
import PostPreview from "src/blog/components/postPreview/PostPreview";
import PostPreviewGrid from "./components/postPreviewGrid/PostPreviewGrid";
import LoadingNews from "./components/loadingNews/LoadingNews";
import CustomErrorMessage, {
homeLink,
} from "./components/customErrorMessage/CustomErrorMessage";
import CustomErrorMessage from "./components/customErrorMessage/CustomErrorMessage";
import { homeLink } from "./components/utils/linkTypes";

interface BlogProps {
blog: BlogPage;
Expand Down
20 changes: 1 addition & 19 deletions src/blog/components/customErrorMessage/CustomErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
import Button from "src/components/buttons/Button";
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { ILink, LinkType } from "studio/lib/payloads/navigation";
import { ILink } from "studio/lib/payloads/navigation";
import styles from "./customErrorMessage.module.css";

export const homeLink = {
_key: "return-home",
_type: "link",
linkTitle: "Return to home",
linkType: LinkType.Internal,
internalLink: {
_ref: "/",
},
};

export const studioLink = {
_key: "go-to-studio",
_type: "link",
linkTitle: "Go to studio",
linkType: LinkType.Internal,
internalLink: { _ref: "/studio" },
};

interface CustomErrorMessageProps {
title: string;
body: string;
Expand Down
34 changes: 34 additions & 0 deletions src/blog/components/informationSection/InformationSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { ILink } from "studio/lib/payloads/navigation";
import styles from "./informationSection.module.css";
import React from "react";

interface InformationSectionProps {
title: string;
body: string;
link?: ILink;
}

const InformationSection = ({ title, body, link }: InformationSectionProps) => {
return (
<section className={styles.wrapper}>
<div className={styles.info}>
<Text type="h1">{title}</Text>
<span>
{body.split("\n").map((line, index) => (
<Text key={index}>
{line}
<br />
</Text>
))}
</span>
<div className={styles.buttonWrapper}>
{link && <LinkButton type="primary" link={link} />}
</div>
</div>
</section>
);
};

export default InformationSection;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.wrapper {
display: flex;
padding: 5rem 2rem;
align-items: center;
align-self: stretch;
@media (min-width: 640px) {
padding: 5rem 3rem;
justify-content: center;
}

@media (min-width: 1024px) {
padding: 7.5rem;
}
}

.info {
max-width: 88rem;
display: flex;
padding: 3rem;
flex-direction: column;
align-items: flex-start;
gap: 1.5rem;
align-self: stretch;
border-radius: 1rem;
}

.buttonWrapper {
display: flex;
align-items: flex-start;
gap: 1.5rem;
}
19 changes: 19 additions & 0 deletions src/blog/components/utils/linkTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LinkType } from "studio/lib/payloads/navigation";

export const homeLink = {
_key: "return-home",
_type: "link",
linkTitle: "Return to home",
linkType: LinkType.Internal,
internalLink: {
_ref: "/",
},
};

export const studioLink = {
_key: "go-to-studio",
_type: "link",
linkTitle: "Go to studio",
linkType: LinkType.Internal,
internalLink: { _ref: "/studio" },
};