Skip to content

Commit 9af12f0

Browse files
authored
Add usage guidance for select vs combobox vs radio (#2391)
# Pull Request ## 🀨 Rationale I needed an example of component usage guidance for an NITech presentation ## πŸ‘©β€πŸ’» Implementation Capture my understanding of when to use select, combobox, and radio in each of their MDX files. I moved the combobox description from storybook to mdx because it was annoying to format large markdown strings from code. Updated language for existing usage guidance to match new pattern. - my secret motivation is working around a prettier bug that puts tags near the end of a line in a new paragraph, leading to ugly docs. I couldn't find a syntax to `prettier-ignore` in mdx files. [nor can](prettier/prettier#12209) [other people](https://stackoverflow.com/questions/69311134/prettier-how-to-ignore-a-single-line) <img width="471" alt="image" src="https://github.com/user-attachments/assets/dcfc9364-25f2-4cf1-96ee-e54b56752ad5"> ## πŸ§ͺ Testing Local storybook ## βœ… Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
1 parent c4470de commit 9af12f0

File tree

8 files changed

+30
-20
lines changed

8 files changed

+30
-20
lines changed

β€Žpackages/storybook/src/nimble/anchor-button/anchor-button.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import * as anchorButtonStories from './anchor-button.stories';
2020
An anchor button is a component with the visual appearance of a button, but it
2121
navigates like an anchor/link when pressed.
2222

23-
If you want a button that triggers an action or event, use the
24-
25-
<Tag name={buttonTag} /> instead.
23+
Consider <Tag name={buttonTag} /> if you want a button that triggers an action
24+
or event.
2625

2726
<Canvas of={anchorButtonStories.outlineAnchorButton} />
2827

β€Žpackages/storybook/src/nimble/button/button.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ Per [W3C](https://www.w3.org/WAI/ARIA/apg/patterns/button/) - A button is a
1313
widget that enables users to trigger an action or event, such as submitting a
1414
form, opening a dialog, canceling an action, or performing a delete operation.
1515

16-
If you want a button that triggers navigation to a URL, use the
17-
18-
<Tag name={anchorButtonTag} /> instead.
16+
Consider <Tag name={anchorButtonTag} /> if you want a button that triggers
17+
navigation to a URL.
1918

2019
<Canvas of={buttonStories.outlineButton} />
2120

β€Žpackages/storybook/src/nimble/card-button/card-button.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ arbitrary content that is specified by a client application. The
1414
<Tag name={cardButtonTag} /> is intended to be larger and more prominent on a
1515
page than the standard <Tag name={buttonTag} />.
1616

17-
If you want a button that triggers navigation to a URL, use the
18-
19-
<Tag name={anchorButtonTag} /> instead.
17+
Consider <Tag name={anchorButtonTag} /> if you want a button that triggers
18+
navigation to a URL.
2019

2120
Note: The styling for the "Color" theme is not complete.
2221

β€Žpackages/storybook/src/nimble/combobox/combobox.mdx

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import { Controls, Canvas, Meta, Title, Description } from '@storybook/blocks';
22
import * as comboboxStories from './combobox.stories';
33
import ComponentApisLink from '../../docs/component-apis-link.mdx';
4+
import { comboboxTag } from '../../../../nimble-components/src/combobox/';
45
import { listOptionTag } from '../../../../nimble-components/src/list-option/';
6+
import { selectTag } from '../../../../nimble-components/src/select/';
57

68
<Meta of={comboboxStories} />
79
<Title of={comboboxStories} />
8-
<Description of={comboboxStories} />
10+
11+
Per [W3C](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/), a combobox is an
12+
input widget that has an associated popup. The popup enables users to choose a
13+
value for the input from a collection. The <Tag name={comboboxTag} /> provides
14+
`autocomplete` options that can help a user find and select a particular value.
15+
16+
The user can enter arbitrary values in the input area, not just those that exist
17+
as autocomplete options. Consider using <Tag name={selectTag} /> to limit values
18+
to those in the list. .
919

1020
<Canvas of={comboboxStories.underlineCombobox} />
1121

β€Žpackages/storybook/src/nimble/combobox/combobox.stories.ts

-7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ const metadata: Meta<ComboboxArgs> = {
8989
title: 'Components/Combobox',
9090
decorators: [withActions<HtmlRenderer>],
9191
parameters: {
92-
docs: {
93-
description: {
94-
component: `Per [W3C](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/), a combobox is an input widget that has an associated popup. The popup enables users to choose a value for the input from a collection.
95-
The \`nimble-combobox\` provides 'autocomplete' options that can help a user find and select a particular value. Unlike with the \`nimble-select\` component, the \`nimble-combobox\` allows the user to enter
96-
arbitrary values in the input area, not just those that exist as autocomplete options.`
97-
}
98-
},
9992
actions: {
10093
handles: ['change', 'input']
10194
},

β€Žpackages/storybook/src/nimble/radio-group/radio-group.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Controls, Canvas, Meta, Title } from '@storybook/blocks';
22
import * as radioGroupStories from './radio-group.stories';
33
import ComponentApisLink from '../../docs/component-apis-link.mdx';
4+
import { selectTag } from '../../../../nimble-components/src/select';
45

56
<Meta of={radioGroupStories} />
67
<Title of={radioGroupStories} />
@@ -11,6 +12,9 @@ buttons can be checked at a time. Some implementations may initialize the set
1112
with all buttons in the unchecked state in order to force the user to check one
1213
of the buttons before moving past a certain point in the workflow.
1314

15+
Consider using <Tag name={selectTag} /> if there are many options to select
16+
from.
17+
1418
<Canvas of={radioGroupStories.radioGroup} />
1519

1620
## API

β€Žpackages/storybook/src/nimble/select/select.mdx

+7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ import * as selectStories from './select.stories';
44
import * as listOptionStories from '../list-option/list-option.stories';
55
import * as listOptionGroupStories from '../list-option-group/list-option-group.stories';
66
import ComponentApisLink from '../../docs/component-apis-link.mdx';
7+
import { comboboxTag } from '../../../../nimble-components/src/combobox';
78
import { listOptionTag } from '../../../../nimble-components/src/list-option';
89
import { listOptionGroupTag } from '../../../../nimble-components/src/list-option-group';
10+
import { radioTag } from '../../../../nimble-components/src/radio';
911

1012
<Meta of={selectStories} />
1113
<Title of={selectStories} />
1214

1315
Select is a control for selecting amongst a set of options. Upon clicking on the
1416
element, the other options are visible in a dropdown.
1517

18+
Consider using <Tag name={radioTag} /> to select from a small set of options.
19+
20+
Consider using <Tag name={comboboxTag} /> to allow the user to enter a custom
21+
value.
22+
1623
<Canvas of={selectStories.select} />
1724

1825
## API

β€Žpackages/storybook/src/nimble/tabs/tabs.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ content at a time. Each tab panel has an associated tab element, that when
1717
activated, displays the panel. The list of tab elements is arranged along one
1818
edge of the currently displayed panel, most commonly the top edge.
1919

20-
If you want a sequence of tabs that navigate to different URLs, use the
21-
22-
<Tag name={anchorTabsTag} /> instead.
20+
Consider <Tag name={anchorTabsTag} /> if you want a sequence of tabs that
21+
navigate to different URLs.
2322

2423
<Canvas of={tabsStories.tabs} />
2524

0 commit comments

Comments
Β (0)