@bundle-stats/ui 4.22.2 → 4.23.0-beta.1

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 (227) hide show
  1. package/.babelrc.js +65 -24
  2. package/globals.d.ts +13 -0
  3. package/lib/app/app.js +3 -0
  4. package/lib/app/app.js.map +1 -1
  5. package/lib/app/app.module.css +11 -1
  6. package/lib/components/bundle-modules/index.js.map +1 -1
  7. package/lib/components/delta/delta.js +3 -13
  8. package/lib/components/delta/delta.js.map +1 -1
  9. package/lib/components/delta/delta.module.css +13 -12
  10. package/lib/components/delta/index.js.map +1 -1
  11. package/lib/components/index.js +3 -1
  12. package/lib/components/index.js.map +1 -1
  13. package/lib/components/insight-icon/insight-icon.module.css +6 -6
  14. package/lib/components/job-name/job-name.js +1 -2
  15. package/lib/components/job-name/job-name.js.map +1 -1
  16. package/lib/components/metric-change-legend/index.js +18 -0
  17. package/lib/components/metric-change-legend/index.js.map +1 -0
  18. package/lib/components/metric-change-legend/metric-change-legend.js +91 -0
  19. package/lib/components/metric-change-legend/metric-change-legend.js.map +1 -0
  20. package/lib/components/metric-change-legend/metric-change-legend.module.css +69 -0
  21. package/lib/components/metric-run-info/metric-run-info.js +30 -7
  22. package/lib/components/metric-run-info/metric-run-info.js.map +1 -1
  23. package/lib/components/metrics-display-selector/metrics-display-selector.js +7 -9
  24. package/lib/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
  25. package/lib/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
  26. package/lib/components/metrics-table-header/metrics-table-header.js +8 -8
  27. package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -1
  28. package/lib/components/metrics-table-header/metrics-table-header.module.css +8 -12
  29. package/lib/components/metrics-table-options/metrics-table-options.js +1 -1
  30. package/lib/components/metrics-table-options/metrics-table-options.js.map +1 -1
  31. package/lib/components/metrics-table-title/metrics-table-title.js +1 -1
  32. package/lib/components/metrics-table-title/metrics-table-title.js.map +1 -1
  33. package/lib/components/run-info/run-info.js +26 -14
  34. package/lib/components/run-info/run-info.js.map +1 -1
  35. package/lib/components/run-info/run-info.module.css +35 -26
  36. package/lib/components/summary/summary.js +9 -10
  37. package/lib/components/summary/summary.js.map +1 -1
  38. package/lib/components/summary/summary.module.css +60 -10
  39. package/lib/constants.js +13 -1
  40. package/lib/constants.js.map +1 -1
  41. package/lib/css/default.css +1 -1
  42. package/lib/css/variables.css +71 -58
  43. package/lib/hooks/rows-sort.js +13 -12
  44. package/lib/hooks/rows-sort.js.map +1 -1
  45. package/lib/ui/button/button.js.map +1 -1
  46. package/lib/ui/dialog/dialog.js +4 -2
  47. package/lib/ui/dialog/dialog.js.map +1 -1
  48. package/lib/ui/dialog/dialog.module.css +22 -0
  49. package/lib/ui/dropdown/dropdown.js +4 -3
  50. package/lib/ui/dropdown/dropdown.js.map +1 -1
  51. package/lib/ui/dropdown/dropdown.module.css +11 -0
  52. package/lib/ui/empty-set/empty-set.js +3 -3
  53. package/lib/ui/empty-set/empty-set.js.map +1 -1
  54. package/lib/ui/hover-card/hover-card.js +1 -1
  55. package/lib/ui/hover-card/hover-card.js.map +1 -1
  56. package/lib/ui/hover-card/hover-card.module.css +14 -0
  57. package/lib/ui/table/table.module.css +0 -1
  58. package/lib/ui/tooltip/tooltip.js +1 -1
  59. package/lib/ui/tooltip/tooltip.js.map +1 -1
  60. package/lib/ui/tooltip/tooltip.module.css +11 -0
  61. package/lib-esm/app/app.js +4 -1
  62. package/lib-esm/app/app.js.map +1 -1
  63. package/lib-esm/app/app.module.css +11 -1
  64. package/lib-esm/components/bundle-modules/index.js.map +1 -1
  65. package/lib-esm/components/delta/delta.js +3 -13
  66. package/lib-esm/components/delta/delta.js.map +1 -1
  67. package/lib-esm/components/delta/delta.module.css +13 -12
  68. package/lib-esm/components/delta/index.js.map +1 -1
  69. package/lib-esm/components/index.js +1 -0
  70. package/lib-esm/components/index.js.map +1 -1
  71. package/lib-esm/components/insight-icon/insight-icon.module.css +6 -6
  72. package/lib-esm/components/job-name/job-name.js +1 -2
  73. package/lib-esm/components/job-name/job-name.js.map +1 -1
  74. package/lib-esm/components/metric-change-legend/index.js +2 -0
  75. package/lib-esm/components/metric-change-legend/index.js.map +1 -0
  76. package/lib-esm/components/metric-change-legend/metric-change-legend.js +84 -0
  77. package/lib-esm/components/metric-change-legend/metric-change-legend.js.map +1 -0
  78. package/lib-esm/components/metric-change-legend/metric-change-legend.module.css +69 -0
  79. package/lib-esm/components/metric-run-info/metric-run-info.js +31 -8
  80. package/lib-esm/components/metric-run-info/metric-run-info.js.map +1 -1
  81. package/lib-esm/components/metrics-display-selector/metrics-display-selector.js +7 -9
  82. package/lib-esm/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
  83. package/lib-esm/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
  84. package/lib-esm/components/metrics-table-header/metrics-table-header.js +8 -8
  85. package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -1
  86. package/lib-esm/components/metrics-table-header/metrics-table-header.module.css +8 -12
  87. package/lib-esm/components/metrics-table-options/metrics-table-options.js +1 -1
  88. package/lib-esm/components/metrics-table-options/metrics-table-options.js.map +1 -1
  89. package/lib-esm/components/metrics-table-title/metrics-table-title.js +1 -1
  90. package/lib-esm/components/metrics-table-title/metrics-table-title.js.map +1 -1
  91. package/lib-esm/components/run-info/run-info.js +26 -14
  92. package/lib-esm/components/run-info/run-info.js.map +1 -1
  93. package/lib-esm/components/run-info/run-info.module.css +35 -26
  94. package/lib-esm/components/summary/summary.js +10 -11
  95. package/lib-esm/components/summary/summary.js.map +1 -1
  96. package/lib-esm/components/summary/summary.module.css +60 -10
  97. package/lib-esm/constants.js +12 -0
  98. package/lib-esm/constants.js.map +1 -1
  99. package/lib-esm/css/default.css +1 -1
  100. package/lib-esm/css/variables.css +71 -58
  101. package/lib-esm/hooks/rows-sort.js +10 -8
  102. package/lib-esm/hooks/rows-sort.js.map +1 -1
  103. package/lib-esm/ui/button/button.js.map +1 -1
  104. package/lib-esm/ui/dialog/dialog.js +4 -2
  105. package/lib-esm/ui/dialog/dialog.js.map +1 -1
  106. package/lib-esm/ui/dialog/dialog.module.css +22 -0
  107. package/lib-esm/ui/dropdown/dropdown.js +4 -3
  108. package/lib-esm/ui/dropdown/dropdown.js.map +1 -1
  109. package/lib-esm/ui/dropdown/dropdown.module.css +11 -0
  110. package/lib-esm/ui/empty-set/empty-set.js +3 -3
  111. package/lib-esm/ui/empty-set/empty-set.js.map +1 -1
  112. package/lib-esm/ui/hover-card/hover-card.js +1 -1
  113. package/lib-esm/ui/hover-card/hover-card.js.map +1 -1
  114. package/lib-esm/ui/hover-card/hover-card.module.css +14 -0
  115. package/lib-esm/ui/table/table.module.css +0 -1
  116. package/lib-esm/ui/tooltip/tooltip.js +1 -1
  117. package/lib-esm/ui/tooltip/tooltip.js.map +1 -1
  118. package/lib-esm/ui/tooltip/tooltip.module.css +11 -0
  119. package/package.json +26 -15
  120. package/src/app/app.jsx +6 -1
  121. package/src/app/app.module.css +11 -1
  122. package/src/app/app.stories.tsx +2 -2
  123. package/src/components/asset-info/asset-info.stories.tsx +47 -39
  124. package/src/components/asset-name/asset-name.stories.tsx +1 -3
  125. package/src/components/asset-not-predictive/asset-not-predictive.stories.tsx +22 -15
  126. package/src/components/browsertime-table/browsertime-table.stories.tsx +45 -0
  127. package/src/components/bundle-assets-totals/bundle-assets-totals.stories.tsx +47 -0
  128. package/src/components/bundle-modules/bundle-modules.stories.tsx +191 -0
  129. package/src/components/bundle-modules/bundle-modules.tsx +1 -1
  130. package/src/components/bundle-modules/index.tsx +4 -0
  131. package/src/components/bundle-packages/bundle-packages.stories.tsx +87 -0
  132. package/src/components/delta/delta.module.css +13 -12
  133. package/src/components/delta/delta.stories.tsx +57 -0
  134. package/src/components/delta/delta.tsx +32 -0
  135. package/src/components/entry-info/entry-info.stories.tsx +49 -54
  136. package/src/components/{index.js → index.ts} +7 -2
  137. package/src/components/insight-icon/insight-icon.module.css +6 -6
  138. package/src/components/insights/insights.stories.tsx +36 -33
  139. package/src/components/job-name/job-name.jsx +2 -3
  140. package/src/components/job-name/job-name.stories.tsx +46 -0
  141. package/src/components/jobs-header/jobs-header.stories.tsx +19 -15
  142. package/src/components/lighthouse-table/lighthouse-table.stories.tsx +30 -0
  143. package/src/components/metric/metric.stories.tsx +24 -22
  144. package/src/components/metric-change-legend/index.ts +1 -0
  145. package/src/components/metric-change-legend/metric-change-legend.module.css +69 -0
  146. package/src/components/metric-change-legend/metric-change-legend.stories.tsx +13 -0
  147. package/src/components/metric-change-legend/metric-change-legend.tsx +148 -0
  148. package/src/components/metric-run-info/metric-run-info.stories.tsx +45 -41
  149. package/src/components/metric-run-info/metric-run-info.tsx +41 -17
  150. package/src/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
  151. package/src/components/metrics-display-selector/metrics-display-selector.tsx +25 -37
  152. package/src/components/metrics-table/metrics-table.stories.tsx +33 -13
  153. package/src/components/metrics-table/metrics-table.tsx +1 -1
  154. package/src/components/metrics-table-header/metrics-table-header.module.css +8 -12
  155. package/src/components/metrics-table-header/metrics-table-header.tsx +14 -10
  156. package/src/components/metrics-table-options/metrics-table-options.tsx +1 -1
  157. package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
  158. package/src/components/module-info/module-info.stories.tsx +41 -30
  159. package/src/components/package-info/package-info.stories.tsx +20 -15
  160. package/src/components/run-info/run-info.module.css +35 -26
  161. package/src/components/run-info/run-info.stories.tsx +47 -39
  162. package/src/components/run-info/run-info.tsx +132 -73
  163. package/src/components/summary/summary.module.css +60 -10
  164. package/src/components/summary/summary.stories.tsx +26 -32
  165. package/src/components/summary/summary.tsx +47 -50
  166. package/src/constants.ts +13 -0
  167. package/src/css/default.css +1 -1
  168. package/src/css/variables.css +71 -58
  169. package/src/hooks/rows-sort.ts +9 -6
  170. package/src/layout/box/box.stories.tsx +35 -28
  171. package/src/layout/flex-stack/flex-stack.stories.tsx +79 -48
  172. package/src/layout/footer/footer.stories.tsx +30 -0
  173. package/src/layout/stack/stack.stories.tsx +68 -44
  174. package/src/ui/alert/alert.stories.tsx +25 -21
  175. package/src/ui/button/button.stories.tsx +181 -176
  176. package/src/ui/button/button.tsx +8 -1
  177. package/src/ui/container/container.stories.tsx +28 -21
  178. package/src/ui/control-group/control-group.stories.tsx +23 -16
  179. package/src/ui/dialog/dialog.module.css +22 -0
  180. package/src/ui/dialog/dialog.tsx +9 -2
  181. package/src/ui/dropdown/dropdown.module.css +11 -0
  182. package/src/ui/dropdown/dropdown.stories.tsx +23 -15
  183. package/src/ui/dropdown/dropdown.tsx +5 -1
  184. package/src/ui/empty-set/empty-set.jsx +16 -4
  185. package/src/ui/empty-set/empty-set.stories.tsx +41 -0
  186. package/src/ui/file-name/file-name.stories.tsx +45 -0
  187. package/src/ui/filters/filters.stories.tsx +29 -26
  188. package/src/ui/hover-card/hover-card.module.css +14 -0
  189. package/src/ui/hover-card/hover-card.stories.tsx +35 -26
  190. package/src/ui/hover-card/hover-card.tsx +1 -1
  191. package/src/ui/icon/icon.stories.tsx +36 -28
  192. package/src/ui/input/input.stories.tsx +17 -5
  193. package/src/ui/input-search/input-search.stories.tsx +31 -0
  194. package/src/ui/loader/loader.stories.tsx +22 -0
  195. package/src/ui/skeleton/skeleton.stories.tsx +42 -0
  196. package/src/ui/table/table.module.css +0 -1
  197. package/src/ui/table/table.stories.tsx +244 -218
  198. package/src/ui/tag/tag.stories.tsx +11 -10
  199. package/src/ui/toolbar/toolbar.stories.tsx +41 -0
  200. package/src/ui/tooltip/tooltip.module.css +11 -0
  201. package/src/ui/tooltip/tooltip.tsx +1 -1
  202. package/types/components/bundle-modules/bundle-modules.d.ts +1 -1
  203. package/types/components/bundle-modules/index.d.ts +2 -1
  204. package/types/components/delta/delta.d.ts +7 -21
  205. package/types/components/delta/index.d.ts +1 -1
  206. package/types/components/index.d.ts +25 -20
  207. package/types/components/metric-change-legend/index.d.ts +1 -0
  208. package/types/components/metric-change-legend/metric-change-legend.d.ts +4 -0
  209. package/types/components/metric-run-info/metric-run-info.d.ts +2 -6
  210. package/types/components/metrics-table/metrics-table.d.ts +1 -1
  211. package/types/components/metrics-table-header/metrics-table-header.d.ts +1 -1
  212. package/types/components/run-info/run-info.d.ts +16 -7
  213. package/types/constants.d.ts +12 -0
  214. package/types/hooks/rows-sort.d.ts +2 -2
  215. package/types/ui/button/button.d.ts +1 -1
  216. package/types/ui/dialog/dialog.d.ts +3 -2
  217. package/types/ui/dropdown/dropdown.d.ts +1 -0
  218. package/vitest.config.ts +47 -0
  219. package/vitest.setup.ts +26 -0
  220. package/lib/assets/icons.svg.js +0 -100
  221. package/lib/assets/icons.svg.js.map +0 -1
  222. package/lib-esm/assets/icons.svg.js +0 -63
  223. package/lib-esm/assets/icons.svg.js.map +0 -1
  224. package/src/assets/icons.svg.jsx +0 -279
  225. package/src/components/delta/delta.jsx +0 -22
  226. package/types/assets/icons.svg.d.ts +0 -2
  227. /package/src/components/delta/{index.js → index.ts} +0 -0
