You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds two new props to the Icon component: `muted`, which will
render the icon slightly opaque, and `size` which will scale the icon
to the requested icon size token.
Copy file name to clipboardExpand all lines: src/components/icon/icon.stories.mdx
+66-6Lines changed: 66 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,15 @@ const iconStory = (args) => {
20
20
}
21
21
returntemplate(args);
22
22
};
23
+
const defaultArgs = {
24
+
name: { type: 'string' },
25
+
fallback: { type: 'string' },
26
+
inline: { type: 'boolean' },
27
+
class: { type: 'string' },
28
+
title: { type: 'string' },
29
+
muted: { type: 'boolean' },
30
+
size: { type: 'string' },
31
+
};
23
32
24
33
<Metatitle="Components/Icon" />
25
34
@@ -36,13 +45,62 @@ For a list of available icons, visit [the Icons page](/docs/design-icons--page).
36
45
name: 'heart',
37
46
inline: false,
38
47
}}
39
-
argTypes={{
40
-
name: { type: { name: 'string' } },
41
-
fallback: { type: { name: 'string' } },
42
-
inline: { type: { name: 'boolean' } },
43
-
class: { type: { name: 'string' } },
44
-
title: { type: { name: 'string' } },
48
+
argTypes={defaultArgs}
49
+
>
50
+
{(args) =>iconStory(args)}
51
+
</Story>
52
+
</Canvas>
53
+
54
+
## Muted
55
+
56
+
By setting the `muted` property to `true`, the icon will become slightly opaque.
57
+
58
+
<Canvas>
59
+
<Story
60
+
name="Muted"
61
+
args={{
62
+
name: 'heart',
63
+
inline: false,
64
+
muted: true,
65
+
}}
66
+
argTypes={defaultArgs}
67
+
>
68
+
{(args) =>iconStory(args)}
69
+
</Story>
70
+
</Canvas>
71
+
72
+
## Sizes
73
+
74
+
By setting the `size` property to the [name of a `size.$icon` token](/docs/design-tokens-size--page), such as `large`, the icon will be scaled to the appropriate size.
75
+
76
+
<Canvas>
77
+
<Story
78
+
name="Medium Size"
79
+
args={{
80
+
name: 'heart',
81
+
size: 'medium',
82
+
}}
83
+
argTypes={defaultArgs}
84
+
>
85
+
{(args) =>iconStory(args)}
86
+
</Story>
87
+
<Story
88
+
name="Large Size"
89
+
args={{
90
+
name: 'heart',
91
+
size: 'large',
92
+
}}
93
+
argTypes={defaultArgs}
94
+
>
95
+
{(args) =>iconStory(args)}
96
+
</Story>
97
+
<Story
98
+
name="X-Large Size"
99
+
args={{
100
+
name: 'heart',
101
+
size: 'x-large',
45
102
}}
103
+
argTypes={defaultArgs}
46
104
>
47
105
{(args) =>iconStory(args)}
48
106
</Story>
@@ -87,6 +145,8 @@ The component template supports the following unique properties:
87
145
-`inline`: When `true`, the inline modifier will be applied.
88
146
-`name`: The name of the intended icon [in our library](/docs/design-icons--page).
89
147
-`title`: If provided, a `title` element will be prepended to the icon source with the contents of this property. This will also set the `role` to `img` unless it is already specified. ([More info](https://css-tricks.com/accessible-svgs/#aa-example-1-standalone-icon-meaningful))
148
+
-`muted`: When `true`, the icon will be displayed in a muted color.
149
+
-`size`: The size to display the icon, taken from the `size.$icon` tokens.
90
150
91
151
Additional SVG properties will be passed to the Twig template for the asset itself:
0 commit comments