Skip to content

Commit

Permalink
Document button order guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed Apr 28, 2024
1 parent cc1d1fa commit 9c56b93
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/css/src/components/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ A Dialog allows the user to focus on one task or a piece of information by poppi
- Use a dialog for short and non-frequent tasks.
Consider using the main flow for regular tasks.

## The order of buttons

If your Dialog needs more than one button, put the one for the primary action first and other buttons behind it.
Sighted users will read the primary action first, in line with the natural reading order.
The same goes for users of screen readers, who will hear the primary action first, and users of a keyboard, who will focus the primary action first.
Additionally, this approach keeps the order of buttons consistent on both narrow and wide screens: if the buttons don’t fit next to each other, they get stacked vertically, where having the primary action on top makes the most sense.

## Keyboard Support

| key | function |
Expand Down
7 changes: 7 additions & 0 deletions storybook/src/components/Dialog/Dialog.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ Content taller than the dialog itself will scroll.
Click or tap the button to open a dialog.

<Canvas of={DialogStories.TriggerButton} />

## Vertically Stacked Buttons

If the buttons don’t fit next to each other, they will stack vertically and stretch to the full width.
View this example in a narrow window, enlarge your browser’s text size, or [use the ‘Phone’ size of the preview](?path=/story/components-containers-dialog--vertical-buttons&globals=viewport:phone).

<Canvas of={DialogStories.VerticalButtons} />
28 changes: 28 additions & 0 deletions storybook/src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,31 @@ export const TriggerButton: Story = {
),
],
}

export const VerticalButtons: Story = {
args: {
actions: (
<>
<Button type="submit">Ja, ik wil doorgaan</Button>
<Button onClick={closeDialog} variant="tertiary">
Nee, toch maar terug
</Button>
</>
),
open: true,
},
decorators: [
(Story) => (
<div style={{ backgroundColor: '#0006', position: 'absolute', width: '100%', height: '100%' }}>
<Story />
</div>
),
],
parameters: {
layout: 'fullscreen',
docs: {
story: { height: '32em' },
},
viewport: { defaultViewport: 'phone' },
},
}

0 comments on commit 9c56b93

Please sign in to comment.