@automattic/jetpack-components 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/.gitattributes +8 -0
  2. package/CHANGELOG.md +747 -0
  3. package/LICENSE.txt +357 -0
  4. package/README.md +11 -0
  5. package/SECURITY.md +38 -0
  6. package/components/action-button/index.jsx +70 -0
  7. package/components/action-button/stories/index.stories.jsx +38 -0
  8. package/components/action-button/style.module.scss +11 -0
  9. package/components/action-button/test/component.jsx +16 -0
  10. package/components/action-popover/index.tsx +105 -0
  11. package/components/action-popover/stories/index.stories.jsx +115 -0
  12. package/components/action-popover/stories/styles.module.scss +7 -0
  13. package/components/action-popover/styles.module.scss +49 -0
  14. package/components/action-popover/types.ts +20 -0
  15. package/components/admin-page/index.tsx +58 -0
  16. package/components/admin-page/stories/index.stories.tsx +35 -0
  17. package/components/admin-page/stories/style.module.scss +13 -0
  18. package/components/admin-page/style.module.scss +11 -0
  19. package/components/admin-page/types.ts +41 -0
  20. package/components/admin-section/basic/index.tsx +15 -0
  21. package/components/admin-section/basic/style.module.scss +3 -0
  22. package/components/admin-section/hero/index.tsx +15 -0
  23. package/components/admin-section/hero/style.module.scss +3 -0
  24. package/components/admin-section/stories/index.stories.tsx +60 -0
  25. package/components/admin-section/types.ts +6 -0
  26. package/components/alert/index.tsx +61 -0
  27. package/components/alert/stories/index.stories.jsx +24 -0
  28. package/components/alert/style.module.scss +43 -0
  29. package/components/automattic-byline-logo/README.md +16 -0
  30. package/components/automattic-byline-logo/index.tsx +38 -0
  31. package/components/automattic-byline-logo/stories/index.stories.tsx +20 -0
  32. package/components/automattic-byline-logo/test/component.tsx +28 -0
  33. package/components/automattic-byline-logo/types.ts +18 -0
  34. package/components/boost-score-bar/index.tsx +103 -0
  35. package/components/boost-score-bar/stories/index.stories.tsx +39 -0
  36. package/components/boost-score-bar/style.scss +184 -0
  37. package/components/boost-score-bar/test/component.tsx +102 -0
  38. package/components/boost-score-bar/types.ts +9 -0
  39. package/components/button/index.tsx +84 -0
  40. package/components/button/stories/index.mdx +90 -0
  41. package/components/button/stories/index.stories.tsx +400 -0
  42. package/components/button/stories/style.module.scss +20 -0
  43. package/components/button/style.module.scss +212 -0
  44. package/components/button/types.ts +21 -0
  45. package/components/contextual-upgrade-trigger/README.md +81 -0
  46. package/components/contextual-upgrade-trigger/index.tsx +44 -0
  47. package/components/contextual-upgrade-trigger/stories/index.stories.tsx +25 -0
  48. package/components/contextual-upgrade-trigger/style.module.scss +75 -0
  49. package/components/contextual-upgrade-trigger/types.ts +9 -0
  50. package/components/decorative-card/index.tsx +44 -0
  51. package/components/decorative-card/stories/index.stories.tsx +18 -0
  52. package/components/decorative-card/style.scss +116 -0
  53. package/components/decorative-card/types.ts +16 -0
  54. package/components/dialog/index.tsx +69 -0
  55. package/components/dialog/stories/boost.png +0 -0
  56. package/components/dialog/stories/declaration.d.ts +1 -0
  57. package/components/dialog/stories/index.stories.tsx +118 -0
  58. package/components/dialog/stories/js-components.components.dialog.mdx +62 -0
  59. package/components/dialog/stories/js-components.components.dialog.stories.js +37 -0
  60. package/components/dialog/stories/style.module.scss +21 -0
  61. package/components/dialog/style.module.scss +30 -0
  62. package/components/donut-meter/index.tsx +147 -0
  63. package/components/donut-meter/stories/index.stories.tsx +51 -0
  64. package/components/donut-meter/style.scss +11 -0
  65. package/components/donut-meter/test/component.tsx +24 -0
  66. package/components/gridicon/index.tsx +298 -0
  67. package/components/gridicon/stories/index.stories.tsx +18 -0
  68. package/components/gridicon/style.scss +16 -0
  69. package/components/gridicon/types.ts +48 -0
  70. package/components/icon-tooltip/index.tsx +96 -0
  71. package/components/icon-tooltip/stories/index.stories.tsx +108 -0
  72. package/components/icon-tooltip/stories/style.scss +36 -0
  73. package/components/icon-tooltip/style.scss +121 -0
  74. package/components/icon-tooltip/test/component.tsx +15 -0
  75. package/components/icon-tooltip/types.ts +76 -0
  76. package/components/icons/README.md +98 -0
  77. package/components/icons/index.tsx +369 -0
  78. package/components/icons/stories/index.stories.tsx +65 -0
  79. package/components/icons/stories/style.module.scss +33 -0
  80. package/components/icons/style.module.scss +40 -0
  81. package/components/icons/types.ts +38 -0
  82. package/components/indeterminate-progress-bar/index.tsx +28 -0
  83. package/components/indeterminate-progress-bar/stories/index.stories.tsx +14 -0
  84. package/components/indeterminate-progress-bar/style.module.scss +34 -0
  85. package/components/indeterminate-progress-bar/types.ts +6 -0
  86. package/components/jetpack-footer/README.md +21 -0
  87. package/components/jetpack-footer/index.tsx +94 -0
  88. package/components/jetpack-footer/stories/index.stories.tsx +40 -0
  89. package/components/jetpack-footer/style.scss +116 -0
  90. package/components/jetpack-footer/test/component.tsx +45 -0
  91. package/components/jetpack-footer/types.ts +36 -0
  92. package/components/jetpack-logo/README.md +20 -0
  93. package/components/jetpack-logo/index.tsx +46 -0
  94. package/components/jetpack-logo/stories/index.stories.tsx +20 -0
  95. package/components/jetpack-logo/test/component.tsx +16 -0
  96. package/components/jetpack-logo/types.ts +7 -0
  97. package/components/jetpack-search-logo/README.md +20 -0
  98. package/components/jetpack-search-logo/index.tsx +93 -0
  99. package/components/jetpack-search-logo/stories/index.stories.tsx +21 -0
  100. package/components/jetpack-search-logo/test/component.tsx +16 -0
  101. package/components/jetpack-search-logo/types.ts +7 -0
  102. package/components/jetpack-vaultpress-backup-logo/README.md +19 -0
  103. package/components/jetpack-vaultpress-backup-logo/index.tsx +113 -0
  104. package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +20 -0
  105. package/components/jetpack-vaultpress-backup-logo/test/component.tsx +18 -0
  106. package/components/jetpack-vaultpress-backup-logo/types.ts +6 -0
  107. package/components/jetpack-videopress-logo/README.md +19 -0
  108. package/components/jetpack-videopress-logo/index.tsx +93 -0
  109. package/components/jetpack-videopress-logo/stories/index.stories.tsx +20 -0
  110. package/components/jetpack-videopress-logo/test/component.tsx +16 -0
  111. package/components/jetpack-videopress-logo/types.tsx +6 -0
  112. package/components/layout/README.md +9 -0
  113. package/components/layout/breakpoints.module.scss +20 -0
  114. package/components/layout/col/README.md +81 -0
  115. package/components/layout/col/index.tsx +49 -0
  116. package/components/layout/col/style.module.scss +28 -0
  117. package/components/layout/container/README.md +77 -0
  118. package/components/layout/container/index.tsx +42 -0
  119. package/components/layout/container/style.module.scss +35 -0
  120. package/components/layout/stories/index.stories.tsx +145 -0
  121. package/components/layout/stories/styles.module.scss +22 -0
  122. package/components/layout/types.ts +55 -0
  123. package/components/layout/use-breakpoint-match/README.md +43 -0
  124. package/components/layout/use-breakpoint-match/declaration.d.ts +9 -0
  125. package/components/layout/use-breakpoint-match/index.ts +79 -0
  126. package/components/loading-placeholder/README.md +22 -0
  127. package/components/loading-placeholder/index.tsx +23 -0
  128. package/components/loading-placeholder/stories/index.stories.tsx +78 -0
  129. package/components/loading-placeholder/style.module.scss +18 -0
  130. package/components/notice/index.tsx +98 -0
  131. package/components/notice/stories/index.stories.jsx +90 -0
  132. package/components/notice/style.module.scss +107 -0
  133. package/components/number-format/README.md +25 -0
  134. package/components/number-format/index.ts +16 -0
  135. package/components/pricing-card/index.tsx +127 -0
  136. package/components/pricing-card/stories/index.stories.tsx +55 -0
  137. package/components/pricing-card/style.scss +112 -0
  138. package/components/pricing-card/test/component.tsx +89 -0
  139. package/components/pricing-card/types.ts +52 -0
  140. package/components/pricing-slider/index.tsx +53 -0
  141. package/components/pricing-slider/stories/index.stories.tsx +44 -0
  142. package/components/pricing-slider/style.scss +55 -0
  143. package/components/pricing-slider/test/component.tsx +14 -0
  144. package/components/pricing-slider/types.ts +58 -0
  145. package/components/pricing-table/index.tsx +200 -0
  146. package/components/pricing-table/stories/index.stories.tsx +74 -0
  147. package/components/pricing-table/styles.module.scss +160 -0
  148. package/components/pricing-table/test/component.tsx +41 -0
  149. package/components/pricing-table/types.ts +84 -0
  150. package/components/product-offer/icons-card.tsx +47 -0
  151. package/components/product-offer/index.tsx +115 -0
  152. package/components/product-offer/product-offer-header.tsx +23 -0
  153. package/components/product-offer/stories/index.stories.tsx +104 -0
  154. package/components/product-offer/style.module.scss +93 -0
  155. package/components/product-offer/types.ts +125 -0
  156. package/components/product-price/index.tsx +90 -0
  157. package/components/product-price/price.tsx +35 -0
  158. package/components/product-price/stories/index.stories.tsx +33 -0
  159. package/components/product-price/style.module.scss +69 -0
  160. package/components/product-price/test/component.tsx +26 -0
  161. package/components/product-price/types.ts +73 -0
  162. package/components/qr-code/Readme.md +5 -0
  163. package/components/qr-code/index.tsx +78 -0
  164. package/components/qr-code/stories/index.stories.tsx +32 -0
  165. package/components/record-meter-bar/index.tsx +135 -0
  166. package/components/record-meter-bar/stories/index.stories.tsx +39 -0
  167. package/components/record-meter-bar/style.scss +38 -0
  168. package/components/record-meter-bar/test/component.tsx +52 -0
  169. package/components/spinner/README.md +28 -0
  170. package/components/spinner/index.jsx +45 -0
  171. package/components/spinner/stories/index.stories.jsx +20 -0
  172. package/components/spinner/style.scss +31 -0
  173. package/components/spinner/test/component.jsx +17 -0
  174. package/components/split-button/index.tsx +39 -0
  175. package/components/split-button/stories/index.stories.tsx +35 -0
  176. package/components/split-button/style.module.scss +21 -0
  177. package/components/split-button/types.ts +14 -0
  178. package/components/stat-card/index.tsx +49 -0
  179. package/components/stat-card/stories/index.mdx +35 -0
  180. package/components/stat-card/stories/index.stories.tsx +41 -0
  181. package/components/stat-card/style.module.scss +49 -0
  182. package/components/stat-card/test/component.tsx +24 -0
  183. package/components/stat-card/types.ts +28 -0
  184. package/components/status/README.md +42 -0
  185. package/components/status/index.tsx +40 -0
  186. package/components/status/stories/index.stories.tsx +44 -0
  187. package/components/status/style.module.scss +72 -0
  188. package/components/terms-of-service/index.tsx +63 -0
  189. package/components/terms-of-service/styles.scss +10 -0
  190. package/components/terms-of-service/test/index.test.jsx +52 -0
  191. package/components/terms-of-service/types.ts +30 -0
  192. package/components/testimonials/index.tsx +58 -0
  193. package/components/testimonials/style.scss +127 -0
  194. package/components/testimonials/test/component.tsx +103 -0
  195. package/components/testimonials/testimonial.tsx +47 -0
  196. package/components/testimonials/types.ts +17 -0
  197. package/components/text/constants.ts +30 -0
  198. package/components/text/index.tsx +91 -0
  199. package/components/text/stories/headings.index.stories.tsx +80 -0
  200. package/components/text/stories/index.mdx +195 -0
  201. package/components/text/stories/index.stories.tsx +69 -0
  202. package/components/text/stories/style.module.scss +64 -0
  203. package/components/text/stories/title.index.stories.tsx +34 -0
  204. package/components/text/style.module.scss +125 -0
  205. package/components/text/types.ts +53 -0
  206. package/components/theme-provider/Readme.md +49 -0
  207. package/components/theme-provider/globals.module.scss +6 -0
  208. package/components/theme-provider/index.tsx +151 -0
  209. package/components/theme-provider/stories/index.stories.tsx +164 -0
  210. package/components/theme-provider/stories/style.module.scss +79 -0
  211. package/components/theme-provider/types.ts +25 -0
  212. package/components/toggle-control/README.md +5 -0
  213. package/components/toggle-control/index.tsx +67 -0
  214. package/components/toggle-control/stories/index.stories.tsx +83 -0
  215. package/components/toggle-control/styles.module.scss +41 -0
  216. package/components/zendesk-chat/README.md +26 -0
  217. package/components/zendesk-chat/constants.ts +2 -0
  218. package/components/zendesk-chat/index.tsx +22 -0
  219. package/components/zendesk-chat/stories/index.stories.tsx +15 -0
  220. package/components/zendesk-chat/test/component.tsx +16 -0
  221. package/components/zendesk-chat/types.ts +3 -0
  222. package/index.ts +69 -0
  223. package/lib/locale/index.ts +48 -0
  224. package/lib/locale/test/index.ts +21 -0
  225. package/package.json +80 -0
  226. package/tools/get-product-checkout-url/Readme.md +32 -0
  227. package/tools/get-product-checkout-url/index.ts +31 -0
  228. package/tools/jp-redirect/README.md +61 -0
  229. package/tools/jp-redirect/index.ts +62 -0
  230. package/tools/jp-redirect/test/index.tsx +89 -0
  231. package/tools/jp-redirect/types.ts +49 -0
  232. package/tools/pricing-utils/README.md +16 -0
  233. package/tools/pricing-utils/index.ts +11 -0
  234. package/tools/pricing-utils/test/index.ts +39 -0
  235. package/tools/pricing-utils/types.ts +12 -0
