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

Task/HOM-1 update white hero banner text color #826

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/components/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SBGlobalHeader } from './storyblok/globalHeader';
import { SBGlobalHeaderPicker } from './storyblok/globalHeaderPicker';
import { SBGrid } from './storyblok/grid';
import { SBHeading } from './storyblok/heading';
import Hero from './composite/hero';
import Hero from './composite/Hero/hero';
import IconCard from './cards/iconCard';
import InterstitialPage from './page-types/registrationFormPage/interstitialPage';
import Itinerary from './composite/itinerary';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import SbEditable from 'storyblok-react';
import { ArrowDownIcon } from '@heroicons/react/outline';
import { dcnb } from 'cnbuilder';
import { FlexBox } from '../layout/FlexBox';
import { Container } from '../layout/Container';
import { SrOnlyText } from '../accessibility/SrOnlyText';
import FullWidthImage from '../media/fullWidthImage';
import CreateBloks from '../../utilities/createBloks';
import getNumBloks from '../../utilities/getNumBloks';
import { heroGradient } from '../../utilities/dataSource';
import { FlexBox } from '../../layout/FlexBox';
import { Container } from '../../layout/Container';
import { SrOnlyText } from '../../accessibility/SrOnlyText';
import FullWidthImage from '../../media/fullWidthImage';
import CreateBloks from '../../../utilities/createBloks';
import getNumBloks from '../../../utilities/getNumBloks';
import { heroGradient } from '../../../utilities/dataSource';
import * as styles from './hero.styles';

