Skip to content

Commit

Permalink
#320 Implement personalized guides
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxicom committed Feb 23, 2023
1 parent f934052 commit e875fd2
Show file tree
Hide file tree
Showing 29 changed files with 578 additions and 118 deletions.
19 changes: 18 additions & 1 deletion src/build-utils/helpers/contentfulContentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const link = `

const linkCollectionModule = `
heading
subheading
variant
image {
gatsbyImageData(
formats: WEBP
Expand Down Expand Up @@ -124,7 +126,7 @@ const resourceItem = `

const resourceListModule = `
heading
subheading {
subheadingRich: subheading {
raw
}
resources {
Expand Down Expand Up @@ -277,6 +279,20 @@ const promotionBannerModule = `
}
`;

const stepsModule = `
steps {
... on Node {
id
internal {
type
}
... on ContentfulFaqItem {
${faqItem}
}
}
}
`;

module.exports = {
hero,
seo,
Expand All @@ -296,4 +312,5 @@ module.exports = {
pageData,
promoLine,
promotionBannerModule,
stepsModule,
};
5 changes: 4 additions & 1 deletion src/build-utils/pages/homePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const {
} = require(`../helpers/hooks`);
const { logContentfulWarning } = require(`../helpers/utils`);

const homepageId = `VoE6QU1LhN2Y5h6Tja3fq`;
// comment out one line to determine which homepage you want to render
// don't forget to uncomment correct homepage before merging PR
// const homepageId = `VoE6QU1LhN2Y5h6Tja3fq`; // this is the PRODUCTION homepage
const homepageId = `2hHrtVu5fUseOPMTxz82fV`; // this is the DUMMY homepage

const query = (graphql) => {
return graphql(`
Expand Down
6 changes: 6 additions & 0 deletions src/build-utils/pages/modularPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const query = (graphql) => {
... on ContentfulHelpSearchModule {
${contentModel.helpSearchModule}
}
... on ContentfulStepsModule {
${contentModel.stepsModule}
}
... on ContentfulFaqCategoriesModule {
${contentModel.faqCategoriesModule}
}
}
}
includeContactForm
Expand Down
10 changes: 10 additions & 0 deletions src/components/Button/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
}
}

&--tertiary {
background: #eaf1ff;

&:hover {
&::after {
display: none;
}
}
}

.Icon {
--icon-size: 20px;

Expand Down
5 changes: 5 additions & 0 deletions src/components/ContentfulModule/ContentfulModule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HelpSearch } from "../HelpSearch";
import { PartnersModule } from "./PartnersModule";
import { FaqCategoriesModule } from "./FaqCategoriesModule";
import { PromotionBannerModule } from "./PromotionBannerModule";
import { StepsModule } from "./StepsModule";

const ContentfulModule = ({ module, pathname }) => {
const type = module?.internal?.type || ``;
Expand Down Expand Up @@ -60,6 +61,10 @@ const ContentfulModule = ({ module, pathname }) => {
return <PromotionBannerModule {...module} />;
}

if (type === `ContentfulStepsModule`) {
return <StepsModule {...module} />;
}

return null;
};

Expand Down
2 changes: 2 additions & 0 deletions src/components/ContentfulModule/ContentfulModulePropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HelpSearchPropTypes } from "../HelpSearch";
import { PartnersModulePropTypes } from "./PartnersModule";
import { FaqCategoriesModulePropTypes } from "./FaqCategoriesModule";
import { PromotionBannerModulePropTypes } from "./PromotionBannerModule";
import { StepsModulePropTypes } from "./StepsModule";

const ContentfulModulePropTypes = PropTypes.oneOfType([
PropTypes.shape(EventsModulePropTypes),
Expand All @@ -24,6 +25,7 @@ const ContentfulModulePropTypes = PropTypes.oneOfType([
PropTypes.shape(PartnersModulePropTypes),
PropTypes.shape(FaqCategoriesModulePropTypes),
PropTypes.shape(PromotionBannerModulePropTypes),
PropTypes.shape(StepsModulePropTypes),
]);

export default ContentfulModulePropTypes;
Original file line number Diff line number Diff line change
@@ -1,58 +1,29 @@
import React from "react";

import { LinkCollectionModulePropTypes } from "./LinkCollectionModulePropTypes";
import Button from "../../Button";
import Constraint from "../../Constraint";
import LinkCollectionWithImage from "../../LinkCollectionWithImage";
import Section from "../../Section";

import "./LinkCollectionModule.css";

const LinkCollectionModule = ({ links, heading, image }) => {
if (image) {
return (
<Section className="BeVigilantSection">
<Constraint>
<LinkCollectionWithImage image={image} title={heading}>
{links.map(({ id, url, label }) => {
if (!label || !url) {
return null;
}
return (
<li key={id}>
<Button endIcon={`arrow-blue`} to={url} color={`transparent`}>
{label}
</Button>
</li>
);
})}
</LinkCollectionWithImage>
</Constraint>
</Section>
);
import {
LinkCollectionModuleDefaultProps,
LinkCollectionModulePropTypes,
} from "./LinkCollectionModulePropTypes";
import LcmWithImage from "./variants/LcmWithImage";
import LcmDefault from "./variants/LcmDefault";
import LcmLightBlocks from "./variants/LcmLightBlocks";

const LinkCollectionModule = (props) => {
const { variant } = props;

if (variant === `with-image`) {
return <LcmWithImage {...props} />;
}

if (variant === `light-blocks`) {
return <LcmLightBlocks {...props} />;
}
return (
<section className="LinkCollectionModule">
{!!heading && <h2 className="LinkCollectionModule__title">{heading}</h2>}
<ul className="LinkCollectionModule__button-list">
{links.map((link) => {
return (
<li key={link.id}>
<Button endIcon={`arrow-white`} to={link.url} color={`primary`}>
{link.label}
</Button>
</li>
);
})}
</ul>
</section>
);

return <LcmDefault {...props} />;
};

LinkCollectionModule.propTypes = LinkCollectionModulePropTypes;

LinkCollectionModule.defaultProps = {
title: ``,
};
LinkCollectionModule.defaultProps = LinkCollectionModuleDefaultProps;

export default LinkCollectionModule;
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import PropTypes from "prop-types";

const LinkCollectionModulePropTypes = {
title: PropTypes.string,
heading: PropTypes.string,
subheading: PropTypes.string,
variant: PropTypes.oneOf([`default`, `light-blocks`, `with-image`]),
links: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
Expand All @@ -11,4 +13,10 @@ const LinkCollectionModulePropTypes = {
).isRequired,
};

export { LinkCollectionModulePropTypes };
const LinkCollectionModuleDefaultProps = {
heading: ``,
subheading: ``,
variant: `default`,
};

export { LinkCollectionModulePropTypes, LinkCollectionModuleDefaultProps };
11 changes: 9 additions & 2 deletions src/components/ContentfulModule/LinkCollectionModule/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import LinkCollectionModule from "./LinkCollectionModule";
import { LinkCollectionModulePropTypes } from "./LinkCollectionModulePropTypes";
import {
LinkCollectionModulePropTypes,
LinkCollectionModuleDefaultProps,
} from "./LinkCollectionModulePropTypes";

export { LinkCollectionModule, LinkCollectionModulePropTypes };
export {
LinkCollectionModule,
LinkCollectionModulePropTypes,
LinkCollectionModuleDefaultProps,
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.LinkCollectionModule {
.LcmDefault {
margin: var(--s__main-padding) 0;
overflow: hidden;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";

import Button from "../../../Button";
import {
LinkCollectionModuleDefaultProps,
LinkCollectionModulePropTypes,
} from "../LinkCollectionModulePropTypes";

import "./LcmDefault.css";

const LcmDefault = ({ heading, links }) => {
return (
<section className="LcmDefault">
{!!heading && <h2 className="LcmDefault__title">{heading}</h2>}
<ul className="LcmDefault__button-list">
{links.map((link) => {
return (
<li key={link.id}>
<Button endIcon={`arrow-white`} to={link.url} color={`primary`}>
{link.label}
</Button>
</li>
);
})}
</ul>
</section>
);
};

LcmDefault.propTypes = LinkCollectionModulePropTypes;

LcmDefault.defaultProps = LinkCollectionModuleDefaultProps;

export default LcmDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.LcmLightBlocks {
margin: var(--s__main-padding) 0;
overflow: hidden;
width: 100%;

&__heading {
font-size: 1.8rem;
margin: 0;
}

&__button-list {
display: flex;
flex-direction: column;
font-size: var(--fs__h5);
gap: calc(var(--s__unit) * 6);
list-style: none;
padding: 0;

li {
width: 100%;
}

.Button {
border-radius: var(--s__alt-border-radius);
box-sizing: border-box;
height: 100%;
justify-content: center;
padding: calc(var(--s__unit) * 6);
text-align: center;
text-transform: none;
width: 100%;

&::after {
display: none;
}
}
}

@media (min-width: 60rem) {
&__heading {
font-size: var(--fs__h3);
}

&__button-list {
flex-direction: row;
font-size: 1.5rem;
justify-content: space-between;

> * {
flex: 1;
}
}

.Button {
box-shadow: none;

.Icon {
display: none;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from "react";

import Button from "../../../Button";
import Constraint from "../../../Constraint";
import Section from "../../../Section";
import {
LinkCollectionModuleDefaultProps,
LinkCollectionModulePropTypes,
} from "../LinkCollectionModulePropTypes";

import "./LcmLightBlocks.css";

const LcmLightBlocks = ({ heading, subheading, links }) => {
console.log({ links });
return (
<Section className="LcmLightBlocks">
<Constraint>
{!!heading && <h2 className="LcmLightBlocks__heading">{heading}</h2>}
{!!subheading && (
<p className="LcmLightBlocks__subheading">{subheading}</p>
)}
<ul className="LcmLightBlocks__button-list">
{links.map((link) => {
return (
<li key={link.id}>
<Button to={link.url} color={`tertiary`}>
{link.label}
</Button>
</li>
);
})}
</ul>
</Constraint>
</Section>
);
};

LcmLightBlocks.propTypes = LinkCollectionModulePropTypes;

LcmLightBlocks.defaultProps = LinkCollectionModuleDefaultProps;

export default LcmLightBlocks;
Loading

0 comments on commit e875fd2

Please sign in to comment.