@@ -0,0 +1,400 @@
1
+ import * as allIcons from '@wordpress/icons';
2
+ import Col from '../../layout/col';
3
+ import Container from '../../layout/container';
4
+ import Text, { H3 } from '../../text';
5
+ import Button from '../index';
6
+ import styles from './style.module.scss';
7
+
8
+ const { Icon: WPIcon, ...icons } = allIcons;
9
+ const { check, cloud } = icons;
10
+
11
+ const disableVariant = {
12
+ variant: {
13
+ table: {
14
+ disable: true,
15
+ },
16
+ },
17
+ };
18
+
19
+ const disableDisabled = {
20
+ disabled: {
21
+ table: {
22
+ disable: true,
23
+ },
24
+ },
25
+ };
26
+
27
+ const disableIsDestructive = {
28
+ isDestructive: {
29
+ table: {
30
+ disable: true,
31
+ },
32
+ },
33
+ };
34
+
35
+ const disableIsLoading = {
36
+ isLoading: {
37
+ table: {
38
+ disable: true,
39
+ },
40
+ },
41
+ };
42
+
43
+ const disableIcon = {
44
+ icon: {
45
+ table: {
46
+ disable: true,
47
+ },
48
+ },
49
+ };
50
+
51
+ const disableClassName = {
52
+ className: {
53
+ table: {
54
+ disable: true,
55
+ },
56
+ },
57
+ };
58
+
59
+ const disableFullWidth = {
60
+ fullWidth: {
61
+ table: {
62
+ disable: true,
63
+ },
64
+ },
65
+ };
66
+
67
+ export default {
68
+ title: 'JS Packages/Components/Button',
69
+ component: Button,
70
+ argTypes: {
71
+ variant: {
72
+ control: {
73
+ type: 'select',
74
+ },
75
+ options: [ 'primary', 'secondary', 'link', 'tertiary' ],
76
+ },
77
+ size: {
78
+ control: {
79
+ type: 'select',
80
+ },
81
+ options: [ 'normal', 'small' ],
82
+ },
83
+ weight: {
84
+ control: {
85
+ type: 'select',
86
+ },
87
+ options: [ 'bold', 'regular' ],
88
+ },
89
+ icon: {
90
+ control: {
91
+ type: 'select',
92
+ },
93
+ options: [ 'none', ...Object.keys( icons ) ],
94
+ },
95
+ },
96
+ parameters: {
97
+ backgrounds: {
98
+ default: 'Jetpack Dashboard',
99
+ },
100
+ },
101
+ };
102
+
103
+ const DefaultTemplate = args => {
104
+ const icon = args?.icon && args?.icon !== 'none' ? <WPIcon icon={ icons[ args.icon ] } /> : null;
105
+ return <Button { ...args } icon={ icon } />;
106
+ };
107
+
108
+ export const _default = DefaultTemplate.bind( {} );
109
+ _default.args = {
110
+ variant: 'primary',
111
+ size: 'normal',
112
+ weight: 'bold',
113
+ icon: 'cloud',
114
+ isExternalLink: false,
115
+ isLoading: false,
116
+ disabled: false,
117
+ isDestructive: false,
118
+ fullWidth: false,
119
+ children: 'Once upon a time… a button story',
120
+ };
121
+
122
+ const Template = args => <Button { ...args } />;
123
+
124
+ export const ButtonPrimary = Template.bind( {} );
125
+ ButtonPrimary.argTypes = {
126
+ ...disableVariant,
127
+ ...disableDisabled,
128
+ ...disableIcon,
129
+ ...disableIsLoading,
130
+ ...disableIsDestructive,
131
+ ...disableFullWidth,
132
+ };
133
+ ButtonPrimary.args = {
134
+ size: 'normal',
135
+ children: 'Jetpack Button',
136
+ variant: 'primary',
137
+ };
138
+
139
+ export const ButtonSecondary = Template.bind( {} );
140
+ ButtonSecondary.argTypes = {
141
+ ...disableVariant,
142
+ ...disableDisabled,
143
+ ...disableIcon,
144
+ ...disableIsLoading,
145
+ ...disableIsDestructive,
146
+ ...disableClassName,
147
+ ...disableFullWidth,
148
+ };
149
+ ButtonSecondary.args = {
150
+ size: 'normal',
151
+ children: 'Jetpack Button',
152
+ variant: 'secondary',
153
+ };
154
+
155
+ export const ButtonLink = Template.bind( {} );
156
+ ButtonLink.argTypes = {
157
+ ...disableVariant,
158
+ ...disableDisabled,
159
+ ...disableIcon,
160
+ ...disableIsLoading,
161
+ ...disableIsDestructive,
162
+ ...disableClassName,
163
+ ...disableFullWidth,
164
+ };
165
+ ButtonLink.args = {
166
+ size: 'normal',
167
+ children: 'Jetpack Button',
168
+ variant: 'link',
169
+ };
170
+
171
+ export const ButtonExternalLink = Template.bind( {} );
172
+ ButtonExternalLink.argTypes = {
173
+ ...disableVariant,
174
+ ...disableDisabled,
175
+ ...disableIcon,
176
+ ...disableIsLoading,
177
+ ...disableIsDestructive,
178
+ ...disableClassName,
179
+ ...disableFullWidth,
180
+ };
181
+ ButtonExternalLink.args = {
182
+ size: 'normal',
183
+ children: 'Jetpack Button',
184
+ variant: 'external-link',
185
+ };
186
+
187
+ export const Icon = Template.bind( {} );
188
+ Icon.argTypes = {
189
+ ...disableIcon,
190
+ ...disableDisabled,
191
+ ...disableIsLoading,
192
+ ...disableIsDestructive,
193
+ ...disableClassName,
194
+ ...disableFullWidth,
195
+ };
196
+ Icon.args = {
197
+ size: 'normal',
198
+ children: 'Jetpack Button',
199
+ icon: <WPIcon icon={ check } />,
200
+ variant: 'primary',
201
+ };
202
+
203
+ export const Disabled = Template.bind( {} );
204
+ Disabled.argTypes = {
205
+ ...disableDisabled,
206
+ ...disableIsDestructive,
207
+ ...disableIsLoading,
208
+ ...disableClassName,
209
+ ...disableFullWidth,
210
+ ...disableIcon,
211
+ };
212
+ Disabled.args = {
213
+ size: 'normal',
214
+ children: 'Jetpack Button',
215
+ variant: 'primary',
216
+ disabled: true,
217
+ };
218
+
219
+ export const Destructive = Template.bind( {} );
220
+ Destructive.argTypes = {
221
+ ...disableIsDestructive,
222
+ ...disableIsLoading,
223
+ ...disableDisabled,
224
+ ...disableClassName,
225
+ ...disableFullWidth,
226
+ ...disableIcon,
227
+ };
228
+ Destructive.args = {
229
+ size: 'normal',
230
+ children: 'Jetpack Button',
231
+ variant: 'primary',
232
+ isDestructive: true,
233
+ };
234
+
235
+ export const Loading = Template.bind( {} );
236
+ Loading.argTypes = {
237
+ ...disableIsDestructive,
238
+ ...disableIsLoading,
239
+ ...disableDisabled,
240
+ ...disableClassName,
241
+ ...disableFullWidth,
242
+ ...disableIcon,
243
+ };
244
+ Loading.args = {
245
+ size: 'normal',
246
+ children: 'Jetpack Button',
247
+ variant: 'primary',
248
+ isLoading: true,
249
+ };
250
+
251
+ export const FullWidth = Template.bind( {} );
252
+ FullWidth.argTypes = {
253
+ ...disableIsDestructive,
254
+ ...disableIsLoading,
255
+ ...disableDisabled,
256
+ ...disableClassName,
257
+ ...disableIcon,
258
+ };
259
+ FullWidth.args = {
260
+ size: 'normal',
261
+ children: 'Jetpack Button',
262
+ variant: 'primary',
263
+ fullWidth: true,
264
+ };
265
+
266
+ export const VariantsAndProps = () => {
267
+ const variants = [ 'primary', 'secondary', 'link' ];
268
+ return (
269
+ <>
270
+ <Container>
271
+ <Col>
272
+ <H3>Variants & Props</H3>
273
+ </Col>
274
+ <Col>
275
+ <Text mb={ 3 }>
276
+ The following shows how the properties modify the appearance and/or behavior of the
277
+ button, in the different variants. Keep in mind that you cannot combine the variants but
278
+ you can combine the props. Use the { '' }
279
+ <a href="./?path=/story/js-packages-components-button--default">default story</a> to
280
+ play with the combinations.
281
+ </Text>
282
+ </Col>
283
+ </Container>
284
+ <Container className={ styles.container } horizontalGap={ 0 }>
285
+ <Col
286
+ className={ `${ styles[ 'row-instance' ] } ${ styles.header }` }
287
+ sm={ 4 }
288
+ md={ 2 }
289
+ lg={ 3 }
290
+ >
291
+ <Text size="body-extra-small">props / variants</Text>
292
+ </Col>
293
+
294
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
295
+ <Text size="body-extra-small" className={ styles.header }>
296
+ Primary
297
+ </Text>
298
+ </Col>
299
+
300
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
301
+ <Text size="body-extra-small" className={ styles.header }>
302
+ Secondary
303
+ </Text>
304
+ </Col>
305
+
306
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
307
+ <Text size="body-extra-small" className={ styles.header }>
308
+ Link
309
+ </Text>
310
+ </Col>
311
+
312
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
313
+ <Text size="body-extra-small">no props</Text>
314
+ </Col>
315
+ { variants.map( variant => (
316
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
317
+ <Button { ...ButtonPrimary.args } variant={ variant } />
318
+ </Col>
319
+ ) ) }
320
+
321
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
322
+ <Text size="body-extra-small">size: small</Text>
323
+ </Col>
324
+ { variants.map( variant => (
325
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
326
+ <Button { ...ButtonPrimary.args } variant={ variant } size="small" />
327
+ </Col>
328
+ ) ) }
329
+
330
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
331
+ <Text size="body-extra-small">weight: regular</Text>
332
+ </Col>
333
+ { variants.map( variant => (
334
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
335
+ <Button { ...ButtonPrimary.args } variant={ variant } weight="regular" />
336
+ </Col>
337
+ ) ) }
338
+
339
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
340
+ <Text size="body-extra-small">icon (cloud)</Text>
341
+ </Col>
342
+ { variants.map( variant => (
343
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
344
+ <Button
345
+ { ...ButtonPrimary.args }
346
+ variant={ variant }
347
+ icon={ <WPIcon icon={ cloud } /> }
348
+ />
349
+ </Col>
350
+ ) ) }
351
+
352
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
353
+ <Text size="body-extra-small">disabled</Text>
354
+ </Col>
355
+ { variants.map( variant => (
356
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
357
+ <Button { ...ButtonPrimary.args } variant={ variant } disabled />
358
+ </Col>
359
+ ) ) }
360
+
361
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
362
+ <Text size="body-extra-small">isDestructive</Text>
363
+ </Col>
364
+ { variants.map( variant => (
365
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
366
+ <Button { ...ButtonPrimary.args } variant={ variant } isDestructive />
367
+ </Col>
368
+ ) ) }
369
+
370
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
371
+ <Text size="body-extra-small">isExternalLink</Text>
372
+ </Col>
373
+ { variants.map( variant => (
374
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
375
+ <Button { ...ButtonPrimary.args } variant={ variant } isExternalLink />
376
+ </Col>
377
+ ) ) }
378
+
379
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
380
+ <Text size="body-extra-small">isLoading</Text>
381
+ </Col>
382
+ { variants.map( variant => (
383
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
384
+ <Button { ...ButtonPrimary.args } variant={ variant } isLoading />
385
+ </Col>
386
+ ) ) }
387
+
388
+ <Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
389
+ <Text size="body-extra-small">fullWidth</Text>
390
+ </Col>
391
+ { variants.map( variant => (
392
+ <Col sm={ 4 } md={ 2 } lg={ 3 }>
393
+ <Button { ...ButtonPrimary.args } variant={ variant } fullWidth />
394
+ </Col>
395
+ ) ) }
396
+ </Container>
397
+ </>
398
+ );
399
+ };
400
+ VariantsAndProps.storyName = 'Variants & Props';
@@ -0,0 +1,20 @@
1
+ .container {
2
+ row-gap: 0;
3
+ column-gap: 0;
4
+ > div {
5
+ border-right: 1px dotted var( --jp-gray-10 );
6
+ border-bottom: 1px dotted var( --jp-gray-10 );
7
+ padding: calc( var( --spacing-base ) * 4 ) calc( var( --spacing-base ) * 2 );
8
+ align-items: center;
9
+
10
+ &:nth-child(4n) {
11
+ border-right: none;
12
+ }
13
+ }
14
+ }
15
+
16
+
17
+ .header {
18
+ font-weight: 600;
19
+ text-align: center;
20
+ }
@@ -0,0 +1,212 @@
1
+ .button {
2
+ --wp-admin-theme-color: var(--jp-black);
3
+ --wp-admin-theme-color-darker-10: var(--jp-black-80);
4
+ --wp-admin-theme-color-darker-20: var(--jp-black-80);
5
+ // 1.51px to avoid subpixel rendering issues on Firefox/Linux
6
+ --wp-admin-border-width-focus: 1.51px;
7
+
8
+ border-radius: var(--jp-border-radius);
9
+ justify-content: center;
10
+ font-weight: 600;
11
+
12
+ // Icon Button
13
+ &.is-icon-button {
14
+ padding: var( --spacing-base );
15
+ width: calc( var( --spacing-base ) * 5 );
16
+ height: calc( var( --spacing-base ) * 5 );
17
+ > svg:first-child {
18
+ margin: 0;
19
+ padding: 0;
20
+ }
21
+
22
+ &.small {
23
+ padding: calc( var( --spacing-base ) / 2 );
24
+ width: calc( var( --spacing-base ) * 4 );
25
+ min-width: calc( var( --spacing-base ) * 4 );
26
+ height: calc( var( --spacing-base ) * 4 );
27
+ }
28
+ }
29
+
30
+ // Normal Size & Font
31
+ &.normal:not(.is-icon-button) {
32
+ height: auto;
33
+ font-size: var(--font-body);
34
+ line-height: 24px;
35
+ padding: var(--spacing-base) calc( var(--spacing-base) * 3); // 8px - 24px
36
+
37
+ // With icon
38
+ &.icon {
39
+ padding: var(--spacing-base) calc( var(--spacing-base) * 2); // 8px - 16px
40
+ }
41
+ }
42
+
43
+ // Small Size & Font
44
+ &.small:not(.is-icon-button) {
45
+ height: auto;
46
+ font-size: var(--font-body-extra-small);
47
+ line-height: 20px;
48
+ padding: calc( var(--spacing-base) / 2 ) var(--spacing-base); // 4px - 8px
49
+
50
+ &.icon > svg:first-child {
51
+ margin-right: calc( var(--spacing-base) / 2 ); // 4px
52
+ }
53
+
54
+ // With Spinner
55
+ & > :global(.components-spinner) {
56
+ height: 20px;
57
+ }
58
+ }
59
+
60
+ &.regular {
61
+ font-weight: 400;
62
+ }
63
+
64
+ // Full Width
65
+ &.full-width {
66
+ min-width: 100%;
67
+ }
68
+
69
+ // SPECIFICS
70
+ // PRIMARY AND SECONDARY
71
+
72
+ // Primary & Secondary
73
+ &:global(.is-primary),
74
+ &:global(.is-secondary) {
75
+ // Disabled
76
+ &:disabled {
77
+ background: var(--jp-gray);
78
+ color: var(--jp-gray-20);
79
+ }
80
+ }
81
+
82
+ // Only Secondary
83
+ &:global(.is-secondary) {
84
+ background: var(--jp-white);
85
+ // 1.51px to avoid subpixel rendering issues on Firefox/Linux
86
+ box-shadow: inset 0 0 0 1.51px var(--jp-black);
87
+
88
+ // Hover & Active
89
+ &:active:not(:disabled),
90
+ &:hover:not(:disabled) {
91
+ background: var(--jp-gray-0);
92
+ }
93
+ }
94
+
95
+ // SPECIFICS
96
+ // LINK & EXTERNAL LINK
97
+
98
+ &:global(.is-link) {
99
+ // Normal & Small Spacing
100
+ &.normal,
101
+ &.small {
102
+ padding: 0;
103
+ }
104
+
105
+ // Hover State
106
+ &:hover:not(:disabled) {
107
+ text-decoration-thickness: 3px;
108
+ }
109
+
110
+ // Focus State
111
+ &:focus:not(:disabled) {
112
+ text-decoration-line: none;
113
+ }
114
+ }
115
+
116
+ // DESTRUCTIVE
117
+
118
+ &:global(.is-destructive) {
119
+ // Primary
120
+ &:global(.is-primary) {
121
+ box-shadow: none;
122
+
123
+ &:not(:disabled) {
124
+ color: var(--jp-white);
125
+ background: var(--jp-red-50);
126
+ box-shadow: inset 0 0 0 1px var(--jp-red-50);
127
+ }
128
+
129
+ &:hover:not(:disabled) {
130
+ background: var(--jp-red-60);
131
+ box-shadow: inset 0 0 0 1px var(--jp-red-60);
132
+ }
133
+
134
+ &:focus:not(:disabled) {
135
+ box-shadow: inset 0 0 0 1px var(--jp-white), 0 0 0 var(--wp-admin-border-width-focus) var(--jp-red-70);
136
+ background: var(--jp-red-70);
137
+ color: var(--jp-white);
138
+ }
139
+
140
+ &:active:not(:disabled) {
141
+ background: var(--jp-red-50);
142
+ }
143
+ }
144
+
145
+ // Secondary
146
+ &:global(.is-secondary) {
147
+ box-shadow: none;
148
+
149
+ &:not(:disabled) {
150
+ color: var(--jp-red-50);
151
+ background: var(--jp-white);
152
+ box-shadow: inset 0 0 0 1.5px var(--jp-red-50);
153
+ }
154
+
155
+ &:hover:not(:disabled) {
156
+ background: var(--jp-red-0);
157
+ box-shadow: inset 0 0 0 1.5px var(--jp-red-60);
158
+ color: var(--jp-red-60);
159
+ }
160
+
161
+ &:focus:not(:disabled) {
162
+ box-shadow: inset 0 0 0 1px var(--jp-white), 0 0 0 var(--wp-admin-border-width-focus) var(--jp-red-70);
163
+ color: var(--jp-red-70);
164
+ }
165
+
166
+ &:active:not(:disabled) {
167
+ background: var(--jp-gray-0);
168
+ }
169
+ }
170
+
171
+ // Link
172
+ &:global(.is-link) {
173
+ &:not(:disabled) {
174
+ color: var(--jp-red-50);
175
+ }
176
+
177
+ &:hover:not(:disabled) {
178
+ color: var(--jp-red-60);
179
+ box-shadow: none;
180
+ }
181
+
182
+ &:focus:not(:disabled) {
183
+ color: var(--jp-red-70);
184
+ box-shadow: inset 0 0 0 1px var(--jp-white), 0 0 0 var(--wp-admin-border-width-focus) var(--jp-red-70);
185
+ }
186
+ }
187
+ }
188
+
189
+ // LOADING
190
+
191
+ &.loading {
192
+ position: relative;
193
+
194
+ &:global(.has-icon) {
195
+ justify-content: center;
196
+ }
197
+
198
+ & > *:not(:global(.components-spinner)) {
199
+ visibility: hidden;
200
+ }
201
+
202
+ // Spinner
203
+ & > :global(.components-spinner) {
204
+ margin: 0;
205
+ position: absolute;
206
+ }
207
+ }
208
+ }
209
+
210
+ .external-icon {
211
+ margin-left: calc( var(--spacing-base) / 2 ); // 4px
212
+ }
@@ -0,0 +1,21 @@
1
+ import { Button } from '@wordpress/components';
2
+ import type React from 'react';
3
+
4
+ type JetpackButtonBaseProps = {
5
+ className?: string;
6
+ children?: React.ReactNode;
7
+ disabled?: boolean;
8
+ isDestructive?: boolean;
9
+ isLoading?: boolean;
10
+ isExternalLink?: boolean;
11
+ size?: 'normal' | 'small';
12
+ text?: string;
13
+ variant?: 'primary' | 'secondary' | 'link' | 'tertiary';
14
+ weight?: 'bold' | 'regular';
15
+ fullWidth?: boolean;
16
+ ref: React.ForwardedRef< unknown >;
17
+ };
18
+
19
+ type WPButtonProps = Omit< React.ComponentProps< typeof Button >, 'size' | 'variant' >;
20
+
21
+ export type ButtonProps = JetpackButtonBaseProps & WPButtonProps;