diff --git a/packages/drupal/test_content/content/node/a397ca48-8fad-411e-8901-0eba2feb989c.yml b/packages/drupal/test_content/content/node/a397ca48-8fad-411e-8901-0eba2feb989c.yml index 465669703..3bb3bfca3 100644 --- a/packages/drupal/test_content/content/node/a397ca48-8fad-411e-8901-0eba2feb989c.yml +++ b/packages/drupal/test_content/content/node/a397ca48-8fad-411e-8901-0eba2feb989c.yml @@ -7,8 +7,8 @@ _meta: depends: 3a0fe860-a6d6-428a-9474-365bd57509aa: media 478c4289-961d-4ce8-85d6-578ae05f3019: media - 72187a1f-3e48-4b45-a9b7-189c6fd7ee26: media 5dfc1856-e9e4-4f02-9cd6-9d888870ce1a: media + 72187a1f-3e48-4b45-a9b7-189c6fd7ee26: media default: revision_uid: - @@ -103,7 +103,7 @@ default: - + @@ -114,7 +114,6 @@ default: - diff --git a/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.stories.tsx b/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.stories.tsx new file mode 100644 index 000000000..6b90bf401 --- /dev/null +++ b/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.stories.tsx @@ -0,0 +1,36 @@ +import { Url } from '@custom/schema'; +import Landscape from '@stories/landscape.jpg?as=metadata'; +import Portrait from '@stories/portrait.jpg?as=metadata'; +import { Meta, StoryObj } from '@storybook/react'; + +import { image } from '../../../helpers/image'; +import { BlockImageTeasers } from './BlockImageTeasers'; + +export default { + component: BlockImageTeasers, +} satisfies Meta; + +export const Default = { + args: { + teasers: [ + { + title: 'Title', + ctaText: 'Call to action', + ctaUrl: '/test' as Url, + image: { + source: image(Landscape), + alt: 'Alt text', + }, + }, + { + title: 'Title', + ctaText: 'Call to action', + ctaUrl: '/test' as Url, + image: { + source: image(Portrait), + alt: 'Alt text', + }, + }, + ], + }, +} satisfies StoryObj; diff --git a/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.tsx b/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.tsx new file mode 100644 index 000000000..0b3472b57 --- /dev/null +++ b/packages/ui/src/components/Organisms/PageContent/BlockImageTeasers.tsx @@ -0,0 +1,55 @@ +import { BlockImageTeasersFragment, Image, Link } from '@custom/schema'; +import React from 'react'; + +import { isTruthy } from '../../../utils/isTruthy'; + +export function BlockImageTeasers(props: BlockImageTeasersFragment) { + return ( + // eslint-disable-next-line tailwindcss/no-custom-classname +
+
+
+ {props.teasers.filter(isTruthy).map((teaser, index) => ( + + ))} +
+
+
+ ); +} + +// This component uses the following Flowbite component: +// https://flowbite.com/blocks/marketing/hero/#background-image-cards +export function BlockImageTeaser( + props: BlockImageTeasersFragment['teasers'][0], +) { + return ( +
+ {props.image ? ( + {props.image.alt} + ) : null} + +
+ {props.title ? ( +

+ {props.title} +

+ ) : null} + + {props.ctaUrl && props.ctaText ? ( + + {props.ctaText} + + ) : null} +
+
+ ); +} diff --git a/packages/ui/src/components/Organisms/PageDisplay.tsx b/packages/ui/src/components/Organisms/PageDisplay.tsx index 84c916a1e..9476bfc9d 100644 --- a/packages/ui/src/components/Organisms/PageDisplay.tsx +++ b/packages/ui/src/components/Organisms/PageDisplay.tsx @@ -9,6 +9,7 @@ import { BlockAccordion } from './PageContent/BlockAccordion'; import { BlockCta } from './PageContent/BlockCta'; import { BlockForm } from './PageContent/BlockForm'; import { BlockHorizontalSeparator } from './PageContent/BlockHorizontalSeparator'; +import { BlockImageTeasers } from './PageContent/BlockImageTeasers'; import { BlockImageWithText } from './PageContent/BlockImageWithText'; import { BlockMarkup } from './PageContent/BlockMarkup'; import { BlockMedia } from './PageContent/BlockMedia'; @@ -30,20 +31,7 @@ export function PageDisplay(page: PageFragment) { case 'BlockForm': return ; case 'BlockImageTeasers': - return ( - // TODO: Implement BlockImageTeasers -
- BlockImageTeasers goes here -
- ); + return ; case 'BlockCta': return ; case 'BlockImageWithText': diff --git a/packages/ui/src/components/Organisms/PageHero.tsx b/packages/ui/src/components/Organisms/PageHero.tsx index 9004af958..237765e00 100644 --- a/packages/ui/src/components/Organisms/PageHero.tsx +++ b/packages/ui/src/components/Organisms/PageHero.tsx @@ -17,7 +17,7 @@ export function PageHero(props: NonNullable) { function DefaultHero(props: NonNullable) { return ( <> -
+
{props.image ? ( {props.image.alt}['content'], }, }, diff --git a/packages/ui/src/tailwind.css b/packages/ui/src/tailwind.css index f977bbc41..18682f9a6 100644 --- a/packages/ui/src/tailwind.css +++ b/packages/ui/src/tailwind.css @@ -35,3 +35,11 @@ )::after { content: '' !important; } + +/* + Selects the .block-background-image-cards only when it is the direct + sibling of .default-hero section. + */ +.default-hero + .block-background-image-cards { + @apply mt-2 px-0; +}