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

Add figure description to sanityImages #1008

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/customerCases/customerCase/CustomerCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export default async function CustomerCase({
</div>
<div className={styles.mainImageWrapper}>
<SanitySharedImage image={customerCase.image} />
{customerCase.image.figureDescription && (
<Text type="imageLabel">
{customerCase.image.figureDescription}
</Text>
)}
</div>
<div className={styles.sectionsWrapper}>
{customerCase.sections.map((section) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
height: 36.5rem;
overflow: hidden;
padding-top: 1.5rem;
padding-bottom: 2rem;
padding-bottom: var(--padding-xl);
}

.mainImageWrapper img {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SanitySharedImage } from "src/components/image/SanityImage";
import Text from "src/components/text/Text";
import { ImageBlock } from "studioShared/lib/interfaces/imageBlock";

import styles from "./imageSection.module.css";
Expand All @@ -15,6 +16,9 @@ export default function ImageSection({ section }: ImageSectionProps) {
>
<div className={styles.imageContent}>
<SanitySharedImage image={section.image} />
{section.image.figureDescription && (
<Text type="imageLabel">{section.image.figureDescription}</Text>
)}
</div>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export type TextType =
| "bodyBig"
| "bodyXl"
| "mobileH1"
| "mobileBodyNormal";
| "mobileBodyNormal"
| "imageLabel";

const elementMap: { [key in TextType]: keyof JSX.IntrinsicElements } = {
h1: "h1",
Expand All @@ -39,6 +40,7 @@ const elementMap: { [key in TextType]: keyof JSX.IntrinsicElements } = {
bodyXl: "p",
mobileH1: "h1",
mobileBodyNormal: "p",
imageLabel: "span",
};

const classMap: { [key in TextType]?: string } = {
Expand All @@ -60,6 +62,7 @@ const classMap: { [key in TextType]?: string } = {
bodyXl: styles.bodyXl,
mobileH1: styles.mobileH1,
mobileBodyNormal: styles.mobileBodyNormal,
imageLabel: styles.imageLabel,
};

const Text = ({
Expand Down
10 changes: 10 additions & 0 deletions src/components/text/text.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.bodySmall,
.bodyNormal,
.bodyBig,
.imageLabel,
.list {
font-family: var(--font-britti-sans);
line-height: 140%;
Expand Down Expand Up @@ -182,3 +183,12 @@
line-height: 130%;
white-space: pre-line;
}

.imageLabel {
font-size: var(--Font-size-Picture-label, 1rem);
font-style: normal;
font-weight: 400;
line-height: 150%;
letter-spacing: 0.05rem;
padding: 0rem 0.5rem;
}
1 change: 1 addition & 0 deletions studio/lib/interfaces/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface IImage {
metadata?: {
lqip: string;
};
figureDescription?: string;
}

export interface ImageExtendedProps extends IImage {
Expand Down
11 changes: 10 additions & 1 deletion studio/schemas/fields/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ export const internationalizedImage = defineField({
title: "Image",
type: "image",
options: { hotspot: true },
fields: [internationalizedImageAltField],
fields: [
internationalizedImageAltField,
{
name: "figureDescription",
type: "internationalizedArrayString",
title: "Figure Description",
description:
"Provide a figure description of the image. Leave empty if figure description is not needed.",
},
],
preview: {
select: {
alt: "alt",
Expand Down
3 changes: 2 additions & 1 deletion studioShared/lib/queries/customerCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const INTERNATIONALIZED_IMAGE_FRAGMENT = groq`
"metadata": asset -> metadata {
lqip
},
"alt": ${translatedFieldFragment("alt")}
"alt": ${translatedFieldFragment("alt")},
"figureDescription": ${translatedFieldFragment("figureDescription")}
`;

const CUSTOMER_CASE_BASE_FRAGMENT = groq`
Expand Down
Loading