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

DO NOT MERGE #1039

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1c6644a
add colour for section background
will0684 Jun 6, 2024
3b3d9a1
update Card image container height
will0684 Jun 6, 2024
1278e0c
show 3 projects on homepage and add new section
will0684 Jun 6, 2024
6c072fd
create updates section component
will0684 Jun 6, 2024
d3d91c4
fix dictionary entry used on project pages
will0684 Jun 6, 2024
9c50bd4
modify Card.js to allow passing styling and html descriptions
will0684 Jun 6, 2024
3a56751
allow excluding H1 nodes in FragmentRender
will0684 Jun 7, 2024
fe74b7d
update homepage query
will0684 Jun 7, 2024
9b6fcf4
update homepage to use FragmentRender
will0684 Jun 7, 2024
15526c3
add viewport to HEAD on all pages for tailwind
will0684 Jun 7, 2024
fac6f4f
use grid ExploreUpdates.js
will0684 Jun 7, 2024
4b4da7e
update homepage to use new query and fragments
will0684 Jun 7, 2024
d60a215
add ExploreUpdates to home page and project pages
will0684 Jun 7, 2024
a78e098
fix list styling on project pages
will0684 Jun 7, 2024
7e73c88
Project page updates (#1035)
blai0264 Jun 7, 2024
2913c79
merge design-update-may-2024
will0684 Jun 7, 2024
10599dc
add margin for new sections on project pages
will0684 Jun 7, 2024
90e5a08
remove defaultprops throwing warnings
will0684 Jun 7, 2024
a22dd29
modify Card.js description to accept html
will0684 Jun 7, 2024
0fb8472
drill down for H1 in HeaderText.jsx
will0684 Jun 7, 2024
49f7295
update mockdata
will0684 Jun 7, 2024
d2d9a57
update home.test.js
will0684 Jun 7, 2024
dcd25a8
revert dateModified
will0684 Jun 7, 2024
1b69d74
use js defaults in Link.js
will0684 Jun 7, 2024
1c5b67b
create unit test and story for ExploreUpdates.js
will0684 Jun 7, 2024
1f3791d
add updates section to all article pages
will0684 Jun 7, 2024
f24f710
rename filterProjects -> filterItems
will0684 Jun 7, 2024
5989de9
sort updates by most recent on all pages
will0684 Jun 7, 2024
1038c93
add missing ski link to homepage
will0684 Jun 7, 2024
7c400db
add key to update pages to ensure proper navigation between update pages
will0684 Jun 8, 2024
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
2,681 changes: 2,083 additions & 598 deletions __mocks__/mockStore.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion __tests__/pages/home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { render, screen } from "@testing-library/react";
import Home from "../../pages/home";
import { homePageData } from "../../__mocks__/mockStore";
import { experimentsData } from "../../__mocks__/mockStore";
import { dictionaryData } from "../../__mocks__/mockStore";

describe("Home", () => {
it("renders without crashing", () => {
render(
<Home
pageData={homePageData.data.scLabsPagev1ByPath}
pageData={homePageData.data.sclabsPageV1ByPath}
experimentsData={experimentsData.data.scLabsPagev1List.items}
dictionary={dictionaryData.data.dictionaryV1List}
/>
);
expect(
Expand Down
3 changes: 3 additions & 0 deletions __tests__/pages/oas-benefits-estimator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
dictionaryData,
oasBenefitsEstimatorData,
oasUpdatesData,
experimentsData,
} from "../../__mocks__/mockStore";
import { shuffle } from "../../lib/utils/shuffle";

describe("OAS Benefits Estimator", () => {
it("renders without crashing", () => {
Expand All @@ -16,6 +18,7 @@ describe("OAS Benefits Estimator", () => {
pageData={oasBenefitsEstimatorData.data.sclabsPageV1ByPath}
updatesData={oasUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={shuffle(experimentsData.data.scLabsPagev1List.items)}
/>
);
});
Expand Down
80 changes: 43 additions & 37 deletions components/atoms/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ import PropTypes from "prop-types";

// Use this component for Footer link and use Next.js <Link>
// for all links within the site
export function Link(props) {
export function Link({
href = "#",
target = "_self",
ariaLabel,
component = "a",
linkStyle,
disabled,
lang,
locale,
onClick,
id,
dataGcAnalyticsCustomClick,
text,
abbr,
...rest
}) {
//Styling for links based on Figma Design
let basicStyle = "";
switch (props.linkStyle) {
switch (linkStyle) {
case "basicStyleWithEmphasis":
basicStyle =
"underline text-multi-blue-blue70b font-body text-browserh5 font-bold text-mobileh5 leading-33px hover:text-multi-blue-blue50b";
Expand Down Expand Up @@ -37,70 +52,61 @@ export function Link(props) {
break;
}

const Component = props.component || "a";
const Component = component || "a";

function onKeyDown() {
true;
}

return Component !== "a" ? (
<Component
href={props.href}
disabled={props.disabled}
lang={props.lang}
target={props.target}
aria-label={props.ariaLabel || props.text}
href={href}
disabled={disabled}
lang={lang}
target={target}
aria-label={ariaLabel || text}
role="link"
>
<a
href={props.href}
locale={props.locale}
onClick={props.onClick ? props.onClick : undefined}
id={props.id}
href={href}
locale={locale}
onClick={onClick ? onClick : undefined}
id={id}
className={`${basicStyle}`}
data-gc-analytics-customclick={props.dataGcAnalyticsCustomClick}
data-gc-analytics-customclick={dataGcAnalyticsCustomClick}
onKeyDown={onKeyDown}
>
{/* <!-- English Text: English --> */}
<span className={props.abbr ? "language-toggle-text" : ""}>
{props.text}
</span>
<span className={abbr ? "language-toggle-text" : ""}>{text}</span>
{/* <!-- English Text: title="English", en --> */}
<abbr className="language-toggle-abbr" title={props.text}>
{props.abbr}
<abbr className="language-toggle-abbr" title={text}>
{abbr}
</abbr>
</a>
</Component>
) : (
<a
href={props.href}
href={href}
className={`${basicStyle}`}
id={props.id}
disabled={props.disabled}
lang={props.lang}
target={props.target}
aria-label={props.ariaLabel || props.text}
locale={props.locale}
onClick={props.onClick ? props.onClick : undefined}
data-gc-analytics-customclick={props.dataGcAnalyticsCustomClick}
id={id}
disabled={disabled}
lang={lang}
target={target}
aria-label={ariaLabel || text}
locale={locale}
onClick={onClick ? onClick : undefined}
data-gc-analytics-customclick={dataGcAnalyticsCustomClick}
>
{/* <!-- English Text: English --> */}
<span className={props.abbr ? "language-toggle-text" : ""}>
{props.text}
</span>
<span className={abbr ? "language-toggle-text" : ""}>{text}</span>
{/* <!-- English Text: title="English", en --> */}
<abbr className="language-toggle-abbr" title={props.text}>
{props.abbr}
<abbr className="language-toggle-abbr" title={text}>
{abbr}
</abbr>
</a>
);
}

Link.defaultProps = {
target: "_self",
href: "#",
};

Link.propTypes = {
/**
* The text that Text Link will display
Expand Down
6 changes: 4 additions & 2 deletions components/fragment_renderer/FragmentRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const FRAGMENTS = {
"SCLabs-Image-v1": ImageWithCollapse,
};

const mapFragmentsToProps = (fragmentData, fragmentName, locale) => {
const mapFragmentsToProps = (fragmentData, fragmentName, locale, excludeH1) => {
switch (fragmentName) {
case "SCLabs-Feature-v1":
return {
Expand Down Expand Up @@ -63,6 +63,7 @@ const mapFragmentsToProps = (fragmentData, fragmentName, locale) => {
? fragmentData.scLabContent[0].scContentEn.json
: fragmentData.scLabContent[0].scContentFr.json,
layout: fragmentData.scLabLayout,
excludeH1: excludeH1,
};

case "SCLabs-Comp-Content-v1":
Expand Down Expand Up @@ -146,7 +147,8 @@ export default function FragmentRender(props) {
{...mapFragmentsToProps(
fragmentData,
fragmentData?._model.title,
props.locale
props.locale,
props.excludeH1
)}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import Image from "next/image";
import TextRender from "../../text_node_renderer/TextRender";

export default function BasicTextWithImage({ src, alt, width, height, data }) {
export default function BasicTextWithImage({
src,
alt,
width,
height,
data,
excludeH1,
}) {
return (
<div className="layout-container grid grid-cols-12 gap-x-6 my-12">
<div className="hidden lg:grid col-start-8 col-span-5 row-start-1 row-span-2">
Expand All @@ -19,7 +26,7 @@ export default function BasicTextWithImage({ src, alt, width, height, data }) {
</div>
</div>
<div className="col-span-12 lg:col-span-7">
<TextRender data={data} excludeH1={true} />
<TextRender data={data} excludeH1={excludeH1} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default function TextWithImage({
height,
data,
layout,
excludeH1,
}) {
switch (layout) {
case "default":
Expand All @@ -18,6 +19,7 @@ export default function TextWithImage({
width={width}
height={height}
data={data}
excludeH1={excludeH1}
/>
);
case "image-vertical-line-content":
Expand All @@ -28,6 +30,7 @@ export default function TextWithImage({
width={width}
height={height}
data={data}
excludeH1={excludeH1}
/>
);
default:
Expand Down
21 changes: 15 additions & 6 deletions components/molecules/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export const Card = (props) => {
<Link href={props.href}>
<div
className={`h-full group card-shadow border border-custom-gray-border rounded-md pb-4 hover:cursor-pointer ${
"border-" + tagColour
"border-" + tagColour + ` ${props.customStyling}`
}`}
data-testid={props.dataTestId}
data-cy={props.dataCy}
>
{props.showImage ? (
<div className="sm:h-80 flex justify-center">
<div className="h-[208px] flex justify-center">
<Image
src={props.imgSrc}
alt={props.imgAlt}
Expand Down Expand Up @@ -76,9 +76,13 @@ export const Card = (props) => {
) : (
""
)}
<p className="text-custom-gray-text mx-6 leading-30px text-lg">
{props.description}
</p>
{props.htmlDesc ? (
props.htmlDesc
) : (
<p className="text-custom-gray-text mx-6 leading-30px text-lg">
{props.description}
</p>
)}
{props.showButton ? (
<ActionButton
href={props.btnHref}
Expand Down Expand Up @@ -119,7 +123,7 @@ Card.propTypes = {
/**
* Description of the experiment card.
*/
description: PropTypes.string.isRequired,
description: PropTypes.string,

/**
* the test id for unit tests
Expand All @@ -131,6 +135,11 @@ Card.propTypes = {
*/
dataCy: PropTypes.string,

/**
* Boolean value to allow passing of html for description
*/
htmlDesc: PropTypes.object,

/**
* Boolean value to show or hide image
*/
Expand Down
60 changes: 60 additions & 0 deletions components/organisms/ExploreProjects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { useEffect } from "react";
import Card from "../molecules/Card";

//callback function that creates a card for a project when called
const createCard = (locale, project) => {
return (
<li
key={project.scId}
className="rounded-md bg-multi-neutrals-white col-span-12 lg:col-span-4"
>
<Card
showImage
imgSrc={
locale === "en"
? `https://www.canada.ca${project.scSocialMediaImageEn?._path}`
: `https://www.canada.ca${project.scSocialMediaImageFr?._path}`
}
imgAlt={
locale === "en"
? project.scSocialMediaImageAltTextEn
: project.scSocialMediaImageAltTextFr
}
imgHeight={project.scSocialMediaImageEn.height}
imgWidth={project.scSocialMediaImageEn.width}
title={locale === "en" ? project.scTitleEn : project.scTitleFr}
href={locale === "en" ? project.scPageNameEn : project.scPageNameFr}
description={
locale === "en"
? project.scDescriptionEn.json[0].content[0].value
: project.scDescriptionFr.json[0].content[0].value
}
/>
</li>
);
};

export function ExploreProjects(props) {
//initialize props
const { locale, projects } = props;
//create cards for current projects
const displayCurrentProjects = projects.map((project) =>
createCard(locale, project)
);
return (
//create html for "Explore other projects" section
<div className="py-24 max-w-full bg-multi-blue-blue65b">
<div className="layout-container">
<h2 className="mt-0 text-multi-neutrals-white">
{locale === "en"
? "Explore other projects"
: "Explorer d'autres projets"}
</h2>
<ul className="grid grid-cols-12 gap-x-6 gap-y-6 list-none">
{/*iterate over filteredProjects array and create card for each project */}
{displayCurrentProjects}
</ul>
</div>
</div>
);
}
Loading
Loading