1
1
import React from 'react' ;
2
2
import type { ComponentMeta } from '@storybook/react' ;
3
- import { Icon , Text , BlockStack } from '@shopify/polaris' ;
4
- import { CirclePlusMinor } from '@shopify/polaris-icons' ;
3
+ import { Icon , Text , BlockStack , InlineStack } from '@shopify/polaris' ;
4
+ import * as polarisIcons from '@shopify/polaris-icons' ;
5
+ import iconMetadata from '@shopify/polaris-icons/metadata' ;
5
6
6
7
export default {
7
8
component : Icon ,
8
9
} as ComponentMeta < typeof Icon > ;
9
10
11
+ interface Icons {
12
+ [ key : string ] : any ;
13
+ }
14
+ const icons : Icons = polarisIcons ;
15
+
10
16
export function Default ( ) {
11
- return < Icon source = { CirclePlusMinor } /> ;
17
+ return < Icon source = { icons . CirclePlusMinor } /> ;
12
18
}
13
19
14
20
export function Colored ( ) {
@@ -17,71 +23,71 @@ export function Colored() {
17
23
< Text as = "p" variant = "bodyMd" alignment = "center" >
18
24
Base tone
19
25
</ Text >
20
- < Icon source = { CirclePlusMinor } tone = "base" />
26
+ < Icon source = { icons . CirclePlusMinor } tone = "base" />
21
27
< Text as = "p" variant = "bodyMd" alignment = "center" >
22
28
Subdued tone
23
29
</ Text >
24
- < Icon source = { CirclePlusMinor } tone = "subdued" />
30
+ < Icon source = { icons . CirclePlusMinor } tone = "subdued" />
25
31
< Text as = "p" variant = "bodyMd" alignment = "center" >
26
32
Primary tone
27
33
</ Text >
28
- < Icon source = { CirclePlusMinor } tone = "primary" />
34
+ < Icon source = { icons . CirclePlusMinor } tone = "primary" />
29
35
< Text as = "p" variant = "bodyMd" alignment = "center" >
30
36
Info tone
31
37
</ Text >
32
- < Icon source = { CirclePlusMinor } tone = "info" />
38
+ < Icon source = { icons . CirclePlusMinor } tone = "info" />
33
39
< Text as = "p" variant = "bodyMd" alignment = "center" >
34
40
Success tone
35
41
</ Text >
36
- < Icon source = { CirclePlusMinor } tone = "success" />
42
+ < Icon source = { icons . CirclePlusMinor } tone = "success" />
37
43
< Text as = "p" variant = "bodyMd" alignment = "center" >
38
44
Caution tone
39
45
</ Text >
40
- < Icon source = { CirclePlusMinor } tone = "caution" />
46
+ < Icon source = { icons . CirclePlusMinor } tone = "caution" />
41
47
< Text as = "p" variant = "bodyMd" alignment = "center" >
42
48
Warning tone
43
49
</ Text >
44
- < Icon source = { CirclePlusMinor } tone = "warning" />
50
+ < Icon source = { icons . CirclePlusMinor } tone = "warning" />
45
51
< Text as = "p" variant = "bodyMd" alignment = "center" >
46
52
Critical tone
47
53
</ Text >
48
- < Icon source = { CirclePlusMinor } tone = "critical" />
54
+ < Icon source = { icons . CirclePlusMinor } tone = "critical" />
49
55
< Text as = "p" variant = "bodyMd" alignment = "center" >
50
56
Emphasis tone
51
57
</ Text >
52
- < Icon source = { CirclePlusMinor } tone = "emphasis" />
58
+ < Icon source = { icons . CirclePlusMinor } tone = "emphasis" />
53
59
< Text as = "p" variant = "bodyMd" alignment = "center" >
54
60
Magic tone
55
61
</ Text >
56
- < Icon source = { CirclePlusMinor } tone = "magic" />
62
+ < Icon source = { icons . CirclePlusMinor } tone = "magic" />
57
63
< Text as = "p" variant = "bodyMd" alignment = "center" >
58
64
Text Primary tone
59
65
</ Text >
60
- < Icon source = { CirclePlusMinor } tone = "textPrimary" />
66
+ < Icon source = { icons . CirclePlusMinor } tone = "textPrimary" />
61
67
< Text as = "p" variant = "bodyMd" alignment = "center" >
62
68
Text Caution tone
63
69
</ Text >
64
- < Icon source = { CirclePlusMinor } tone = "textCaution" />
70
+ < Icon source = { icons . CirclePlusMinor } tone = "textCaution" />
65
71
< Text as = "p" variant = "bodyMd" alignment = "center" >
66
72
Text Warning tone
67
73
</ Text >
68
- < Icon source = { CirclePlusMinor } tone = "textWarning" />
74
+ < Icon source = { icons . CirclePlusMinor } tone = "textWarning" />
69
75
< Text as = "p" variant = "bodyMd" alignment = "center" >
70
76
Text Critical tone
71
77
</ Text >
72
- < Icon source = { CirclePlusMinor } tone = "textCritical" />
78
+ < Icon source = { icons . CirclePlusMinor } tone = "textCritical" />
73
79
< Text as = "p" variant = "bodyMd" alignment = "center" >
74
80
Text Info tone
75
81
</ Text >
76
- < Icon source = { CirclePlusMinor } tone = "textInfo" />
82
+ < Icon source = { icons . CirclePlusMinor } tone = "textInfo" />
77
83
< Text as = "p" variant = "bodyMd" alignment = "center" >
78
84
Text Success tone
79
85
</ Text >
80
- < Icon source = { CirclePlusMinor } tone = "textSuccess" />
86
+ < Icon source = { icons . CirclePlusMinor } tone = "textSuccess" />
81
87
< Text as = "p" variant = "bodyMd" alignment = "center" >
82
88
Text Magic tone
83
89
</ Text >
84
- < Icon source = { CirclePlusMinor } tone = "textMagic" />
90
+ < Icon source = { icons . CirclePlusMinor } tone = "textMagic" />
85
91
</ BlockStack >
86
92
) ;
87
93
}
@@ -115,3 +121,16 @@ export function WithCustomSVGAndColor() {
115
121
116
122
return < Icon source = { iconContent } tone = "warning" /> ;
117
123
}
124
+
125
+ export function PolarisIconsLibrary ( ) {
126
+ return (
127
+ < BlockStack gap = "100" inlineAlign = "start" >
128
+ { Object . keys ( iconMetadata ) . map ( ( icon ) => (
129
+ < InlineStack key = { icon } gap = "200" >
130
+ < Icon source = { polarisIcons [ icon ] } />
131
+ < Text as = "span" > { icon } </ Text >
132
+ </ InlineStack >
133
+ ) ) }
134
+ </ BlockStack >
135
+ ) ;
136
+ }
0 commit comments