@@ -1,53 +1,77 @@
1
1
  import React from 'react';
2
- import type { Meta } from '@storybook/react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  import { getWrapperDecorator } from '../../stories';
5
5
  import { Box } from '../box';
6
6
  import { Stack } from '.';
7
7
 
8
- export default {
8
+ const meta = {
9
9
  title: 'Layout/Stack',
10
10
  component: Stack,
11
11
  decorators: [getWrapperDecorator()],
12
- } as Meta<typeof Stack>;
13
-
14
- export const Default = () => (
15
- <Stack>
16
- <Box outline>Lorem ipsum 1</Box>
17
- <Box outline>Lorem ipsum 2</Box>
18
- {null}
19
- Lorem ipsum 3
20
- </Stack>
21
- );
22
-
23
- export const WithCustomWrapper = () => (
24
- <Stack as="main" className="wrapper">
25
- <Box outline>Lorem ipsum 1</Box>
26
- <Box outline>Lorem ipsum 2</Box>
27
- </Stack>
28
- );
29
-
30
- export const WithSpace = () => (
31
- <Stack space="large">
32
- <Box outline>Lorem ipsum 1</Box>
33
- <Box outline>Lorem ipsum 2</Box>
34
- <Box outline>Lorem ipsum 3</Box>
35
- </Stack>
36
- );
37
-
38
- export const WithNestedStacks = () => (
39
- <Stack space="large">
40
- <Box outline>Lorem ipsum 1</Box>
41
- <Box outline>Lorem ipsum 2</Box>
42
- <Stack space="small">
43
- <Box outline>Lorem ipsum 3.1</Box>
44
- <Box outline>Lorem ipsum 3.2</Box>
45
- </Stack>
46
- </Stack>
47
- );
48
-
49
- export const WithSingleItem = () => (
50
- <Stack>
51
- <Box outline>Lorem ipsum</Box>
52
- </Stack>
53
- );
12
+ } satisfies Meta<typeof Stack>;
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ export const Default: Story = {
19
+ args: {
20
+ children: (
21
+ <>
22
+ <Box outline>Lorem ipsum 1</Box>
23
+ <Box outline>Lorem ipsum 2</Box>
24
+ {null}
25
+ Lorem ipsum 3
26
+ </>
27
+ ),
28
+ },
29
+ };
30
+
31
+ export const WithCustomWrapper: Story = {
32
+ args: {
33
+ as: 'main',
34
+ className: 'wrapper',
35
+ children: (
36
+ <>
37
+ <Box outline>Lorem ipsum 1</Box>
38
+ <Box outline>Lorem ipsum 2</Box>
39
+ </>
40
+ ),
41
+ },
42
+ };
43
+
44
+ export const WithSpace: Story = {
45
+ args: {
46
+ space: 'large',
47
+ children: (
48
+ <>
49
+ <Box outline>Lorem ipsum 1</Box>
50
+ <Box outline>Lorem ipsum 2</Box>
51
+ <Box outline>Lorem ipsum 3</Box>
52
+ </>
53
+ ),
54
+ },
55
+ };
56
+
57
+ export const WithNestedStacks: Story = {
58
+ args: {
59
+ space: 'large',
60
+ children: (
61
+ <>
62
+ <Box outline>Lorem ipsum 1</Box>
63
+ <Box outline>Lorem ipsum 2</Box>
64
+ <Stack space="small">
65
+ <Box outline>Lorem ipsum 3.1</Box>
66
+ <Box outline>Lorem ipsum 3.2</Box>
67
+ </Stack>
68
+ </>
69
+ ),
70
+ },
71
+ };
72
+
73
+ export const WithSingleItem: Story = {
74
+ args: {
75
+ children: <Box outline>Lorem ipsum</Box>,
76
+ },
77
+ };
@@ -1,39 +1,43 @@
1
- import React from 'react';
2
- import type { Meta, Story } from '@storybook/react';
1
+ import type { Meta, StoryObj } from '@storybook/react';
3
2
 
