Skip to content

Commit 4510997

Browse files
committed
docs(button): custom mdx docs page
Create an MDX "Docs" page that works as a replacement for the YML docs pages, and covers the important Button options from there and the guidelines. Adds the tag "is-hidden-story" for excluding Storybook sidebar items.
1 parent 44f4020 commit 4510997

File tree

4 files changed

+419
-156
lines changed

4 files changed

+419
-156
lines changed

.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const componentPkgs = readdirSync(componentsPath, {
1010

1111
module.exports = {
1212
stories: [
13+
"../components/*/stories/*.mdx",
1314
"../components/*/stories/*.stories.js",
1415
"./guides/*.mdx",
1516
"./foundations/*/*.mdx",

.storybook/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ addons.setConfig({
5050
sidebar: {
5151
showRoots: false,
5252
filters: {
53-
patterns: (item) => !(item.id.includes('forced-colors') || item.tags.includes('foundation')),
53+
patterns: (item) => !item.id.includes('forced-colors') && ['foundation','is-hidden-story'].every((tag) => !item.tags.includes(tag)),
5454
}
5555
},
5656
});

components/button/stories/button.mdx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { Canvas, Meta, Subtitle } from '@storybook/blocks';
2+
3+
import * as ButtonStories from './button.stories';
4+
5+
<Meta of={ButtonStories} title="Docs" />
6+
7+
# Button
8+
9+
<Subtitle>Buttons allow users to perform an action or to navigate to another page. They have
10+
multiple styles for various needs, and are ideal for calling attention to where a user needs to
11+
do something in order to move forward in a flow.</Subtitle>
12+
13+
## Variants
14+
15+
There are four available variants that are used for different levels of emphasis and different
16+
types of actions. By default, a button uses the fill style with a solid background. The primary
17+
and secondary variants also have an outline option.
18+
19+
### Accent
20+
21+
The call to action button communicates strong emphasis and is reserved for encouraging critical
22+
actions. In general, only use the emphasized option for the most important action on the page.
23+
24+
<Canvas of={ButtonStories.Accent} />
25+
26+
### Primary
27+
28+
The primary button is for medium emphasis. Use it in place of a call to action button when the
29+
action requires less prominence, or if there are multiple primary actions of the same importance
30+
in the same view. Both the fill (default) and outline styles are demonstrated below:
31+
32+
<Canvas of={ButtonStories.Primary} />
33+
34+
### Secondary
35+
36+
The secondary button is for low emphasis. It’s paired with other button types to surface less
37+
prominent actions, and should never be the only button in a group. Both the fill (default) and
38+
outline styles are demonstrated below:
39+
40+
<Canvas of={ButtonStories.Secondary} />
41+
42+
### Negative
43+
44+
The negative button is for emphasizing actions that can be destructive or have negative
45+
consequences if taken. Use it sparingly.
46+
47+
<Canvas of={ButtonStories.Negative} />
48+
49+
## Static color
50+
51+
When a button needs to be placed on top of a color background or a visual, use the static color
52+
option. Static color buttons do not change shades or values depending upon the color theme.
53+
54+
### Static white - primary
55+
56+
<Canvas of={ButtonStories.StaticWhitePrimary} />
57+
58+
### Static white - secondary
59+
60+
<Canvas of={ButtonStories.StaticWhiteSecondary} />
61+
62+
### Static black - primary
63+
64+
<Canvas of={ButtonStories.StaticBlackPrimary} />
65+
66+
### Static black - secondary
67+
68+
<Canvas of={ButtonStories.StaticBlackSecondary} />
69+
70+
## Sizing
71+
72+
Buttons come in four different sizes: small, medium, large, and extra large. The medium size is
73+
the default and most frequently used option. Use the other sizes sparingly; they should be used
74+
to create a hierarchy of importance within the page.
75+
76+
<Canvas of={ButtonStories.Sizing} />
77+
78+
## Pending state
79+
80+
The pending button is for indicating that a quick progress action is taking place. In this case, the
81+
label and optional icon disappear and a progress circle appears. The progress circle always shows an
82+
indeterminate progress. We recommend the use of the `.is-pending` class on the component’s parent
83+
container, but there is also an option to use an attribute of `pending` instead. Buttons should have
84+
the disabled attribute when the pending state is applied.
85+
86+
<Canvas of={ButtonStories.Pending} />
87+
88+
## Disabled state
89+
90+
A button in a disabled state shows that an action exists, but is not available in that circumstance.
91+
This state can be used to maintain layout continuity and to communicate that an action may become
92+
available later.
93+
94+
<Canvas of={ButtonStories.Disabled} />
95+
96+
## Text overflow behavior
97+
98+
When the button text is too long for the horizontal space available, it wraps to form another line.
99+
When there is no icon present, the text is aligned center. When there is an icon present, the text is
100+
aligned `start` (left with a writing direction of left-to-right) and the icon remains vertically aligned
101+
at the top.
102+
103+
<Canvas of={ButtonStories.WithWrapping} />

0 commit comments

Comments
 (0)