diff --git a/components/img/docs/technology-pdf.nl.md b/components/img/docs/technology-pdf.nl.md new file mode 100644 index 00000000000..3b519c906ee --- /dev/null +++ b/components/img/docs/technology-pdf.nl.md @@ -0,0 +1,10 @@ + + +# PDF + +Image moet opgebouwd worden met de `
` tag, met een tekst-alternatief in de `Alt` property. + +```text +
{ +} +``` diff --git a/packages/component-library-pdf/src/Image.test.tsx b/packages/component-library-pdf/src/Image.test.tsx new file mode 100644 index 00000000000..8907ed55d56 --- /dev/null +++ b/packages/component-library-pdf/src/Image.test.tsx @@ -0,0 +1,43 @@ +/* eslint-env jest */ + +import { beforeAll, describe, expect, it } from '@jest/globals'; +import { Image } from '@utrecht/component-library-react/src/index'; +import { readFile } from 'fs/promises'; +import React from 'react'; +import { renderPdf } from './lib'; + +describe('Image', () => { + let dataURL = ''; + + beforeAll(async () => { + const file = await readFile('./src/image.png'); + dataURL = `data:image/png;base64,${file.toString('base64')}`; + }); + + it('renders a
tag', async () => { + const { sha256 } = await renderPdf({ + id: 'pdf-image', + render: () => , + }); + + expect(sha256).toBe('TODO'); + }); + + it('renders a text alternative for `Colorful gradients`', async () => { + const { sha256 } = await renderPdf({ + id: 'pdf-image-alt', + render: () => Colorful gradients, + }); + + expect(sha256).toBe('TODO'); + }); + + it('renders a visible text alternative for `Text alternative`', async () => { + const { sha256 } = await renderPdf({ + id: 'pdf-image-actual-text', + render: () => Text alternative for an image that is unavailable, + }); + + expect(sha256).toBe('TODO'); + }); +}); diff --git a/packages/component-library-pdf/src/image.png b/packages/component-library-pdf/src/image.png new file mode 100644 index 00000000000..b0e0ababc87 Binary files /dev/null and b/packages/component-library-pdf/src/image.png differ diff --git a/packages/storybook-pdf/package.json b/packages/storybook-pdf/package.json index 03c37dc0dfb..d9e94d9a7f1 100644 --- a/packages/storybook-pdf/package.json +++ b/packages/storybook-pdf/package.json @@ -49,6 +49,7 @@ "@utrecht/heading-4-css": "workspace:*", "@utrecht/heading-5-css": "workspace:*", "@utrecht/heading-6-css": "workspace:*", + "@utrecht/img-css": "workspace:*", "@utrecht/link-css": "workspace:*", "@utrecht/ordered-list-css": "workspace:*", "@utrecht/page-css": "workspace:*", diff --git a/packages/storybook-pdf/src/Image.stories.tsx b/packages/storybook-pdf/src/Image.stories.tsx new file mode 100644 index 00000000000..d1a310699da --- /dev/null +++ b/packages/storybook-pdf/src/Image.stories.tsx @@ -0,0 +1,40 @@ +/* @license CC0-1.0 */ + +import { Meta, StoryObj } from '@storybook/react'; +import { Image } from '@utrecht/component-library-react/src/Image'; +import readme from '@utrecht/img-css/README.md?raw'; +import pdfDocs from '@utrecht/img-css/docs/technology-pdf.nl.md?raw'; +import { mergeMarkdown } from '@utrecht/storybook-helpers/src/markdown'; +import React from 'react'; +import { PdfPreview } from './PdfPreview'; + +const meta = { + title: 'PDF Component/Image', + id: 'pdf-image', + component: Image, + argTypes: {}, + args: {}, + parameters: { + bugs: 'https://github.com/nl-design-system/utrecht/issues?q=is%3Aissue+is%3Aopen+label%3Acomponent%2Fimage', + nldesignsystem: 'https://nldesignsystem.nl/image', + status: { + type: 'ALPHA', + }, + docs: { + description: { + component: mergeMarkdown([readme, pdfDocs]), + }, + }, + }, + render: () => , +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; + +export const ImageNotFound: Story = { + render: () => , +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b33e998542..a34ff618fc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3701,6 +3701,9 @@ importers: '@utrecht/heading-6-css': specifier: workspace:* version: link:../../components/heading-6 + '@utrecht/img-css': + specifier: workspace:* + version: link:../../components/img '@utrecht/link-css': specifier: workspace:* version: link:../../components/link