4
3
  import { getWrapperDecorator } from '../../stories';
5
4
  import { Alert } from '.';
6
5
 
7
- export default {
6
+ const meta = {
8
7
  title: 'UI/Alert',
9
8
  component: Alert,
10
9
  decorators: [getWrapperDecorator()],
11
- } as Meta<typeof Alert>;
10
+ args: {
11
+ children: 'Lorem ipsum',
12
+ },
13
+ } satisfies Meta<typeof Alert>;
12
14
 
13
- const Template: Story = (args) => <Alert {...args}>Lorem ipsum</Alert>;
15
+ export default meta;
14
16
 
15
- export const Default = Template.bind({});
17
+ type Story = StoryObj<typeof meta>;
16
18
 
17
- export const WithKindSuccess = Template.bind({});
19
+ export const Default: Story = {};
18
20
 
19
- WithKindSuccess.args = {
20
- kind: 'success',
21
+ export const WithKindSuccess: Story = {
22
+ args: {
23
+ kind: 'success',
24
+ },
21
25
  };
22
26
 
23
- export const WithKindInfo = Template.bind({});
24
-
25
- WithKindInfo.args = {
26
- kind: 'info',
27
+ export const WithKindInfo: Story = {
28
+ args: {
29
+ kind: 'info',
30
+ },
27
31
  };
28
32
 
29
- export const WithKindWarning = Template.bind({});
30
-
31
- WithKindWarning.args = {
32
- kind: 'warning',
33
+ export const WithKindWarning: Story = {
34
+ args: {
35
+ kind: 'warning',
36
+ },
33
37
  };
34
38
 
35
- export const WithKindDanger = Template.bind({});
36
-
37
- WithKindDanger.args = {
38
- kind: 'danger',
39
+ export const WithKindDanger: Story = {
40
+ args: {
41
+ kind: 'danger',
42
+ },
39
43
  };
@@ -1,234 +1,239 @@
1
1
  import React from 'react';
2
- import { Meta, Story } from '@storybook/react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  import { Stack } from '../../layout/stack';
5
5
  import { FlexStack } from '../../layout/flex-stack';
6
6
  import { Icon } from '../icon';
7
7
  import { Button, BUTTON_SIZE, BUTTON_KIND } from '.';
8
8
 
9
- export default {
9
+ const meta = {
10
10
  title: 'UI/Button',
11
11
  component: Button,
12
- } as Meta;
12
+ args: {
13
+ children: 'Action',
14
+ },
15
+ } satisfies Meta<typeof Button>;
13
16
 
14
- const Template: Story = ({ children = 'Action', ...props }) => (
15
- <Button {...props}>{children}</Button>
16
- );
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof meta>;
17
20
 
18
- const Items = (props) => (
21
+ const Items = (props: React.ComponentProps<typeof FlexStack>) => (
19
22
  <FlexStack alignItems="top" style={{ flexWrap: 'wrap', gap: '12px' }} {...props} />
20
23
  );
21
24
 
22
- export const Default = Template.bind({});
25
+ export const Default: Story = {};
23
26
 
24
- export const All = () => (
25
- <Stack space="large">
26
- <Stack space="medium">
27
- <h2>Size</h2>
28
- <Items>
29
- {Object.values(BUTTON_SIZE).map((size) => (
30
- <Button size={size} key={size}>
31
- Action {size}
32
- </Button>
33
- ))}
34
- </Items>
35
- </Stack>
36
- <Stack space="medium">
37
- <h2>Kind</h2>
27
+ export const All: Story = {
28
+ render: () => (
29
+ <Stack space="large">
38
30
  <Stack space="medium">
31
+ <h2>Size</h2>
39
32
  <Items>
40
- {Object.values(BUTTON_KIND).map((kind) => (
41
- <Button kind={kind} key={kind}>
42
- Action {kind}
43
- </Button>
44
- ))}
45
- </Items>
46
- <h3>Active</h3>
47
- <Items>
48
- {Object.values(BUTTON_KIND).map((kind) => (
49
- <Button kind={kind} key={kind} active>
50
- Action {kind}
51
- </Button>
52
- ))}
53
- </Items>
54
- <h3>As link</h3>
55
- <Items>
56
- {Object.values(BUTTON_KIND).map((kind) => (
57
- <Button kind={kind} key={kind} as="a" href="#">
58
- Action {kind}
59
- </Button>
60
- ))}
61
- </Items>
62
- <h3>With icon</h3>
63
- <Items>
64
- {Object.values(BUTTON_KIND).map((kind) => (
65
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} kind={kind} key={kind}>
66
- Action {kind}
67
- </Button>
68
- ))}
69
- </Items>
70
- <Items>
71
- {Object.values(BUTTON_KIND).map((kind) => (
72
- <Button rightGlyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} kind={kind} key={kind}>
73
- Action {kind}
74
- </Button>
75
- ))}
76
- </Items>
77
- <h3>Disabled</h3>
78
- <Items>
79
- {Object.values(BUTTON_KIND).map((kind) => (
80
- <Button kind={kind} key={kind} disabled>
81
- Action {kind}
33
+ {Object.values(BUTTON_SIZE).map((size) => (
34
+ <Button size={size} key={size}>
35
+ Action {size}
82
36
  </Button>
83
37
  ))}
84
38
  </Items>
85
39
  </Stack>
86
- </Stack>
87
- <Stack space="medium">
88
- <h2>Outline & Kind</h2>
89
40
  <Stack space="medium">
90
- {Object.values(BUTTON_SIZE).map((size) => (
91
- <Items key={size}>
92
- <Button outline size={size}>
93
- Action default
94
- </Button>
41
+ <h2>Kind</h2>
42
+ <Stack space="medium">
43
+ <Items>
95
44
  {Object.values(BUTTON_KIND).map((kind) => (
96
- <Button outline kind={kind} key={kind} size={size}>
45
+ <Button kind={kind} key={kind}>
97
46
  Action {kind}
98
47
  </Button>
99
48
  ))}
100
49
  </Items>
101
- ))}
102
- <h3>Active</h3>
103
- <Items>
104
- <Button outline active>
105
- Action default
106
- </Button>
107
- {Object.values(BUTTON_KIND).map((kind) => (
108
- <Button outline kind={kind} key={kind} active>
109
- Action {kind}
110
- </Button>
111
- ))}
112
- </Items>
113
- <h3>With icon</h3>
114
- {Object.values(BUTTON_SIZE).map((size) => (
115
- <Items key={size}>
116
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size}>
117
- Action default
118
- </Button>
50
+ <h3>Active</h3>
51
+ <Items>
119
52
  {Object.values(BUTTON_KIND).map((kind) => (
120
- <Button
121
- glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
122
- outline
123
- kind={kind}
124
- size={size}
125
- key={kind}
126
- >
53
+ <Button kind={kind} key={kind} active>
127
54
  Action {kind}
128
55
  </Button>
129
56
  ))}
130
57
  </Items>
131
- ))}
132
- <h3>Only icon</h3>
133
- {Object.values(BUTTON_SIZE).map((size) => (
134
- <Items key={size}>
135
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size} />
58
+ <h3>As link</h3>
59
+ <Items>
136
60
  {Object.values(BUTTON_KIND).map((kind) => (
137
- <Button
138
- glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
139
- outline
140
- kind={kind}
141
- size={size}
142
- key={kind}
143
- />
61
+ <Button kind={kind} key={kind} as="a" href="#">
62
+ Action {kind}
63
+ </Button>
144
64
  ))}
145
65
  </Items>
146
- ))}
147
- <h3>Disabled</h3>
148
- <Items>
149
- <Button outline disabled>
150
- Action default
151
- </Button>
152
- {Object.values(BUTTON_KIND).map((kind) => (
153
- <Button outline kind={kind} key={kind} disabled>
154
- Action {kind}
155
- </Button>
156
- ))}
157
- </Items>
66
+ <h3>With icon</h3>
67
+ <Items>
68
+ {Object.values(BUTTON_KIND).map((kind) => (
69
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} kind={kind} key={kind}>
70
+ Action {kind}
71
+ </Button>
72
+ ))}
73
+ </Items>
74
+ <Items>
75
+ {Object.values(BUTTON_KIND).map((kind) => (
76
+ <Button rightGlyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} kind={kind} key={kind}>
77
+ Action {kind}
78
+ </Button>
79
+ ))}
80
+ </Items>
81
+ <h3>Disabled</h3>
82
+ <Items>
83
+ {Object.values(BUTTON_KIND).map((kind) => (
84
+ <Button kind={kind} key={kind} disabled>
85
+ Action {kind}
86
+ </Button>
87
+ ))}
88
+ </Items>
89
+ </Stack>
158
90
  </Stack>
159
- </Stack>
160
- <Stack space="medium">
161
- <h2>Solid & Kind</h2>
162
91
  <Stack space="medium">
163
- {Object.values(BUTTON_SIZE).map((size) => (
164
- <Items key={size}>
165
- <Button solid size={size}>
92
+ <h2>Outline &amp; Kind</h2>
93
+ <Stack space="medium">
94
+ {Object.values(BUTTON_SIZE).map((size) => (
95
+ <Items key={size}>
96
+ <Button outline size={size}>
97
+ Action default
98
+ </Button>
99
+ {Object.values(BUTTON_KIND).map((kind) => (
100
+ <Button outline kind={kind} key={kind} size={size}>
101
+ Action {kind}
102
+ </Button>
103
+ ))}
104
+ </Items>
105
+ ))}
106
+ <h3>Active</h3>
107
+ <Items>
108
+ <Button outline active>
166
109
  Action default
167
110
  </Button>
168
111
  {Object.values(BUTTON_KIND).map((kind) => (
169
- <Button solid kind={kind} key={kind} size={size}>
112
+ <Button outline kind={kind} key={kind} active>
170
113
  Action {kind}
171
114
  </Button>
172
115
  ))}
173
116
  </Items>
174
- ))}
175
- <h3>Active</h3>
176
- <Items>
177
- <Button solid active>
178
- Action default
179
- </Button>
180
- {Object.values(BUTTON_KIND).map((kind) => (
181
- <Button solid kind={kind} key={kind} active>
182
- Action {kind}
183
- </Button>
117
+ <h3>With icon</h3>
118
+ {Object.values(BUTTON_SIZE).map((size) => (
119
+ <Items key={size}>
120
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size}>
121
+ Action default
122
+ </Button>
123
+ {Object.values(BUTTON_KIND).map((kind) => (
124
+ <Button
125
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
126
+ outline
127
+ kind={kind}
128
+ size={size}
129
+ key={kind}
130
+ >
131
+ Action {kind}
132
+ </Button>
133
+ ))}
134
+ </Items>
184
135
  ))}
185
- </Items>
186
- <h3>With icon</h3>
187
- {Object.values(BUTTON_SIZE).map((size) => (
188
- <Items key={size}>
189
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size}>
136
+ <h3>Only icon</h3>
137
+ {Object.values(BUTTON_SIZE).map((size) => (
138
+ <Items key={size}>
139
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size} />
140
+ {Object.values(BUTTON_KIND).map((kind) => (
141
+ <Button
142
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
143
+ outline
144
+ kind={kind}
145
+ size={size}
146
+ key={kind}
147
+ />
148
+ ))}
149
+ </Items>
150
+ ))}
151
+ <h3>Disabled</h3>
152
+ <Items>
153
+ <Button outline disabled>
190
154
  Action default
191
155
  </Button>
192
156
  {Object.values(BUTTON_KIND).map((kind) => (
193
- <Button
194
- glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
195
- solid
196
- kind={kind}
197
- size={size}
198
- key={kind}
199
- >
157
+ <Button outline kind={kind} key={kind} disabled>
200
158
  Action {kind}
201
159
  </Button>
202
160
  ))}
203
161
  </Items>
204
- ))}
205
- <h3>Only icon</h3>
206
- {Object.values(BUTTON_SIZE).map((size) => (
207
- <Items key={size}>
208
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size} />
162
+ </Stack>
163
+ </Stack>
164
+ <Stack space="medium">
165
+ <h2>Solid &amp; Kind</h2>
166
+ <Stack space="medium">
167
+ {Object.values(BUTTON_SIZE).map((size) => (
168
+ <Items key={size}>
169
+ <Button solid size={size}>
170
+ Action default
171
+ </Button>
172
+ {Object.values(BUTTON_KIND).map((kind) => (
173
+ <Button solid kind={kind} key={kind} size={size}>
174
+ Action {kind}
175
+ </Button>
176
+ ))}
177
+ </Items>
178
+ ))}
179
+ <h3>Active</h3>
180
+ <Items>
181
+ <Button solid active>
182
+ Action default
183
+ </Button>
209
184
  {Object.values(BUTTON_KIND).map((kind) => (
210
- <Button
211
- glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
212
- solid
213
- kind={kind}
214
- size={size}
215
- key={kind}
216
- />
185
+ <Button solid kind={kind} key={kind} active>
186
+ Action {kind}
187
+ </Button>
217
188
  ))}
218
189
  </Items>
219
- ))}
220
- <h3>Disabled</h3>
221
- <Items>
222
- <Button solid disabled>
223
- Action default
224
- </Button>
225
- {Object.values(BUTTON_KIND).map((kind) => (
226
- <Button solid kind={kind} key={kind} disabled>
227
- Action {kind}
228
- </Button>
190
+ <h3>With icon</h3>
191
+ {Object.values(BUTTON_SIZE).map((size) => (
192
+ <Items key={size}>
193
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size}>
194
+ Action default
195
+ </Button>
196
+ {Object.values(BUTTON_KIND).map((kind) => (
197
+ <Button
198
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
199
+ solid
200
+ kind={kind}
201
+ size={size}
202
+ key={kind}
203
+ >
204
+ Action {kind}
205
+ </Button>
206
+ ))}
207
+ </Items>
229
208
  ))}
230
- </Items>
209
+ <h3>Only icon</h3>
210
+ {Object.values(BUTTON_SIZE).map((size) => (
211
+ <Items key={size}>
212
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size} />
213
+ {Object.values(BUTTON_KIND).map((kind) => (
214
+ <Button
215
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
216
+ solid
217
+ kind={kind}
218
+ size={size}
219
+ key={kind}
220
+ />
221
+ ))}
222
+ </Items>
223
+ ))}
224
+ <h3>Disabled</h3>
225
+ <Items>
226
+ <Button solid disabled>
227
+ Action default
228
+ </Button>
229
+ {Object.values(BUTTON_KIND).map((kind) => (
230
+ <Button solid kind={kind} key={kind} disabled>
231
+ Action {kind}
232
+ </Button>
233
+ ))}
234
+ </Items>
235
+ </Stack>
231
236
  </Stack>
232
237
  </Stack>
233
- </Stack>
234
- );
238
+ ),
239
+ };
@@ -94,4 +94,11 @@ const ButtonComponent = <T extends React.ElementType = 'button'>(
94
94
  );
95
95
  };
96
96
 
97
- export const Button = React.forwardRef(ButtonComponent);
97
+ // React.forwardRef collapses ButtonComponent's generic `as` parameter down to
98
+ // its default ('button'), so cast back to a polymorphic signature to keep
99
+ // `as`/its associated element props (e.g. `href` with `as="a"`) type-checked.
100
+ export const Button = React.forwardRef(ButtonComponent) as <T extends React.ElementType = 'button'>(
101
+ props: ButtonProps<T> &
102
+ Omit<React.ComponentPropsWithoutRef<T>, keyof ButtonProps<T>> &
103
+ React.RefAttributes<Element>,
104
+ ) => React.ReactElement | null;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
2
3
 
3
4
  import { Container } from '.';
4
5
 
5
- export default {
6
+ const meta = {
6
7
  title: 'UI/Container',
7
8
  component: Container,
8
- };
9
+ } satisfies Meta<typeof Container>;
10
+
11
+ export default meta;
9
12
 
10
- export const Default = () => (
11
- <Container style={{ background: 'white' }}>
12
- <div
13
- style={{
14
- background: 'white',
15
- padding: '24px',
16
- }}
17
- >
18
- Content
19
- </div>
20
- </Container>
21
- );
13
+ type Story = StoryObj<typeof meta>;
22
14
 
23
- Default.decorators = [
24
- (Story: React.FunctionComponent) => (
25
- <div style={{ background: 'hotpink' }}>
26
- <Story />
27
- </div>
28
- ),
29
- ];
15
+ export const Default: Story = {
16
+ args: {
17
+ style: { background: 'white' },
18
+ children: (
19
+ <div
20
+ style={{
21
+ background: 'white',
22
+ padding: '24px',
23
+ }}
24
+ >
25
+ Content
26
+ </div>
27
+ ),
28
+ },
29
+ decorators: [
30
+ (Story) => (
31
+ <div style={{ background: 'hotpink' }}>
32
+ <Story />
33
+ </div>
34
+ ),
35
+ ],
36
+ };