Skip to content

Commit

Permalink
Merge pull request #60 from dadoagency/adv3-footer
Browse files Browse the repository at this point in the history
Advertorial 3 Footer RichText Field
  • Loading branch information
martink-rsa committed Jan 7, 2021
2 parents 3e65be1 + 1ce49c6 commit e0677be
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/__snapshots__/storybook.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3289,7 +3289,7 @@ exports[`Storyshots AdvertorialType1 Default 1`] = `
>
<p>
Copyright ©
2020
2021
<a
href="/"
Expand Down Expand Up @@ -4666,7 +4666,7 @@ exports[`Storyshots Footer Default 1`] = `
>
<p>
Copyright ©
2020
2021
<a
href="/"
Expand Down Expand Up @@ -5127,7 +5127,7 @@ exports[`Storyshots Layout Default 1`] = `
>
<p>
Copyright ©
2020
2021
<a
href="/"
Expand Down
15 changes: 14 additions & 1 deletion src/templates/AdvertorialType3/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react"
import * as S from "./Footer.style"
import renderOptions from "../../utils/richText"
import { documentToReactComponents } from "@contentful/rich-text-react-renderer"

function Footer({ links, companyDetails }) {
function DefaultFooter({ links, companyDetails }) {
const { name, url } = companyDetails
return (
<S.Wrapper>
Expand All @@ -27,4 +29,15 @@ function Footer({ links, companyDetails }) {
</S.Wrapper>
)
}

function Adv3Footer({footerSection}) {
return <S.Wrapper>
{documentToReactComponents(footerSection,renderOptions)}
</S.Wrapper>
}

function Footer({ links, companyDetails, footerSection }) {
return footerSection ? <Adv3Footer footerSection={footerSection} /> : <DefaultFooter links={links} companyDetails={companyDetails} />
}

export default Footer
3 changes: 2 additions & 1 deletion src/templates/AdvertorialType3/Layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default ({
headerLinks,
footerLinks,
companyDetails,
footerSection,
pageTitle,
...props
}) => {
Expand All @@ -24,7 +25,7 @@ export default ({
</Helmet>
<Header logo={logo} headerContentRight={headerContentRight} />
{children}
<Footer links={footerLinks} companyDetails={companyDetails} />
<Footer links={footerLinks} companyDetails={companyDetails} footerSection={footerSection} />
</div>
)
}
5 changes: 5 additions & 0 deletions src/templates/AdvertorialType3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export const AdvertorialType3Page = graphql`
body {
json
}
footer {
json
}
}
`

Expand All @@ -75,6 +78,7 @@ function AdvertorialType3(props) {
const heroImg = node.heroImage.image.fluid
const heroSection = node.heroSection.json
const mainSection = node.body.json
const footerSection = node.footer ? node.footer.json : null

return (
<>
Expand All @@ -84,6 +88,7 @@ function AdvertorialType3(props) {
logo={logo}
footerLinks={footerLinks}
companyDetails={companyDetails}
footerSection={footerSection}
headerContentRight={documentToReactComponents(
headerContentRight,
renderOptions
Expand Down

0 comments on commit e0677be

Please sign in to comment.