@bundle-stats/ui 4.13.0-beta.0 → 4.13.0-beta.11

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 (217) hide show
  1. package/lib/app/app.js +4 -8
  2. package/lib/app/app.js.map +1 -1
  3. package/lib/app/app.module.css +2 -2
  4. package/lib/components/bundle-assets/bundle-assets.js +12 -5
  5. package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
  6. package/lib/components/bundle-assets/bundle-assets.module.css +0 -5
  7. package/lib/components/bundle-assets/index.js +2 -2
  8. package/lib/components/bundle-assets/index.js.map +1 -1
  9. package/lib/components/bundle-assets-totals/bundle-assets-totals.js +22 -11
  10. package/lib/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
  11. package/lib/components/bundle-modules/bundle-modules.js +22 -12
  12. package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
  13. package/lib/components/bundle-modules/bundle-modules.module.css +0 -5
  14. package/lib/components/bundle-modules/index.js +2 -2
  15. package/lib/components/bundle-modules/index.js.map +1 -1
  16. package/lib/components/bundle-packages/bundle-packages.js +10 -3
  17. package/lib/components/bundle-packages/bundle-packages.js.map +1 -1
  18. package/lib/components/bundle-packages/bundle-packages.module.css +0 -5
  19. package/lib/components/bundle-packages/index.js +2 -2
  20. package/lib/components/bundle-packages/index.js.map +1 -1
  21. package/lib/components/index.js +1 -3
  22. package/lib/components/index.js.map +1 -1
  23. package/lib/components/jobs-header/jobs-header.module.css +0 -4
  24. package/lib/components/metrics-display-selector/metrics-display-selector.js +4 -10
  25. package/lib/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
  26. package/lib/components/metrics-table/metrics-table.i18n.js +1 -6
  27. package/lib/components/metrics-table/metrics-table.i18n.js.map +1 -1
  28. package/lib/components/metrics-table/metrics-table.js +4 -37
  29. package/lib/components/metrics-table/metrics-table.js.map +1 -1
  30. package/lib/components/metrics-table/metrics-table.module.css +1 -44
  31. package/lib/components/{total-size-type-title → metrics-table-header}/index.js +1 -1
  32. package/lib/components/metrics-table-header/index.js.map +1 -0
  33. package/lib/components/metrics-table-header/metrics-table-header.i18n.js +9 -0
  34. package/lib/components/metrics-table-header/metrics-table-header.i18n.js.map +1 -0
  35. package/lib/components/metrics-table-header/metrics-table-header.js +79 -0
  36. package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -0
  37. package/lib/components/metrics-table-header/metrics-table-header.module.css +51 -0
  38. package/lib/components/metrics-table-options/metrics-table-options.js +2 -2
  39. package/lib/components/metrics-table-options/metrics-table-options.js.map +1 -1
  40. package/lib/components/metrics-table-title/metrics-table-title.js +1 -1
  41. package/lib/components/metrics-table-title/metrics-table-title.js.map +1 -1
  42. package/lib/components/metrics-table-title/metrics-table-title.module.css +4 -4
  43. package/lib/components/metrics-treemap/metrics-treemap.js +66 -51
  44. package/lib/components/metrics-treemap/metrics-treemap.js.map +1 -1
  45. package/lib/components/metrics-treemap/metrics-treemap.module.css +89 -56
  46. package/lib/components/sort-button/sort-button.module.css +1 -0
  47. package/lib/css/variables.css +14 -14
  48. package/lib/hooks/entry-info.js +12 -0
  49. package/lib/hooks/entry-info.js.map +1 -0
  50. package/lib/layout/flex-stack/flex-stack.js +3 -4
  51. package/lib/layout/flex-stack/flex-stack.js.map +1 -1
  52. package/lib/layout/flex-stack/flex-stack.module.css +19 -23
  53. package/lib/query-state.js +1 -1
  54. package/lib/query-state.js.map +1 -1
  55. package/lib/ui/button/button.js +5 -4
  56. package/lib/ui/button/button.js.map +1 -1
  57. package/lib/ui/button/button.module.css +55 -52
  58. package/lib/ui/dropdown/dropdown.js +10 -40
  59. package/lib/ui/dropdown/dropdown.js.map +1 -1
  60. package/lib/ui/dropdown/index.js.map +1 -1
  61. package/lib/ui/filters/filters.js +33 -35
  62. package/lib/ui/filters/filters.js.map +1 -1
  63. package/lib/ui/filters/filters.module.css +55 -67
  64. package/lib/ui/hover-card/hover-card.js +1 -1
  65. package/lib/ui/hover-card/hover-card.js.map +1 -1
  66. package/lib/ui/icon/icon.js +1 -1
  67. package/lib/ui/toolbar/toolbar.module.css +1 -3
  68. package/lib-esm/app/app.js +4 -8
  69. package/lib-esm/app/app.js.map +1 -1
  70. package/lib-esm/app/app.module.css +2 -2
  71. package/lib-esm/components/bundle-assets/bundle-assets.js +12 -5
  72. package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
  73. package/lib-esm/components/bundle-assets/bundle-assets.module.css +0 -5
  74. package/lib-esm/components/bundle-assets/index.js +3 -3
  75. package/lib-esm/components/bundle-assets/index.js.map +1 -1
  76. package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js +23 -12
  77. package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
  78. package/lib-esm/components/bundle-modules/bundle-modules.js +22 -12
  79. package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
  80. package/lib-esm/components/bundle-modules/bundle-modules.module.css +0 -5
  81. package/lib-esm/components/bundle-modules/index.js +2 -2
  82. package/lib-esm/components/bundle-modules/index.js.map +1 -1
  83. package/lib-esm/components/bundle-packages/bundle-packages.js +10 -3
  84. package/lib-esm/components/bundle-packages/bundle-packages.js.map +1 -1
  85. package/lib-esm/components/bundle-packages/bundle-packages.module.css +0 -5
  86. package/lib-esm/components/bundle-packages/index.js +3 -3
  87. package/lib-esm/components/bundle-packages/index.js.map +1 -1
  88. package/lib-esm/components/index.js +0 -1
  89. package/lib-esm/components/index.js.map +1 -1
  90. package/lib-esm/components/jobs-header/jobs-header.module.css +0 -4
  91. package/lib-esm/components/metrics-display-selector/metrics-display-selector.js +4 -10
  92. package/lib-esm/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
  93. package/lib-esm/components/metrics-table/metrics-table.i18n.js +0 -5
  94. package/lib-esm/components/metrics-table/metrics-table.i18n.js.map +1 -1
  95. package/lib-esm/components/metrics-table/metrics-table.js +4 -37
  96. package/lib-esm/components/metrics-table/metrics-table.js.map +1 -1
  97. package/lib-esm/components/metrics-table/metrics-table.module.css +1 -44
  98. package/lib-esm/components/metrics-table-header/index.js +2 -0
  99. package/lib-esm/components/metrics-table-header/index.js.map +1 -0
  100. package/lib-esm/components/metrics-table-header/metrics-table-header.i18n.js +6 -0
  101. package/lib-esm/components/metrics-table-header/metrics-table-header.i18n.js.map +1 -0
  102. package/lib-esm/components/metrics-table-header/metrics-table-header.js +49 -0
  103. package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -0
  104. package/lib-esm/components/metrics-table-header/metrics-table-header.module.css +51 -0
  105. package/lib-esm/components/metrics-table-options/metrics-table-options.js +3 -3
  106. package/lib-esm/components/metrics-table-options/metrics-table-options.js.map +1 -1
  107. package/lib-esm/components/metrics-table-title/metrics-table-title.js +1 -1
  108. package/lib-esm/components/metrics-table-title/metrics-table-title.js.map +1 -1
  109. package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +4 -4
  110. package/lib-esm/components/metrics-treemap/metrics-treemap.js +69 -53
  111. package/lib-esm/components/metrics-treemap/metrics-treemap.js.map +1 -1
  112. package/lib-esm/components/metrics-treemap/metrics-treemap.module.css +89 -56
  113. package/lib-esm/components/sort-button/sort-button.module.css +1 -0
  114. package/lib-esm/css/variables.css +14 -14
  115. package/lib-esm/hooks/entry-info.js +8 -0
  116. package/lib-esm/hooks/entry-info.js.map +1 -0
  117. package/lib-esm/layout/flex-stack/flex-stack.js +3 -4
  118. package/lib-esm/layout/flex-stack/flex-stack.js.map +1 -1
  119. package/lib-esm/layout/flex-stack/flex-stack.module.css +19 -23
  120. package/lib-esm/query-state.js +1 -1
  121. package/lib-esm/query-state.js.map +1 -1
  122. package/lib-esm/ui/button/button.js +5 -4
  123. package/lib-esm/ui/button/button.js.map +1 -1
  124. package/lib-esm/ui/button/button.module.css +55 -52
  125. package/lib-esm/ui/dropdown/dropdown.js +8 -39
  126. package/lib-esm/ui/dropdown/dropdown.js.map +1 -1
  127. package/lib-esm/ui/dropdown/index.js.map +1 -1
  128. package/lib-esm/ui/filters/filters.js +34 -36
  129. package/lib-esm/ui/filters/filters.js.map +1 -1
  130. package/lib-esm/ui/filters/filters.module.css +55 -67
  131. package/lib-esm/ui/hover-card/hover-card.js +1 -1
  132. package/lib-esm/ui/hover-card/hover-card.js.map +1 -1
  133. package/lib-esm/ui/icon/icon.js +1 -1
  134. package/lib-esm/ui/toolbar/toolbar.module.css +1 -3
  135. package/package.json +8 -10
  136. package/src/app/app.jsx +4 -12
  137. package/src/app/app.module.css +2 -2
  138. package/src/components/bundle-assets/bundle-assets.jsx +24 -7
  139. package/src/components/bundle-assets/bundle-assets.module.css +0 -5
  140. package/src/components/bundle-assets/index.jsx +8 -3
  141. package/src/components/bundle-assets-totals/bundle-assets-totals.jsx +55 -24
  142. package/src/components/bundle-modules/bundle-modules.module.css +0 -5
  143. package/src/components/bundle-modules/bundle-modules.tsx +60 -42
  144. package/src/components/bundle-modules/index.tsx +2 -2
  145. package/src/components/bundle-packages/bundle-packages.jsx +19 -5
  146. package/src/components/bundle-packages/bundle-packages.module.css +0 -5
  147. package/src/components/bundle-packages/index.jsx +8 -3
  148. package/src/components/index.js +0 -1
  149. package/src/components/jobs-header/jobs-header.module.css +0 -4
  150. package/src/components/metrics-display-selector/metrics-display-selector.tsx +8 -12
  151. package/src/components/metrics-table/metrics-table.i18n.ts +0 -7
  152. package/src/components/metrics-table/metrics-table.module.css +1 -44
  153. package/src/components/metrics-table/metrics-table.tsx +17 -153
  154. package/src/components/metrics-table-header/index.ts +1 -0
  155. package/src/components/metrics-table-header/metrics-table-header.i18n.ts +6 -0
  156. package/src/components/metrics-table-header/metrics-table-header.module.css +51 -0
  157. package/src/components/metrics-table-header/metrics-table-header.tsx +172 -0
  158. package/src/components/metrics-table-options/metrics-table-options.jsx +4 -10
  159. package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
  160. package/src/components/metrics-table-title/metrics-table-title.module.css +4 -4
  161. package/src/components/metrics-treemap/metrics-treemap.module.css +89 -56
  162. package/src/components/metrics-treemap/metrics-treemap.tsx +151 -118
  163. package/src/components/sort-button/sort-button.module.css +1 -0
  164. package/src/css/variables.css +14 -14
  165. package/src/hooks/entry-info.ts +19 -0
  166. package/src/layout/flex-stack/flex-stack.module.css +19 -23
  167. package/src/layout/flex-stack/flex-stack.tsx +2 -8
  168. package/src/query-state.tsx +1 -1
  169. package/src/ui/button/button.module.css +55 -52
  170. package/src/ui/button/button.stories.tsx +16 -9
  171. package/src/ui/button/button.tsx +8 -7
  172. package/src/ui/dropdown/dropdown.stories.tsx +25 -0
  173. package/src/ui/dropdown/dropdown.tsx +66 -0
  174. package/src/ui/filters/filters.module.css +55 -67
  175. package/src/ui/filters/filters.stories.tsx +109 -0
  176. package/src/ui/filters/filters.tsx +128 -167
  177. package/src/ui/hover-card/hover-card.tsx +1 -1
  178. package/src/ui/icon/icon.tsx +1 -1
  179. package/src/ui/toolbar/toolbar.module.css +1 -3
  180. package/types/components/bundle-assets-totals/bundle-assets-totals.d.ts +5 -1
  181. package/types/components/index.d.ts +0 -1
  182. package/types/components/metrics-display-selector/metrics-display-selector.d.ts +2 -2
  183. package/types/components/metrics-table/metrics-table.d.ts +4 -10
  184. package/types/components/metrics-table/metrics-table.i18n.d.ts +0 -5
  185. package/types/components/metrics-table-header/index.d.ts +1 -0
  186. package/types/components/metrics-table-header/metrics-table-header.d.ts +15 -0
  187. package/types/components/metrics-table-header/metrics-table-header.i18n.d.ts +5 -0
  188. package/types/hooks/entry-info.d.ts +8 -0
  189. package/types/ui/dropdown/dropdown.d.ts +12 -47
  190. package/types/ui/dropdown/index.d.ts +1 -1
  191. package/types/ui/filters/filters.d.ts +2 -7
  192. package/types/ui/icon/icon.d.ts +2 -2
  193. package/lib/components/bundle-assets-totals/bundle-assets-totals.module.css +0 -7
  194. package/lib/components/total-size-type-title/index.js.map +0 -1
  195. package/lib/components/total-size-type-title/total-size-type-title.js +0 -32
  196. package/lib/components/total-size-type-title/total-size-type-title.js.map +0 -1
  197. package/lib/components/total-size-type-title/total-size-type-title.module.css +0 -14
  198. package/lib/hooks/show-entry.js +0 -13
  199. package/lib/hooks/show-entry.js.map +0 -1
  200. package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.module.css +0 -7
  201. package/lib-esm/components/total-size-type-title/index.js +0 -2
  202. package/lib-esm/components/total-size-type-title/index.js.map +0 -1
  203. package/lib-esm/components/total-size-type-title/total-size-type-title.js +0 -25
  204. package/lib-esm/components/total-size-type-title/total-size-type-title.js.map +0 -1
  205. package/lib-esm/components/total-size-type-title/total-size-type-title.module.css +0 -14
  206. package/lib-esm/hooks/show-entry.js +0 -9
  207. package/lib-esm/hooks/show-entry.js.map +0 -1
  208. package/src/components/bundle-assets-totals/bundle-assets-totals.module.css +0 -7
  209. package/src/components/total-size-type-title/index.js +0 -1
  210. package/src/components/total-size-type-title/total-size-type-title.jsx +0 -41
  211. package/src/components/total-size-type-title/total-size-type-title.module.css +0 -14
  212. package/src/hooks/show-entry.ts +0 -17
  213. package/src/ui/dropdown/dropdown.jsx +0 -88
  214. package/types/components/total-size-type-title/index.d.ts +0 -1
  215. package/types/components/total-size-type-title/total-size-type-title.d.ts +0 -14
  216. package/types/hooks/show-entry.d.ts +0 -10
  217. /package/src/ui/dropdown/{index.js → index.ts} +0 -0
