Skip to content

Commit

Permalink
IS-456: Text Cards Previews (#1516)
Browse files Browse the repository at this point in the history
* wip: basic cms preview

* feat: refactor styles

Co-authored-by: Alexander Lee <[email protected]>

* feat: enable previews on text-cards

* fix: lint issues

* feat: update previews to match template

Co-authored-by: Alexander Lee <[email protected]>

---------

Co-authored-by: Alexander Lee <[email protected]>
  • Loading branch information
harishv7 and alexanderleegs committed Sep 27, 2023
1 parent 19c1ae9 commit 1e7d218
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/layouts/EditHomepage/HomepagePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import TemplateInfobarSection from "templates/homepage/InfobarSection"
import TemplateInfopicLeftSection from "templates/homepage/InfopicLeftSection"
import TemplateInfopicRightSection from "templates/homepage/InfopicRightSection"
import TemplateResourcesSection from "templates/homepage/ResourcesSection"
import TemplateTextCardsSection from "templates/homepage/TextCardsSection"
import { getClassNames } from "templates/utils/stylingUtils"

import {
Expand Down Expand Up @@ -182,17 +183,17 @@ export const HomepagePreview = ({
/>
</>
)}
{/* Textcard section placeholder */}
{/* Textcard section */}
{EditorHomepageFrontmatterSection.isTextcard(section) && (
<>
<TemplateInfobarSection
<TemplateTextCardsSection
key={`section-${sectionIndex}`}
title={section.textcards.title}
subtitle={section.textcards.subtitle}
description={section.textcards.description}
button=""
cards={section.textcards.cards}
sectionIndex={sectionIndex}
ref={scrollRefs[sectionIndex]}
ref={scrollRefs[sectionIndex] as Ref<HTMLDivElement>}
/>
</>
)}
Expand Down
1 change: 1 addition & 0 deletions src/styles/isomer-template/components/homepage/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import "./announcements.scss";
@import "./hero.scss";
@import "./text-cards.scss";
62 changes: 62 additions & 0 deletions src/styles/isomer-template/components/homepage/_text-cards.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.textcards-section {
flex-direction: column;
align-items: center;
text-align: center;

@media screen and (min-width: 1408px) {
max-width: 1440px;
margin: auto;
}
}

.textcards-card-section {
justify-content: center;
align-items: flex-start;
gap: 2rem;
width: 100%;
flex-wrap: wrap;
flex-direction: column;

@media screen and (min-width: 770px) {
flex-direction: row;
}

.textcards-card-body {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 1rem;
flex: 1 0 0;
align-self: stretch;
color: #484848;

border-radius: 4px;
border: 1px solid $stroke-default;
background: var(--white, #FFF);
box-shadow: 0px 0px 10px 0px rgba(191, 191, 191, 0.50);

@media screen and (min-width: 770px) {
max-width: 50%;
}

@media screen and (min-width: 1280px) {
max-width: 40%;
}

@media screen and (min-width: 770px) and (max-width: 1279px) {
flex: 0 0 calc(50% - 24px);
}

&:hover {
background-color: $interaction-hover;
cursor: pointer;
> .link {
color: var(--site-secondary-color-hover);
}
}

.textcards-card-description {
flex-grow: 1;
}
}
}
4 changes: 4 additions & 0 deletions src/styles/isomer-template/shared.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@charset 'UTF-8';

$stroke-default-color: #D0D5DD;
$interaction-hover-color: #F9F9F9;
30 changes: 28 additions & 2 deletions src/styles/isomer-template/theme/_text-styles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
display-1 {
color: $content-base;

font-family: Lato;
font-size: 4rem;
font-style: normal;
font-weight: 700;
line-height: 5rem; /* 125% */
letter-spacing: -1.408px;
}

.h1 {
color: $content-base;

Expand All @@ -9,6 +20,17 @@
letter-spacing: -1.056px;
}

.h1-small {
color: $content-base;

font-family: Lato;
font-size: 2.75rem;
font-style: normal;
font-weight: 700;
line-height: 3.5rem; /* 116.667% */
letter-spacing: -1.056px;
}

.h2 {
color: $content-base;

Expand Down Expand Up @@ -96,7 +118,7 @@
}

.button-text {
color: $utility-theme-color;
color: var(--site-secondary-color);
text-align: center;
font-feature-settings: "clig" off, "liga" off;

Expand All @@ -110,7 +132,7 @@
}

.link {
color: $utility-theme-color;
color: var(--site-secondary-color);
font-variant-numeric: lining-nums tabular-nums;
font-feature-settings: "clig" off, "liga" off;

Expand All @@ -122,4 +144,8 @@
line-height: 1.5rem; /* 133.333% */
letter-spacing: 0.01688rem;
text-decoration-line: underline;

&:hover {
color: var(--site-secondary-color-hover)
}
}
97 changes: 97 additions & 0 deletions src/templates/homepage/TextCardsSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { ForwardedRef, forwardRef, RefObject } from "react"

import editorStyles from "styles/isomer-cms/pages/Editor.module.scss"

import { getClassNames } from "templates/utils/stylingUtils"

import { TextcardsSection } from "types/homepage"

interface TemplateTextCardsSectionProps extends TextcardsSection {
sectionIndex: number
}

const TemplateTextCardsSection = forwardRef<
HTMLDivElement,
TemplateTextCardsSectionProps
>(
(
{
title,
subtitle,
description,
cards,
sectionIndex,
}: TemplateTextCardsSectionProps,
ref: ForwardedRef<HTMLDivElement>
) => {
return (
<section
className={getClassNames(editorStyles, [
"px-8",
"px-sm-16",
"px-md-24",
"py-24",
sectionIndex % 2 === 1 ? "bg-newssection" : "",
])}
ref={ref}
>
<div
className={getClassNames(editorStyles, [
"textcards-section",
"is-flex",
])}
>
<p className={getClassNames(editorStyles, ["subtitle-2", "pb-4"])}>
{subtitle}
</p>
<h1 className="h1 has-text-secondary has-text-centered pb-4">
{title}
</h1>
<p
className={getClassNames(editorStyles, [
"body-1",
"has-text-centered",
"pb-12",
])}
>
{description}
</p>
<div
className={getClassNames(editorStyles, [
"textcards-card-section",
"has-text-left",
"is-flex",
])}
>
{!!cards &&
cards.map((card) => (
<>
<a
className={getClassNames(editorStyles, [
"textcards-card-body",
"is-flex",
"p-6",
])}
href="{{ card.url }}"
>
<h3 className={editorStyles.h3}>{card.title}</h3>
<p
className={getClassNames(editorStyles, [
"body-1",
"textcards-card-description",
])}
>
{card.description}
</p>
<p className={editorStyles.link}>{card.linktext}</p>
</a>
</>
))}
</div>
</div>
</section>
)
}
)

export default TemplateTextCardsSection

0 comments on commit 1e7d218

Please sign in to comment.