diff --git a/src/components/elements/screen-centered.tsx b/src/components/elements/screen-centered.tsx new file mode 100644 index 00000000..cfb71bb4 --- /dev/null +++ b/src/components/elements/screen-centered.tsx @@ -0,0 +1,19 @@ +"use client" + +import {HTMLAttributes, useCallback, useEffect, useRef, useState} from "react" +import {useEventListener} from "usehooks-ts" + +const ScreenCentered = ({children}: HTMLAttributes) => { + const ref = useRef(null) + const [translate, setTranslate] = useState(0) + const calculateTranslation = useCallback(() => setTranslate(ref.current?.getBoundingClientRect().x || 0), []) + useEventListener("resize", calculateTranslation) + useEffect(() => calculateTranslation(), [calculateTranslation]) + + return ( +
+
{children}
+
+ ) +} +export default ScreenCentered diff --git a/src/components/nodes/pages/stanford-page/stanford-page-page.tsx b/src/components/nodes/pages/stanford-page/stanford-page-page.tsx index ed3ff701..5090e49f 100644 --- a/src/components/nodes/pages/stanford-page/stanford-page-page.tsx +++ b/src/components/nodes/pages/stanford-page/stanford-page-page.tsx @@ -2,11 +2,7 @@ import Rows from "@components/paragraphs/rows/rows" import InteriorPage from "@components/layouts/interior-page" import {H1} from "@components/elements/headers" import {HtmlHTMLAttributes} from "react" -import { - NodeStanfordPage, - NodeStanfordPageSuPageBannerUnion, - NodeStanfordPageSuPageComponentsUnion, -} from "@lib/gql/__generated__/drupal.d" +import {NodeStanfordPage, NodeStanfordPageSuPageBannerUnion} from "@lib/gql/__generated__/drupal.d" import PageTitleBannerParagraph from "@components/paragraphs/stanford-page-title-banner/page-title-banner-paragraph" import SumArcBannerParagraph from "@components/paragraphs/sum-arc-banner/sum-arc-banner-paragraph" import SumTopBannerParagraph from "@components/paragraphs/sum-top-banner/sum-top-banner-paragraph" @@ -17,25 +13,13 @@ type Props = HtmlHTMLAttributes & { } const StanfordPagePage = ({node, ...props}: Props) => { - // If the page contains any of the following components, force the page to be full width. This prevents the need to - // address the large components on "interior" pages that contain a left sidebar. It's more effort than it's worth. - const fullWidthComponents: NodeStanfordPageSuPageComponentsUnion["__typename"][] = [ - "ParagraphSumTestimonial", - "ParagraphSumCarousel", - "ParagraphSumCourseFilter", - "ParagraphSumPillBanner", - "ParagraphStanfordBanner", - ] const pageTitleBanners: NodeStanfordPageSuPageBannerUnion["__typename"][] = [ "ParagraphStanfordPageTitleBanner", "ParagraphSumArcBanner", "ParagraphSumTopBanner", ] - const fullWidth = - node.layoutSelection?.id === "stanford_basic_page_full" || - !!node.suPageComponents?.find(component => fullWidthComponents.includes(component.__typename)) - + const fullWidth = node.layoutSelection?.id === "stanford_basic_page_full" const lastComponent = node.suPageComponents?.[node.suPageComponents?.length - 1]?.__typename const hasBannerOrCalculator = [ diff --git a/src/components/paragraphs/stanford-banner/banner-paragraph.tsx b/src/components/paragraphs/stanford-banner/banner-paragraph.tsx index d150467b..524d13fc 100644 --- a/src/components/paragraphs/stanford-banner/banner-paragraph.tsx +++ b/src/components/paragraphs/stanford-banner/banner-paragraph.tsx @@ -9,6 +9,7 @@ import ActionLink from "@components/elements/action-link" import Link from "next/link" import {ArrowRightIcon} from "@heroicons/react/24/outline" import Image from "next/image" +import ScreenCentered from "@components/elements/screen-centered" type Props = HtmlHTMLAttributes & { paragraph: ParagraphStanfordBanner @@ -30,80 +31,88 @@ const BannerParagraph = ({paragraph, eagerLoadImage, ...props}: Props) => { const BannerWrapper: ElementType = isSection ? "section" : "div" return ( - - {hasCard && ( -
- {paragraph.suBannerHeader && ( -
- {headerTag === "h2" &&

{paragraph.suBannerHeader}

} - {headerTag === "h3" &&

{paragraph.suBannerHeader}

} - {headerTag === "h4" &&

{paragraph.suBannerHeader}

} - {headerTag === "div" && ( -
{paragraph.suBannerHeader}
- )} -
- )} + + + {hasCard && ( +
+ {paragraph.suBannerHeader && ( +
+ {headerTag === "h2" && ( +

{paragraph.suBannerHeader}

+ )} + {headerTag === "h3" && ( +

{paragraph.suBannerHeader}

+ )} + {headerTag === "h4" && ( +

{paragraph.suBannerHeader}

+ )} + {headerTag === "div" && ( +
{paragraph.suBannerHeader}
+ )} +
+ )} - {paragraph.suBannerSupHeader && ( -
{paragraph.suBannerSupHeader}
- )} + {paragraph.suBannerSupHeader && ( +
{paragraph.suBannerSupHeader}
+ )} - + - {paragraph.suBannerButton?.url && !semiCircleButton && ( -
- - {paragraph.suBannerButton.title} - -
- )} -
- )} -
- {paragraph.suBannerImage?.mediaImage && ( - {paragraph.suBannerImage?.mediaImage.alt + {paragraph.suBannerButton?.url && !semiCircleButton && ( +
+ + {paragraph.suBannerButton.title} + +
+ )} +
)} -
- {paragraph.suBannerButton?.url && semiCircleButton && ( - - {paragraph.suBannerButton.title} - - +
+ {paragraph.suBannerImage?.mediaImage && ( + {paragraph.suBannerImage?.mediaImage.alt )} +
+ {paragraph.suBannerButton?.url && semiCircleButton && ( + + {paragraph.suBannerButton.title} + + + )} +
-
-
+ +
) } export default BannerParagraph diff --git a/src/components/paragraphs/sum-carousel/sum-carousel-paragraph.tsx b/src/components/paragraphs/sum-carousel/sum-carousel-paragraph.tsx index b16ea9a6..1d196273 100644 --- a/src/components/paragraphs/sum-carousel/sum-carousel-paragraph.tsx +++ b/src/components/paragraphs/sum-carousel/sum-carousel-paragraph.tsx @@ -14,6 +14,7 @@ import ArcBanner from "@components/patterns/arc-banner" import {getParagraphBehaviors} from "../get-paragraph-behaviors" import clsx from "clsx" import {twMerge} from "tailwind-merge" +import ScreenCentered from "@components/elements/screen-centered" type Props = HTMLAttributes & { paragraph: ParagraphSumCarousel @@ -26,50 +27,52 @@ const SumCarouselParagraph = ({paragraph, ...props}: Props) => { const Element = paragraph.sumCarouselHeader ? "article" : "div" return ( - - {isArcBanner && ( - + + + {isArcBanner && ( + + + + )} + + {!isArcBanner && ( - - )} - - {!isArcBanner && ( - - )} + )} - {paragraph.sumCarouselSlides && ( -
- - {paragraph.sumCarouselSlides.map((slide, slideIndex) => { - return ( - - ) - })} - -
- )} -
+ {paragraph.sumCarouselSlides && ( +
+ + {paragraph.sumCarouselSlides.map((slide, slideIndex) => { + return ( + + ) + })} + +
+ )} + + ) } diff --git a/src/components/paragraphs/sum-pill-banner/sum-pill-banner-paragraph.tsx b/src/components/paragraphs/sum-pill-banner/sum-pill-banner-paragraph.tsx index 58db9c5e..2b6c45a6 100644 --- a/src/components/paragraphs/sum-pill-banner/sum-pill-banner-paragraph.tsx +++ b/src/components/paragraphs/sum-pill-banner/sum-pill-banner-paragraph.tsx @@ -8,6 +8,7 @@ import {twMerge} from "tailwind-merge" import {getParagraphBehaviors} from "@components/paragraphs/get-paragraph-behaviors" import {clsx} from "clsx" import ActionLink from "@components/elements/action-link" +import ScreenCentered from "@components/elements/screen-centered" type Props = HtmlHTMLAttributes & { paragraph: ParagraphSumPillBanner @@ -18,83 +19,86 @@ const SumPillBannerParagraph = ({paragraph, ...props}: Props) => { const Element = paragraph.sumPillBannerHeadline ? "article" : "div" return ( - - {paragraph.sumPillBannerBkgd && ( -
-
- {paragraph.sumPillBannerBkgd.mediaImage.alt + + + {paragraph.sumPillBannerBkgd && ( +
+
+ {paragraph.sumPillBannerBkgd.mediaImage.alt +
-
- )} -
-
-
-
- {paragraph.sumPillBannerHeadline && ( -

- {paragraph.sumPillBannerHeadline} -

- )} + )} +
+
+
+
+ {paragraph.sumPillBannerHeadline && ( +

+ {paragraph.sumPillBannerHeadline} +

+ )} - {paragraph.sumPillBannerSuphead && ( -
{paragraph.sumPillBannerSuphead}
- )} -
+ {paragraph.sumPillBannerSuphead && ( +
{paragraph.sumPillBannerSuphead}
+ )} +
- + - {paragraph.sumPillBannerLink?.url && ( - - {paragraph.sumPillBannerLink.title} - - )} + {paragraph.sumPillBannerLink?.url && ( + + {paragraph.sumPillBannerLink.title} + + )} +
-
- {paragraph.sumPillBannerCards && ( -
- {paragraph.sumPillBannerCards.map(card => ( - - ))} -
- )} -
- + {paragraph.sumPillBannerCards && ( +
+ {paragraph.sumPillBannerCards.map(card => ( + + ))} +
+ )} +
+ + ) } diff --git a/src/components/paragraphs/sum-testimonial-banner/sum-testimonial-banner-paragraph.tsx b/src/components/paragraphs/sum-testimonial-banner/sum-testimonial-banner-paragraph.tsx index 3c062562..2e11f818 100644 --- a/src/components/paragraphs/sum-testimonial-banner/sum-testimonial-banner-paragraph.tsx +++ b/src/components/paragraphs/sum-testimonial-banner/sum-testimonial-banner-paragraph.tsx @@ -9,6 +9,7 @@ import {H2} from "@components/elements/headers" import Wysiwyg from "@components/elements/wysiwyg" import YoutubeVideoPill from "@components/elements/youtube-video-pill" import ActionLink from "@components/elements/action-link" +import ScreenCentered from "@components/elements/screen-centered" type Props = HtmlHTMLAttributes & { paragraph: ParagraphSumTestimonial @@ -38,135 +39,134 @@ const SumTestimonialBannerParagraph = ({paragraph, ...props}: Props) => { } return ( -
-
+
- {paragraph.sumTestimonialBkgImg.mediaImage.alt +
+ {paragraph.sumTestimonialBkgImg.mediaImage.alt - {paragraph.sumTestimonialHsVideo.__typename === "MediaImage" && ( -
-
- {paragraph.sumTestimonialHsVideo.mediaImage.alt + {paragraph.sumTestimonialHsVideo.__typename === "MediaImage" && ( +
+
+ {paragraph.sumTestimonialHsVideo.mediaImage.alt +
-
- )} + )} - {paragraph.sumTestimonialHsVideo.__typename === "MediaVideo" && ( -
- -
- )} -
+ {paragraph.sumTestimonialHsVideo.__typename === "MediaVideo" && ( +
+ +
+ )} +
-
-

- {paragraph.sumTestimonialHeading} -

+

+ {paragraph.sumTestimonialHeading} +

- + - {paragraph.sumTestimonialName &&
{paragraph.sumTestimonialName}
} + {paragraph.sumTestimonialName &&
{paragraph.sumTestimonialName}
} - {(paragraph.sumTestimonialUniv || studentType) && ( -
{`${paragraph.sumTestimonialUniv || ""} ${studentType || ""}`.trim()}
- )} - {paragraph.sumTestimonialAffi &&
{paragraph.sumTestimonialAffi}
} + {(paragraph.sumTestimonialUniv || studentType) && ( +
{`${paragraph.sumTestimonialUniv || ""} ${studentType || ""}`.trim()}
+ )} + {paragraph.sumTestimonialAffi &&
{paragraph.sumTestimonialAffi}
} - {paragraph.sumTestimonialButton?.url && ( - - {paragraph.sumTestimonialButton.title} - - )} + {paragraph.sumTestimonialButton?.url && ( + + {paragraph.sumTestimonialButton.title} + + )} +
-
-
+ + ) } export default SumTestimonialBannerParagraph