Factoring out the re-used layout

This commit is contained in:
Keith Stevens
2023-01-03 08:40:59 +09:00
parent 53ab8fb479
commit 7f1644e38d
4 changed files with 14 additions and 21 deletions
+8
View File
@@ -17,4 +17,12 @@ export const getDefaultLayout = (page: React.ReactElement) => (
</div>
);
export const getTransparentHeaderLayout = (page: React.ReactElement) => (
<div className="grid grid-rows-[min-content_1fr_min-content] h-full justify-items-stretch">
<Header transparent={true} />
{page}
<Footer />
</div>
);
export const noLayout = (page: React.ReactElement) => page;
+2 -7
View File
@@ -5,6 +5,7 @@ import { Faq } from "src/components/Faq";
import { Footer } from "src/components/Footer";
import { Header } from "src/components/Header";
import { Hero } from "src/components/Hero";
import { getTransparentHeaderLayout } from "src/components/Layout";
import { TaskSelection } from "src/components/TaskSelection";
const Home = () => {
@@ -34,12 +35,6 @@ const Home = () => {
);
};
Home.getLayout = (page) => (
<div className="grid grid-rows-[min-content_1fr_min-content] h-full justify-items-stretch">
<Header transparent={true} />
{page}
<Footer />
</div>
);
Home.getLayout = getTransparentHeaderLayout;
export default Home;
+2 -7
View File
@@ -2,6 +2,7 @@ import { Container, Heading } from "@chakra-ui/react";
import Head from "next/head";
import { Footer } from "src/components/Footer";
import { Header } from "src/components/Header";
import { getTransparentHeaderLayout } from "src/components/Layout";
const PrivacyPolicy = () => {
return (
@@ -403,12 +404,6 @@ const PrivacyPolicy = () => {
);
};
PrivacyPolicy.getLayout = (page) => (
<div>
<Header transparent={true} />
{page}
<Footer />
</div>
);
PrivacyPolicy.getLayout = getTransparentHeaderLayout;
export default PrivacyPolicy;
+2 -7
View File
@@ -2,6 +2,7 @@ import { Container, Heading } from "@chakra-ui/react";
import Head from "next/head";
import { Footer } from "src/components/Footer";
import { Header } from "src/components/Header";
import { getTransparentHeaderLayout } from "src/components/Layout";
const TermsOfService = () => {
return (
@@ -148,12 +149,6 @@ const TermsOfService = () => {
);
};
TermsOfService.getLayout = (page) => (
<div>
<Header transparent={true} />
{page}
<Footer />
</div>
);
TermsOfService.getLayout = getTransparentHeaderLayout;
export default TermsOfService;