diff --git a/components/CreateBloks.tsx b/components/CreateBloks.tsx index b0a6f5c0..5f049900 100644 --- a/components/CreateBloks.tsx +++ b/components/CreateBloks.tsx @@ -2,11 +2,14 @@ import { StoryblokServerComponent, type SbBlokData } from '@storyblok/react/rsc' type CreateBloksProps = { blokSection: SbBlokData[]; + isListItems?: boolean; [k: string]: unknown; }; -export const CreateBloks = ({ blokSection, ...props }: CreateBloksProps) => { - if (blokSection) { +export const CreateBloks = ({ blokSection, isListItems, ...props }: CreateBloksProps) => { + if (blokSection && isListItems) { + return blokSection.map((blok) =>
  • ); + } else if (blokSection) { return blokSection.map((blok) => ); } diff --git a/components/Cta/Cta.styles.ts b/components/Cta/Cta.styles.ts index 26d4dc59..90e05399 100644 --- a/components/Cta/Cta.styles.ts +++ b/components/Cta/Cta.styles.ts @@ -1,10 +1,10 @@ import { type CtaIconLeftMarginType } from './Cta.types'; export const cta = 'group/cta transition-all'; -export const buttonBase = 'block font-normal w-fit no-underline hocus:underline'; +export const buttonBase = 'block font-normal w-fit no-underline hocus:underline leading-tight'; // hocus to plum dark gradient instead of solid plum dark to avoid a flash of white background on hocus export const gradientButtonBase = 'bg-gradient-to-tr hocus:from-plum-dark hocus:to-plum-dark text-white hocus:text-white'; -export const textLinkBase = 'block font-semibold w-fit no-underline text-18 md:text-20'; +export const textLinkBase = 'block font-semibold w-fit no-underline text-18 md:text-20 leading-tight'; export const gradientTextLinkBase = 'bg-clip-text bg-gradient-to-tr text-transparent hocus:text-transparent'; // Maps to linkButtonStyle props in SbCtaLink. Only used for the Button style. @@ -107,3 +107,5 @@ export const ctaAligns = { center: 'su-text-center mx-auto', right: 'su-text-right ml-auto mr-0', }; + +export const ctaGroup = 'list-unstyled gap-x-08em gap-y-1em [&_li]:mb-0 [&_a]:text-09em [&_a]:md:text-20 [&_a]:p-07em [&_a]:md:pt-11 [&_a]:md:pb-12 [&_a]:md:px-30'; diff --git a/components/Cta/Cta.types.ts b/components/Cta/Cta.types.ts index 5fb6a97d..9a224271 100644 --- a/components/Cta/Cta.types.ts +++ b/components/Cta/Cta.types.ts @@ -29,3 +29,5 @@ export interface CtaCommonProps { mb?: MarginType; children?: React.ReactNode; } + +export type CtaGroupDisplayType = 'inline' | 'inline-block'; diff --git a/components/Cta/CtaGroup.tsx b/components/Cta/CtaGroup.tsx new file mode 100644 index 00000000..44bbc468 --- /dev/null +++ b/components/Cta/CtaGroup.tsx @@ -0,0 +1,28 @@ +import { cnb } from 'cnbuilder'; +import { FlexBox } from '@/components/FlexBox'; +import * as styles from './Cta.styles'; +import * as types from './Cta.types'; + +type CtaGroupProps = React.HTMLAttributes & { + display: types.CtaGroupDisplayType; +}; + +export const CtaGroup = ({ + display = 'inline-block', + className, + children, + ...props +}: CtaGroupProps) => { + return ( + + {children} + + ); +}; diff --git a/components/Cta/index.ts b/components/Cta/index.ts index 070a7a41..a2295461 100644 --- a/components/Cta/index.ts +++ b/components/Cta/index.ts @@ -2,5 +2,6 @@ export * from './CtaButton'; export * from './CtaExternalLink'; export * from './CtaNextLink'; export * from './CtaLink'; +export * from './CtaGroup'; export * from './Cta.styles'; export * from './Cta.types'; diff --git a/components/Storyblok/SbCtaGroup.tsx b/components/Storyblok/SbCtaGroup.tsx new file mode 100644 index 00000000..e086cb3f --- /dev/null +++ b/components/Storyblok/SbCtaGroup.tsx @@ -0,0 +1,24 @@ +import { storyblokEditable, type SbBlokData } from '@storyblok/react/rsc'; +import { CreateBloks } from '@/components/CreateBloks'; +import { CtaGroup, type CtaGroupDisplayType } from '@/components/Cta'; +import { getNumBloks } from '@/utilities/getNumBloks'; + +type SbCtaGroupProps = { + blok: SbBlokData & { + ctaLinks?: SbBlokData[]; + display?: CtaGroupDisplayType; + }; +}; + +export const SbCtaGroup = (props: SbCtaGroupProps) => { + const { ctaLinks, display } = props.blok; + if (!getNumBloks(ctaLinks)) { + return null; // Return null if there are no ctaLinks to display + } + + return ( + + + + ); +}; diff --git a/components/Storyblok/SbCtaLink.tsx b/components/Storyblok/SbCtaLink.tsx index 29f5d5c1..2bd1a5b6 100644 --- a/components/Storyblok/SbCtaLink.tsx +++ b/components/Storyblok/SbCtaLink.tsx @@ -39,7 +39,7 @@ export const SbCtaLink = React.forwardRef((props, linkTextColor, } = props.blok; - if (!props.blok.linkText) { + if (!linkText) { return null; } diff --git a/utilities/getNumBloks.ts b/utilities/getNumBloks.ts new file mode 100644 index 00000000..f1b19f23 --- /dev/null +++ b/utilities/getNumBloks.ts @@ -0,0 +1,15 @@ +import { type SbBlokData } from '@storyblok/react/rsc'; +/** + * Returns the number of nested bloks when we use the CreateBloks utility. + * + * @param sbField - The Storyblok field to count bloks in. + * @returns The number of bloks added to this Storyblok field. + */ + +export const getNumBloks = (sbField: SbBlokData[]) => { + if (sbField?.length) { + return sbField.length; + } + + return 0; +}; diff --git a/utilities/storyblok.tsx b/utilities/storyblok.tsx index f0ef31d2..e4c94ccf 100644 --- a/utilities/storyblok.tsx +++ b/utilities/storyblok.tsx @@ -21,13 +21,14 @@ import { SbStoryImage } from '@/components/Storyblok/SbStoryImage'; import { SbSection } from '@/components/Storyblok/SbSection'; import { SbRowOneColumn } from '@/components/Storyblok/SbRowOneColumn'; import { SbBasicCard } from '@/components/Storyblok/SbBasicCard'; +import { SbCtaGroup } from '@/components/Storyblok/SbCtaGroup'; export const components = { - // TODO DS-1417: Remove and clean up page page: SbPage, redirect: Redirect, storyPicker: SbStoryPicker, ctaLink: SbCtaLink, + ctaGroup: SbCtaGroup, navItem: SbNavItem, lockup: SbLockup, // Cards