From 71df54364d6f3fbec88f1fea1c3265d182929274 Mon Sep 17 00:00:00 2001 From: Ruben Smit Date: Wed, 14 Aug 2024 16:18:10 +0200 Subject: [PATCH 1/8] chore(blockquote): created storybook page --- .../storybook/src/community/blockquote.md | 3 ++ .../src/community/blockquote.stories.tsx | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 packages/storybook/src/community/blockquote.md create mode 100644 packages/storybook/src/community/blockquote.stories.tsx diff --git a/packages/storybook/src/community/blockquote.md b/packages/storybook/src/community/blockquote.md new file mode 100644 index 000000000..fc2f35513 --- /dev/null +++ b/packages/storybook/src/community/blockquote.md @@ -0,0 +1,3 @@ + + +# Rijkshuisstijl Community blockquote component diff --git a/packages/storybook/src/community/blockquote.stories.tsx b/packages/storybook/src/community/blockquote.stories.tsx new file mode 100644 index 000000000..3e80713b5 --- /dev/null +++ b/packages/storybook/src/community/blockquote.stories.tsx @@ -0,0 +1,50 @@ +/* @license CC0-1.0 */ + +import { Meta, StoryObj } from '@storybook/react'; +import { Blockquote, Paragraph } from '@utrecht/component-library-react/dist/css-module'; +import readme from './blockquote.md?raw'; + +const meta = { + title: 'React Component/Blockquote', + id: 'rijkshuisstijl-blockquote', + component: Blockquote, + argTypes: { + attribution: { + name: 'attribution', + type: { name: 'string', required: false }, + }, + }, + args: { + children: ( + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla + pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est + laborum + + ), + }, + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: readme, + }, + }, + }, +} as Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; + +export const Attribution: Story = { + name: 'Attribution', + args: { + children: 'hello, world', + attribution: The C Programming Language, + }, +}; From 4c1aec4586ae01b35047bcbfc0b0096a7c90e2aa Mon Sep 17 00:00:00 2001 From: Ruben Smit Date: Thu, 15 Aug 2024 16:29:49 +0200 Subject: [PATCH 2/8] feat(blockquote): implemented component, styling, storybook and tests --- packages/components-css/blockquote/index.scss | 14 ++ packages/components-css/index.scss | 1 + .../components-react/src/Blockquote.test.tsx | 125 ++++++++++++++++++ packages/components-react/src/Blockquote.tsx | 21 +++ .../storybook/src/community/blockquote.md | 11 ++ .../src/community/blockquote.stories.tsx | 18 +-- packages/storybook/src/markdown.d.ts | 4 + .../design-tokens/figma/figma.tokens.json | 4 + .../design-tokens/token-transformer.mjs | 1 - 9 files changed, 185 insertions(+), 14 deletions(-) create mode 100644 packages/components-css/blockquote/index.scss create mode 100644 packages/components-react/src/Blockquote.test.tsx create mode 100644 packages/components-react/src/Blockquote.tsx create mode 100644 packages/storybook/src/markdown.d.ts diff --git a/packages/components-css/blockquote/index.scss b/packages/components-css/blockquote/index.scss new file mode 100644 index 000000000..b67c15b54 --- /dev/null +++ b/packages/components-css/blockquote/index.scss @@ -0,0 +1,14 @@ +@import "../node_modules/@utrecht/components/blockquote/src/"; + +.utrecht-blockquote { + color: var(--utrecht-blockquote-content-color, inherit); + display: flex; + flex-direction: column; + font-family: var(--utrecht-blockquote-content-font-family, inherit); + font-size: var(--utrecht-blockquote-content-font-size, inherit); + gap: var(--utrecht-blockquote-row-gap); +} + +.utrecht-blockquote__attribution { + font-family: var(--utrecht-blockquote-attribution-font-family, inherit); +} diff --git a/packages/components-css/index.scss b/packages/components-css/index.scss index c8d5e94aa..01216d157 100644 --- a/packages/components-css/index.scss +++ b/packages/components-css/index.scss @@ -3,4 +3,5 @@ * Copyright (c) 2021 Community for NL Design System */ @import "accordion/index"; +@import "blockquote/index"; @import "logo/index"; diff --git a/packages/components-react/src/Blockquote.test.tsx b/packages/components-react/src/Blockquote.test.tsx new file mode 100644 index 000000000..f07b75d42 --- /dev/null +++ b/packages/components-react/src/Blockquote.test.tsx @@ -0,0 +1,125 @@ +import { render } from '@testing-library/react'; +import { createRef } from 'react'; +import { Blockquote } from './Blockquote'; +import '@testing-library/jest-dom'; + +describe('Blockquote', () => { + it('renders an HTML blockquote element', () => { + const { container } = render(
); + + const blockquote = container.querySelector('blockquote:only-child'); + + expect(blockquote).toBeInTheDocument(); + }); + + it('renders a block element', () => { + const { container } = render(
); + + const paragraph = container.querySelector(':only-child'); + + expect(paragraph).toHaveStyle({ display: 'block' }); + }); + + it('renders a design system BEM class name: utrecht-blockquote', () => { + const { container } = render(
); + + const paragraph = container.querySelector(':only-child'); + + expect(paragraph).toHaveClass('utrecht-blockquote'); + }); + + it('renders rich text content', () => { + const { container } = render( +
+ Hello, world +
, + ); + + const blockquote = container.querySelector(':only-child'); + + const richText = blockquote?.querySelector('code'); + + expect(richText).toBeInTheDocument(); + }); + + // Make sure Blockquote isn't implemented as `

` element, + // because then it would be impossible to render `

` children. + it('can render multiple paragraph of rich text content', () => { + const { container } = render( +

+

Hello...

+

...world

+
, + ); + + const blockquote = container.querySelector(':only-child'); + + const richText = blockquote?.querySelector('p + p'); + + expect(richText).toBeInTheDocument(); + }); + + it('can be hidden', () => { + const { container } = render(