const Hero = ({
Expand Down Expand Up @@ -45,46 +45,35 @@ const Hero = ({

let blackText;
if (gradientProp === 'white') {
blackText = 'xs:su-text-black';
blackText = 'xs:su-text-black-true';
}

const numCta = getNumBloks(cta);

return (
<SbEditable content={blok}>
<Container
className="hero su-relative su-bg-saa-black lg:su-top-0"
width="full"
>
<Container className={styles.container} width="full">
{filename?.startsWith('http') && (
<figure className="su-absolute su-top-0 su-overflow-hidden su-w-full su-h-full">
<figure className={styles.imgWrapper}>
<FullWidthImage
filename={filename}
imageFocus={imageFocus}
smartFocus={focus}
className="su-w-full su-h-full su-object-cover"
className={styles.img}
loading="eager"
/>
</figure>
)}
<div
className={dcnb(
'su-absolute su-block su-w-full su-h-full su-top-0 su-bg-gradient-to-t su-from-saa-black',
gradient
)}
className={styles.gradientOverlay({ gradient })}
aria-hidden="true"
/>
<Container
className={`su-relative su-rs-pt-9
${isHideScroll ? 'su-rs-pb-8' : 'su-rs-pb-4'}`}
>
<FlexBox direction="col" className="lg:su-mt-[19rem]">
<Container className={styles.textContainer({ isHideScroll })}>
<FlexBox direction="col" className={styles.flexbox}>
{(sansSuper || serifSuper || headline || sansSub) && (
<div className={dcnb('su-text-center su-text-white', blackText)}>
<div className={styles.textWrapper({ blackText })}>
{sansSuper && (
<span className="su-block su-max-w-prose su-font-semibold su-leading-display su-text-shadow-md su-type-4 su-mx-auto su-mb-01em">
{sansSuper}
</span>
<span className={styles.sansSuper}>{sansSuper}</span>
)}
{serifSuper && (
<span className={styles.serifSuper({ blackText })}>
Expand All @@ -107,25 +96,17 @@ const Hero = ({
</div>
)}
{numCta > 0 && (
<div className={sansSub ? 'su-rs-mt-4' : ''}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yvonnetangsu I wasn't sure if this one would still work if moved to hero.styles. Is sansSub referring to something different here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shc314 You'll need to pass sansSub into the styles here like how you pass blackText into the other ones 😄 Otherwise in the styles file, it wouldn't know whether this field exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. There was already a sansSub in the styles file, so I think that's why it didn't cause an error, but I don't think it's the same one as what's here.

<div className={styles.marginTop({ sansSub })}>
<CreateBloks blokSection={cta} />
</div>
)}
{!isHideScroll && (
<div
className={dcnb(
'su-text-center su-text-white su-grow-0 su-rs-mt-5 su-font-serif su-font-regular su-text-19 md:su-text-22',
blackText
)}
>
<p className="su-mb-02em">Scroll to explore</p>
<a
href="#page-title"
className="su-block su-mx-auto su-w-fit su-group"
>
<div className={styles.scroll({ blackText })}>
<p className={styles.scrollText}>Scroll to explore</p>
<a href="#page-title" className={styles.pageTitleLink}>
<SrOnlyText>Jump to main content</SrOnlyText>
<ArrowDownIcon
className="su-transition-colors su-text-digital-red-xlight su-w-40 su-h-40 su-p-6 su-border-2 su-border-cardinal-red su-rounded-full group-hocus:su-text-white group-hocus:su-bg-cardinal-red-dark"
className={styles.arrowDownIcon}
aria-hidden="true"
/>
</a>
Expand Down
49 changes: 49 additions & 0 deletions src/components/composite/Hero/hero.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { dcnb } from 'cnbuilder';

export const container = 'hero su-relative su-bg-saa-black lg:su-top-0';
export const imgWrapper =
'su-absolute su-top-0 su-overflow-hidden su-w-full su-h-full';
export const img = 'su-w-full su-h-full su-object-cover';
export const gradientOverlay = ({ gradient }) =>
dcnb(
'su-absolute su-block su-w-full su-h-full su-top-0 su-bg-gradient-to-t su-from-saa-black',
gradient
);
export const textContainer = ({ isHideScroll }) => `su-relative su-rs-pt-9
${isHideScroll ? 'su-rs-pb-8' : 'su-rs-pb-4'}`;
export const flexbox = 'lg:su-mt-[19rem]';
export const textWrapper = ({ blackText }) =>
dcnb('su-text-center su-text-white', blackText);
Comment on lines +15 to +16
Copy link
Member

@yvonnetangsu yvonnetangsu Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a slightly better way to handle this. Here if blackText exists, you're going to have both of these classes su-text-white and su-text-black-true, and you're counting on su-text-black-true being compiled after su-text-white in the CSS so it overrides su-text-white. A better way would be to have a isBlackText variable as boolean instead, then you can pass in dcnb('su-text-center', isBlackText ? 'su-text-black-true' : 'su-text-white'), which is a lot safer @shc314

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this suggestion. The text needs to be white when the screen size is smaller than the xs breakpoint. That's why I was using xs:su-text-black-true. How can I add a condition for smaller than the xs breakpoint?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're doing - let me take a look later today @shc314

export const sansSuper =
'su-block su-max-w-prose su-font-semibold su-leading-display su-text-shadow-md su-type-4 su-mx-auto su-mb-01em';
export const serifSuper = ({ blackText }) =>
dcnb(
'su-block su-max-w-prose su-font-serif su-leading-display su-type-2 su-mx-auto su-mb-05em su-text-shadow',
{
'xs:su-text-shadow-white': blackText === 'xs:su-text-black-true',
}
);
export const headline = ({ blackText }) =>
dcnb(
'su-block su-font-bold su-font-serif su-leading-tight su-tracking-normal su-mb-02em su-text-shadow-lg',
{
'xs:su-text-shadow-white-lg': blackText === 'xs:su-text-black-true',
}
);
export const sansSub = ({ blackText }) =>
dcnb(
'su-max-w-prose su-type-1 su-leading-display su-text-shadow su-mx-auto su-mb-0 su-text-shadow',
{
'xs:su-text-shadow-white': blackText === 'xs:su-text-black-true',
}
);
export const marginTop = ({ sansSub }) => (sansSub ? 'su-rs-mt-4' : '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yvonnetangsu After I passed sansSub as a prop, ESLint says 'sansSub' is already declared in the upper scope on line 33. Should I change the name of the one on line 33?

Copy link
Member

@yvonnetangsu yvonnetangsu Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shc314 So yes, the fastest way to do this would be to update the variable name on line 33, but after that you'll need to update it in the hero.js file as well (where it uses styles.sansSub), so for example, if you rename the variable to export const subhead = 'something', then in hero.js, you'll use className={styles.subhead} 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I've changed the variable name and there is no error now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update @shc314! I'll get back to you next week on this - it's been a really busy week.

export const scroll = ({ blackText }) =>
dcnb(
'su-text-center su-text-white su-grow-0 su-rs-mt-5 su-font-serif su-font-regular su-text-19 md:su-text-22',
blackText
);
export const scrollText = 'su-mb-02em';
export const pageTitleLink = 'su-block su-mx-auto su-w-fit su-group';
export const arrowDownIcon =
'su-transition-colors su-text-digital-red-xlight su-w-40 su-h-40 su-p-6 su-border-2 su-border-cardinal-red su-rounded-full group-hocus:su-text-white group-hocus:su-bg-cardinal-red-dark';
25 changes: 0 additions & 25 deletions src/components/composite/hero.styles.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/page-types/formPage/formPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
setGiveGabVars,
unsetGiveGabVars,
} from '../../../utilities/giveGabVars';
import Hero from '../../composite/hero';
import Hero from '../../composite/Hero/hero';
import {
formatFmDate,
formatEmailDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Heading } from '../../simple/Heading';
import Layout from '../../partials/layout';
import getNumBloks from '../../../utilities/getNumBloks';
import Ankle from '../../partials/ankle/ankle';
import Hero from '../../composite/hero';
import Hero from '../../composite/Hero/hero';
import { Grid } from '../../layout/Grid';
import {
FormContextProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Layout from '../../partials/layout';
import CreateBloks from '../../../utilities/createBloks';
import getNumBloks from '../../../utilities/getNumBloks';
import Ankle from '../../partials/ankle/ankle';
import Hero from '../../composite/hero';
import Hero from '../../composite/Hero/hero';
import { Grid } from '../../layout/Grid';
import { GridCell } from '../../layout/GridCell';
import AuthenticatedPage from '../../auth/AuthenticatedPage';
Expand Down
Loading