Skip to content

Commit

Permalink
feat(BoxWithImage): add easyLanguage variant
Browse files Browse the repository at this point in the history
  • Loading branch information
chohner committed Aug 2, 2024
1 parent 15741bc commit 2d2659e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
40 changes: 30 additions & 10 deletions app/components/BoxWithImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@ import RichText from "./RichText";

export type BoxWithImageProps = {
image: ImageProps;
variant?: "default" | "easyLanguage";
identifier?: string;
heading?: HeadingProps;
imageLabel?: string;
content?: string;
};

const variantStyles = {
default: {
textSize: "1rem",
headingSize: "1.625rem",
imageWidth: "w-[160px]",
},
easyLanguage: {
textSize: "20px",
headingSize: "30px",
imageWidth: "w-[320px]",
},
} as const;

const BoxWithImage = ({
variant = "default",
identifier,
heading,
image,
Expand All @@ -20,22 +35,27 @@ const BoxWithImage = ({
return (
<div
id={identifier}
className="flex flex-row items-start gap-32 max-[499px]:flex-col"
className="flex flex-row items-start gap-24 max-[499px]:flex-col"
>
<div className="ds-stack-16">
<div
className={`ds-stack-16 ${content ? variantStyles[variant].imageWidth : "max-w-none"}`}
>
{imageLabel && (
<p className="ds-label-section pt-4 text-gray-800">{imageLabel}</p>
)}
<Image
{...image}
{...{
className: content ? "w-[160px]" : "max-w-none",
}}
/>
<Image {...image} />
</div>
<div className={"ds-stack-8 break-words w-full"}>
{heading && <Heading {...heading} />}
{content && <RichText markdown={content} />}
{heading && (
<div style={{ fontSize: variantStyles[variant].headingSize }}>
<Heading {...heading} />
</div>
)}
{content && (
<div style={{ fontSize: variantStyles[variant].textSize }}>
<RichText markdown={content} />
</div>
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion app/services/cms/models/StrapiBoxWithImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getBoxWithImageProps = ({
}: z.infer<typeof StrapiBoxWithImageSchema>): BoxWithImageProps => {
const { content, identifier, imageLabel } = omitNull(props);
return {
image: getImageProps(image),
image: getImageProps(image) ?? {},
identifier,
heading: heading ? getHeadingProps(heading) : undefined,
imageLabel,
Expand Down

0 comments on commit 2d2659e

Please sign in to comment.