@@ -1,48 +1,44 @@
1
1
  .root {
2
2
  display: flex;
3
- align-items: stretch;
4
3
  justify-content: flex-start;
5
- }
6
-
7
- .root > .item:last-child {
8
- margin-right: 0;
4
+ gap: 0;
9
5
  }
10
6
 
11
7
  /** Space variation */
12
- .space--xxxsmall > .item {
13
- margin: 0 var(--space-xxxsmall) 0 0;
8
+ .space--xxxsmall {
9
+ gap: var(--space-xxxsmall);
14
10
  }
15
11
 
16
- .space--xxsmall > .item {
17
- margin: 0 var(--space-xxsmall) 0 0;
12
+ .space--xxsmall {
13
+ gap: var(--space-xxsmall);
18
14
  }
19
15
 
20
- .space--xsmall > .item {
21
- margin: 0 var(--space-xsmall) 0 0;
16
+ .space--xsmall {
17
+ gap: var(--space-xsmall);
22
18
  }
23
19
 
24
- .space--small > .item {
25
- margin: 0 var(--space-small) 0 0;
20
+ .space--small {
21
+ gap: var(--space-small);
26
22
  }
27
23
 
28
- .space--medium > .item {
29
- margin: 0 var(--space-medium) 0 0;
24
+ .space--medium {
25
+ gap: var(--space-medium);
30
26
  }
31
27
 
32
- .space--large > .item {
33
- margin: 0 var(--space-large) 0 0;
28
+ .space--large {
29
+ gap: var(--space-large);
34
30
  }
35
31
 
36
- .space--xlarge > .item {
37
- margin: 0 var(--space-xlarge) 0 0;
32
+ .space--xlarge {
33
+ gap: var(--space-xlarge);
38
34
  }
39
35
 
40
- .space--xxlarge > .item {
41
- margin: 0 var(--space-xxlarge) 0 0;
36
+ .space--xxlarge {
37
+ gap: var(--space-xxlarge);
42
38
  }
43
39
 
44
- .space--xxxlarge > .item {
45
- margin: 0 var(--space-xxxlarge) 0 0;
40
+ .space--xxxlarge {
41
+ gap: var(--space-xxxlarge);
46
42
  }
47
43
 
48
44
  /** Align items variation */
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import cx from 'classnames';
3
3
 
4
4
  import { NO_SPACE, SPACES } from '../../tokens';
5
- import { getRenderChildWithClassName } from '../../utils';
6
5
  import css from './flex-stack.module.css';
7
6
 
8
7
  type SpaceValue = (typeof SPACES)[number];
@@ -22,22 +21,17 @@ export const FlexStack = <T extends React.ElementType = 'div'>(
22
21
  className = '',
23
22
  space = NO_SPACE,
24
23
  inline = false,
25
- children = null,
26
24
  alignItems = '',
27
25
  ...restProps
28
26
  } = props;
29
27
 
30
28
  const rootClassName = cx(
31
- className,
32
29
  css.root,
33
30
  css[`space--${space}`],
34
31
  css[`align-items--${alignItems}`],
35
32
  inline && css.inline,
33
+ className,
36
34
  );
37
35
 
38
- return (
39
- <Component {...restProps} className={rootClassName}>
40
- {React.Children.map(children, getRenderChildWithClassName(css.item))}
41
- </Component>
42
- );
36
+ return <Component {...restProps} className={rootClassName} />;
43
37
  };
@@ -30,7 +30,7 @@ export const useComponentQueryState = (componentName: string) => {
30
30
 
31
31
  setQueryState({ [componentName]: newState });
32
32
  },
33
- [componentState],
33
+ [componentState, setQueryState],
34
34
  );
35
35
 
36
36
  return [componentState, setState];
@@ -1,14 +1,21 @@
1
1
  .root {
2
+ /* use for vertical padding and to compute gap and horizontal spacing */
3
+ --button-space: 0px;
4
+ /* button border width */
5
+ --border-width: 0px;
6
+
2
7
  display: inline-flex;
3
8
  align-items: center;
4
- gap: var(--space-xxsmall);
9
+ justify-content: center;
10
+ gap: calc(max(var(--button-space), var(--space-xxsmall)) * 0.66);
5
11
  appearance: none;
6
12
  padding: 0;
7
- border: 0;
13
+ border: var(--border-width) solid transparent;
8
14
  background: none;
9
15
  transition: var(--transition-out);
10
16
  color: var(--color-text-ultra-light);
11
17
  font-family: var(--font-family);
18
+ white-space: nowrap;
12
19
  }
13
20
 
14
21
  a.root {
@@ -18,6 +25,7 @@ a.root {
18
25
  .root:hover,
19
26
  .root:active,
20
27
  .root:focus {
28
+ outline: none;
21
29
  color: var(--color-text-light);
22
30
  transition: var(--transition-in);
23
31
  }
@@ -98,7 +106,7 @@ a.root {
98
106
  * Solid Kind variation
99
107
  */
100
108
  .solid {
101
- background: var(--color-text-light);
109
+ background: var(--color-text-ultra-light);
102
110
  color: var(--color-background);
103
111
  }
104
112
 
@@ -106,7 +114,7 @@ a.root {
106
114
  .solid:active,
107
115
  .solid:focus {
108
116
  box-shadow: var(--outline-hover);
109
- background: var(--color-text);
117
+ background: var(--color-text-light);
110
118
  color: var(--color-background);
111
119
  }
112
120
 
@@ -170,11 +178,51 @@ a.root {
170
178
  background: var(--color-success-dark);
171
179
  }
172
180
 
181
+ /**
182
+ * Size variation
183
+ */
184
+ .small {
185
+ --button-space: var(--space-xxsmall);
186
+
187
+ font-size: var(--size-small);
188
+ line-height: var(--space-small);
189
+ }
190
+
191
+ .small .glyph {
192
+ width: var(--space-small);
193
+ height: var(--space-small);
194
+ }
195
+
196
+ .medium {
197
+ --button-space: var(--space-xsmall);
198
+
199
+ font-size: var(--size-medium);
200
+ line-height: calc(var(--space-small) + var(--space-xxxsmall));
201
+ }
202
+
203
+ .medium .glyph {
204
+ width: calc(var(--space-small) + var(--space-xxxsmall));
205
+ height: calc(var(--space-small) + var(--space-xxxsmall));
206
+ }
207
+
208
+ .large {
209
+ --button-space: var(--space-small);
210
+
211
+ font-size: var(--size-large);
212
+ line-height: var(--space-medium);
213
+ }
214
+
215
+ .large .glyph {
216
+ width: var(--space-medium);
217
+ height: var(--space-medium);
218
+ }
219
+
173
220
  /**
174
221
  * Outline variation
175
222
  */
176
223
  .outline {
177
- border: 1px solid var(--color-outline);
224
+ --border-width: 1px;
225
+ border-color: var(--color-outline);
178
226
  }
179
227
 
180
228
  .outline:hover,
@@ -244,57 +292,12 @@ a.root {
244
292
  border-color: var(--color-outline-success-dark);
245
293
  }
246
294
 
247
- /**
248
- * Size variation
249
- */
250
- .small {
251
- font-size: var(--size-small);
252
- gap: var(--space-xxxsmall);
253
- line-height: var(--space-small);
254
- }
255
-
256
- .small .glyph {
257
- width: calc(var(--space-xsmall) + 2px);
258
- height: calc(var(--space-xsmall) + 2px);
259
- }
260
-
261
- .medium {
262
- font-size: var(--size-medium);
263
- gap: var(--space-xxsmall);
264
- line-height: var(--space-small);
265
- }
266
-
267
- .large {
268
- font-size: var(--size-large);
269
- gap: var(--space-xxsmall);
270
- line-height: var(--space-small);
271
- }
272
295
 
273
296
  /**
274
297
  * Padding variation
275
298
  */
276
- .padding--small {
277
- padding: var(--space-xxsmall);
278
- }
279
-
280
- .outline--padding--small {
281
- padding: calc(var(--space-xxsmall) - 1px);
282
- }
283
-
284
- .padding--medium {
285
- padding: var(--space-xsmall);
286
- }
287
-
288
- .outline--padding--medium {
289
- padding: calc(var(--space-xsmall) - 1px);
290
- }
291
-
292
- .padding--large {
293
- padding: var(--space-small);
294
- }
295
-
296
- .outline--padding--large {
297
- padding: calc(var(--space-small) - 1px);
299
+ .padding {
300
+ padding: calc(var(--button-space) - var(--border-width));
298
301
  }
299
302
 
300
303
  /**
@@ -62,7 +62,14 @@ export const All = () => (
62
62
  <h3>With icon</h3>
63
63
  <Items>
64
64
  {Object.values(BUTTON_KIND).map((kind) => (
65
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} kind={kind} key={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}>
66
73
  Action {kind}
67
74
  </Button>
68
75
  ))}
@@ -106,12 +113,12 @@ export const All = () => (
106
113
  <h3>With icon</h3>
107
114
  {Object.values(BUTTON_SIZE).map((size) => (
108
115
  <Items key={size}>
109
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} outline size={size}>
116
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size}>
110
117
  Action default
111
118
  </Button>
112
119
  {Object.values(BUTTON_KIND).map((kind) => (
113
120
  <Button
114
- glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE}
121
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
115
122
  outline
116
123
  kind={kind}
117
124
  size={size}
@@ -125,10 +132,10 @@ export const All = () => (
125
132
  <h3>Only icon</h3>
126
133
  {Object.values(BUTTON_SIZE).map((size) => (
127
134
  <Items key={size}>
128
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} outline size={size} />
135
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} outline size={size} />
129
136
  {Object.values(BUTTON_KIND).map((kind) => (
130
137
  <Button
131
- glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE}
138
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
132
139
  outline
133
140
  kind={kind}
134
141
  size={size}
@@ -179,12 +186,12 @@ export const All = () => (
179
186
  <h3>With icon</h3>
180
187
  {Object.values(BUTTON_SIZE).map((size) => (
181
188
  <Items key={size}>
182
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} solid size={size}>
189
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size}>
183
190
  Action default
184
191
  </Button>
185
192
  {Object.values(BUTTON_KIND).map((kind) => (
186
193
  <Button
187
- glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE}
194
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
188
195
  solid
189
196
  kind={kind}
190
197
  size={size}
@@ -198,10 +205,10 @@ export const All = () => (
198
205
  <h3>Only icon</h3>
199
206
  {Object.values(BUTTON_SIZE).map((size) => (
200
207
  <Items key={size}>
201
- <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} solid size={size} />
208
+ <Button glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE} solid size={size} />
202
209
  {Object.values(BUTTON_KIND).map((kind) => (
203
210
  <Button
204
- glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE}
211
+ glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
205
212
  solid
206
213
  kind={kind}
207
214
  size={size}
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+
2
3
  import cx from 'classnames';
3
4
  import { Button as ButtonBaseComponent } from 'ariakit/button';
4
5
 
@@ -50,7 +51,7 @@ const ButtonComponent = <T extends React.ElementType = 'button'>(
50
51
  radius = '',
51
52
  padding = '',
52
53
  as: Component = ButtonBaseComponent,
53
- children,
54
+ children = null,
54
55
  Icon = BaseIcon,
55
56
  glyph,
56
57
  rightGlyph,
@@ -61,10 +62,12 @@ const ButtonComponent = <T extends React.ElementType = 'button'>(
61
62
  const resolvedPadding = padding || ((outline || solid) && size);
62
63
  const resolvedRadius = radius || ((outline || solid) && size);
63
64
 
65
+ const resolvedSize = Object.values(BUTTON_SIZE).includes(size) ? size : BUTTON_SIZE.MEDIUM;
66
+
64
67
  const rootClassName = cx(
65
68
  css.root,
66
- css[size],
67
69
  kind && css[kind],
70
+ css[resolvedSize],
68
71
 
69
72
  outline && css.outline,
70
73
  outline && css[`outline--${kind}`],
@@ -72,22 +75,20 @@ const ButtonComponent = <T extends React.ElementType = 'button'>(
72
75
  solid && css.solid,
73
76
  solid && css[`solid--${kind}`],
74
77
 
75
- resolvedPadding && css[`padding--${resolvedPadding}`],
76
- resolvedPadding && outline && css[`outline--padding--${resolvedPadding}`],
78
+ resolvedPadding && css.padding,
77
79
  resolvedRadius && css[`radius--${resolvedRadius}`],
78
80
 
79
81
  active && css.active,
80
82
  active && outline && css[`active-outline-${kind}`],
81
83
 
82
- css[size],
83
84
  className,
84
85
  );
85
86
 
86
87
  return (
87
88
  <Component {...restProps} className={rootClassName}>
88
- {glyph && <Icon glyph={glyph} size={size} className={css.glyph} />}
89
+ {glyph && <Icon glyph={glyph} className={css.glyph} />}
89
90
  {children && <span className={css.content}>{children}</span>}
90
- {rightGlyph && <Icon glyph={glyph} size={size} className={css.glyph} />}
91
+ {rightGlyph && <Icon glyph={rightGlyph} className={css.glyph} />}
91
92
  </Component>
92
93
  );
93
94
  };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { Meta } from '@storybook/react';
3
+
4
+ import { getWrapperDecorator } from '../../stories';
5
+ import { Dropdown, DropdownItem } from '.';
6
+
7
+ export default {
8
+ title: 'UI/Dropdown',
9
+ component: Dropdown,
10
+ decorators: [getWrapperDecorator()],
11
+ } as Meta;
12
+
13
+ export const Defualt = () => (
14
+ <Dropdown glyph="filter" label="Toggle">
15
+ <DropdownItem>Option 1</DropdownItem>
16
+ <DropdownItem>Option 2</DropdownItem>
17
+ </Dropdown>
18
+ );
19
+
20
+ export const Disabled = () => (
21
+ <Dropdown glyph="filter" label="Toggle" disabled>
22
+ <DropdownItem>Option 1</DropdownItem>
23
+ <DropdownItem>Option 2</DropdownItem>
24
+ </Dropdown>
25
+ );
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
4
+
5
+ import { Button, BUTTON_SIZE } from '../button';
6
+ import css from './dropdown.module.css';
7
+
8
+ interface DropdownItemProps {
9
+ isActive?: boolean;
10
+ }
11
+
12
+ export const DropdownItem = (props: DropdownItemProps & React.ComponentProps<typeof MenuItem>) => {
13
+ const { className = '', isActive = false, ...restProps } = props;
14
+
15
+ return (
16
+ <MenuItem className={cx(css.item, className, isActive && css.itemActive)} {...restProps} />
17
+ );
18
+ };
19
+
20
+ interface DropdownProps {
21
+ dropdownClassName?: string;
22
+ label?: React.ReactNode;
23
+ ariaLabel?: string;
24
+ glyph?: string;
25
+ disabled?: boolean;
26
+ }
27
+
28
+ export const Dropdown = (props: DropdownProps & React.ComponentProps<'div'>) => {
29
+ const {
30
+ className = '',
31
+ dropdownClassName = '',
32
+ label = null,
33
+ ariaLabel = '',
34
+ glyph = '',
35
+ disabled = false,
36
+ children,
37
+ } = props;
38
+
39
+ const dropdownAriaLabel = ariaLabel || (typeof label === 'string' ? label : '');
40
+ const menuState = useMenuState();
41
+
42
+ return (
43
+ <>
44
+ <MenuButton
45
+ as={Button}
46
+ outline
47
+ size={BUTTON_SIZE.SMALL}
48
+ glyph={glyph}
49
+ disabled={disabled}
50
+ state={menuState}
51
+ tabIndex={null}
52
+ className={cx(css.button, className)}
53
+ >
54
+ {label}
55
+ </MenuButton>
56
+ <Menu
57
+ portal
58
+ state={menuState}
59
+ aria-label={dropdownAriaLabel}
60
+ className={cx(css.dropdown, dropdownClassName)}
61
+ >
62
+ {children}
63
+ </Menu>
64
+ </>
65
+ );
66
+ };
@@ -1,18 +1,19 @@
1
- /* Checkbox + label + button */
2
- .filter {
3
- /* Update MenuItem padding */
4
- padding-top: calc(var(--space-xxxsmall) / 2);
5
- padding-bottom: calc(var(--space-xxxsmall) / 2);
1
+ /* explicit ControlGroup last item styles to override ariakit injected sibling nodes */
2
+ .itemLast {
3
+ border-top-right-radius: var(--radius-small) !important;
4
+ border-bottom-right-radius: var(--radius-small) !important;
5
+ }
6
6
 
7
+ /* Filter (label with input + text) */
8
+ .filter {
7
9
  position: relative;
8
10
  width: 100%;
9
11
  max-width: 240px;
12
+ color: var(--color-text);
10
13
  }
11
14
 
12
- .filterCheckbox {
13
- }
14
-
15
- .filterInput {
15
+ .filterControl {
16
+ margin: 0;
16
17
  flex: 0 0 auto;
17
18
  height: 1em;
18
19
  }
@@ -25,7 +26,47 @@
25
26
  text-overflow: ellipsis;
26
27
  }
27
28
 
28
- .filterOnlyButton {
29
+ .filterControl[disabled] + .filterLabel {
30
+ color: var(--color-text-light);
31
+ }
32
+
33
+ .filter:hover {
34
+ color: var(--color-dark);
35
+ }
36
+
37
+ /** Filter single */
38
+ .filterSingle {
39
+ padding: calc(var(--space-xxsmall) - 1px);
40
+ border: 1px solid var(--color-outline);
41
+ border-radius: var(--radius-small);
42
+ font-size: var(--size-small);
43
+ line-height: var(--space-small);
44
+ color: var(--color-text-ultra-light);
45
+ transition: var(--transition-out);
46
+ }
47
+
48
+ .filterSingle:hover,
49
+ .filterSingle:active,
50
+ .filterSingle:focus {
51
+ border-color: var(--color-outline-dark);
52
+ transition: var(--transition-in);
53
+ }
54
+
55
+ /** Filter group */
56
+ .filterGroupItems {
57
+ max-height: calc(10 * (var(--space-small) + 2 * var(--space-xxxsmall)));
58
+ overflow: auto;
59
+ }
60
+
61
+ .filterGroupItem {
62
+ position: relative;
63
+ }
64
+
65
+ .filterGroupItemFilter {
66
+ padding-right: 24px; /* space for only button */
67
+ }
68
+
69
+ .filterGroupOnlyButton {
29
70
  display: none;
30
71
  position: absolute;
31
72
  right: 2px;
@@ -37,10 +78,11 @@
37
78
  }
38
79
 
39
80
  /** cover item text */
40
- .filterOnlyButton::before {
81
+ .filterGroupOnlyButton::before {
41
82
  content: ' ';
42
83
  display: block;
43
84
  position: absolute;
85
+ pointer-events: none;
44
86
  top: 0;
45
87
  right: 100%;
46
88
  bottom: 0;
@@ -48,53 +90,13 @@
48
90
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-highlight) 75%);
49
91
  }
50
92
 
51
- /** filter disabled state */
52
- .filterInput[disabled] + .filterLabel {
53
- color: var(--color-text-light);
54
- }
55
-
56
- .filterInput[disabled] + .filterOnlyButton {
57
- display: none;
58
- }
59
-
60
93
  /** filter hover state */
61
- .filter {
62
- color: var(--color-text);
63
- }
64
-
65
- .filter:hover {
66
- color: var(--color-dark);
67
- }
68
-
69
- .filter:hover .filterOnlyButton {
94
+ .filterGroupItem:hover .filterGroupOnlyButton {
70
95
  display: block;
71
96
  }
72
97
 
73
- /** Filter standard variation */
74
- .filterStandalone {
75
- padding: 0;
76
- width: auto;
77
- color: var(--color-text-light);
78
- z-index: var(--layout-xlow); /* show collapsed border */
79
- font-size: var(--size-small);
80
- line-height: var(--space-small);
81
- }
82
-
83
- .filterStandalone .filterCheckbox {
84
- padding: calc(var(--space-xxsmall) - 1px) calc(var(--space-xxsmall) - 1px);
85
- border: 1px solid var(--color-outline);
86
- }
87
-
88
- .filterStandalone:hover .filterCheckbox,
89
- .filterStandalone:active .filterCheckbox,
90
- .filterStandalone:focus .filterCheckbox {
91
- z-index: var(--layout-xlow); /* show collapsed border */
92
- box-shadow: var(--outline-hover);
93
- color: var(--color-text);
94
- }
95
-
96
98
  /** Filter group variation */
97
- .labelSuffixCustom {
99
+ .filterGroupLabelSuffixCustom {
98
100
  color: var(--color-text);
99
101
  text-transform: lowercase;
100
102
  }
@@ -112,11 +114,6 @@
112
114
  color: var(--color-text-light);
113
115
  }
114
116
 
115
- .filterGroupItems {
116
- max-height: calc(10 * (var(--space-small) + 2 * var(--space-xxxsmall)));
117
- overflow: auto;
118
- }
119
-
120
117
  .filterGroupActions {
121
118
  margin-top: var(--space-xxxsmall);
122
119
  padding-top: var(--space-xxxsmall);
@@ -124,12 +121,3 @@
124
121
  margin-bottom: calc(0px - var(--space-xxxsmall));
125
122
  border-top: 1px solid var(--color-outline);
126
123
  }
127
-
128
- .item {
129
- position: relative;
130
- flex: 0 0 auto;
131
- }
132
-
133
- .itemButton {
134
- border-radius: var(--radius-small);
135
- }