-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add blockquote component (#218)
- Loading branch information
Showing
12 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
apps/docs/content/3-components/2-library/20-blockquote.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: Blockquote | ||
description: Blockquote HTML Component | ||
draft: false | ||
status: alpha | ||
--- | ||
|
||
# Blockquote | ||
|
||
<ComponentStatusBlock componentId="blockquote" /> | ||
|
||
## When to use this component | ||
|
||
Use the inset text component to differentiate a block of text from the content that surrounds it, for example: | ||
|
||
- quotes | ||
- examples | ||
- additional information about the page | ||
|
||
## When not to use this component | ||
|
||
Some users do not notice inset text if it’s used on complex pages or near to other visually prominent elements. | ||
For this reason, avoid using inset text as a way of highlighting very important information that users need to see. | ||
|
||
If you need to draw attention to very important content, like legal information, use the warning text component instead. |
14 changes: 0 additions & 14 deletions
14
apps/docs/content/3-components/2-library/20-inset-text.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,6 @@ centered | |
data-testid | ||
flexbox-based | ||
checkboxes | ||
dropdown | ||
dropdown | ||
Blockquote | ||
blockquote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% macro govieBlockquote(props) %} | ||
|
||
<blockquote | ||
class="gi-my-6 gi-p-4 gi-border-l-2xl gi-border-gray-400 gi-text-sm md:gi-text-md" | ||
> | ||
{{ props.content | safe | trim }} | ||
</blockquote> | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as zod from 'zod'; | ||
|
||
export const blockquoteSchema = zod.object({ | ||
content: zod.string({ | ||
description: 'Content for blockquote.', | ||
required_error: 'Content is required', | ||
}), | ||
}); | ||
|
||
export type BlockquoteProps = zod.infer<typeof blockquoteSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { renderComponent } from '../storybook/storybook'; | ||
import html from './blockquote.html?raw'; | ||
import { BlockquoteProps } from './blockquote.schema'; | ||
|
||
const macro = { name: 'govieBlockquote', html }; | ||
|
||
const Blockquote = renderComponent<BlockquoteProps>(macro); | ||
|
||
const meta = { | ||
component: Blockquote, | ||
title: 'Typography/Blockquote', | ||
parameters: { | ||
macro, | ||
}, | ||
} satisfies Meta<typeof Blockquote>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
argTypes: { | ||
content: { | ||
control: 'text', | ||
type: { name: 'string', required: true }, | ||
description: 'The text content of the blockquote.', | ||
}, | ||
}, | ||
args: { | ||
content: | ||
'It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { render } from '../common/render'; | ||
import html from './blockquote.html?raw'; | ||
import { BlockquoteProps } from './blockquote.schema'; | ||
|
||
describe('govieBlockquote', () => { | ||
const renderBlockquote = render<BlockquoteProps>({ | ||
componentName: 'blockquote', | ||
macroName: 'govieBlockquote', | ||
html, | ||
}); | ||
|
||
it('should render a blockquote with the correct content', () => { | ||
const screen = renderBlockquote({ | ||
content: 'This is a blockquote', | ||
}); | ||
const pElement = screen.getByText('This is a blockquote'); | ||
expect(pElement).toBeTruthy(); | ||
expect(pElement.tagName.toLowerCase()).toBe('blockquote'); | ||
}); | ||
|
||
it('should pass axe accessibility tests', async () => { | ||
const screen = renderBlockquote({ | ||
content: 'Accessible blockquote', | ||
}); | ||
|
||
await screen.axe(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Blockquote } from './blockquote.js'; | ||
|
||
const meta = { | ||
title: 'typography/Blockquote', | ||
component: Blockquote, | ||
} satisfies Meta<typeof Blockquote>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: | ||
'It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function Blockquote({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<blockquote | ||
className={`gi-my-6 gi-p-4 gi-border-l-2xl gi-border-gray-400 gi-text-sm md:gi-text-md`} | ||
> | ||
{children} | ||
</blockquote> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters