@bundle-stats/ui 3.3.0-alpha.1 → 3.4.0-alpha.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 (178) hide show
  1. package/CHANGELOG.md +94 -13
  2. package/lib/app/app.js +137 -102
  3. package/lib/app/app.module.css +11 -4
  4. package/lib/app/header/header.js +1 -10
  5. package/lib/components/asset-info/asset-info.module.css +1 -0
  6. package/lib/components/bundle-assets/bundle-assets.js +104 -52
  7. package/lib/components/bundle-assets/bundle-assets.module.css +24 -26
  8. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +13 -3
  9. package/lib/components/bundle-modules/bundle-modules.js +53 -67
  10. package/lib/components/bundle-packages/bundle-packages.js +100 -44
  11. package/lib/components/bundle-packages/bundle-packages.module.css +17 -21
  12. package/lib/components/delta/delta.module.css +1 -0
  13. package/lib/components/job-header/job-header.js +3 -1
  14. package/lib/components/job-header/job-header.module.css +6 -8
  15. package/lib/components/jobs-header/jobs-header.module.css +5 -0
  16. package/lib/components/metrics-table/metrics-table.js +72 -59
  17. package/lib/components/metrics-table/metrics-table.module.css +18 -7
  18. package/lib/components/metrics-table-search/metrics-table-search.module.css +5 -4
  19. package/lib/components/metrics-table-title/metrics-table-title.js +9 -7
  20. package/lib/components/metrics-table-title/metrics-table-title.module.css +2 -0
  21. package/lib/components/module-info/module-info.js +2 -2
  22. package/lib/components/module-info/module-info.module.css +1 -0
  23. package/lib/components/summary/summary.js +1 -1
  24. package/lib/components/summary-item/summary-item.js +15 -18
  25. package/lib/components/summary-item/summary-item.module.css +1 -23
  26. package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
  27. package/lib/css/default.css +14 -3
  28. package/lib/css/variables.css +17 -17
  29. package/lib/hooks/search-params.js +31 -31
  30. package/lib/layout/box/box.module.css +9 -0
  31. package/lib/layout/footer/footer.module.css +1 -1
  32. package/lib/layout/index.js +8 -0
  33. package/lib/layout/separator.js +48 -0
  34. package/lib/layout/separator.module.css +5 -0
  35. package/lib/ui/dropdown/dropdown.js +21 -26
  36. package/lib/ui/dropdown/dropdown.module.css +11 -12
  37. package/lib/ui/dropdown/dropdown.stories.js +2 -9
  38. package/lib/ui/empty-set/empty-set.js +5 -4
  39. package/lib/ui/empty-set/empty-set.module.css +2 -2
  40. package/lib/ui/filters/filters.container.js +1 -1
  41. package/lib/ui/filters/filters.js +22 -7
  42. package/lib/ui/filters/filters.module.css +3 -3
  43. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +1 -1
  44. package/lib/ui/hover-card/hover-card.js +102 -0
  45. package/lib/ui/hover-card/hover-card.module.css +29 -0
  46. package/lib/ui/hover-card/hover-card.stories.js +56 -0
  47. package/lib/ui/hover-card/index.js +18 -0
  48. package/lib/ui/icon/icon.js +6 -6
  49. package/lib/ui/icon/icon.module.css +1 -0
  50. package/lib/ui/index.js +8 -8
  51. package/lib/ui/table/table.js +5 -74
  52. package/lib/ui/table/table.module.css +41 -25
  53. package/lib/ui/table/table.stories.js +1 -1
  54. package/lib/ui/{popover → tag}/index.js +4 -4
  55. package/lib/ui/tag/tag.js +72 -0
  56. package/lib/ui/tag/tag.module.css +55 -0
  57. package/lib/ui/tag/tag.stories.js +38 -0
  58. package/lib/ui/tooltip/tooltip.js +10 -9
  59. package/lib/ui/tooltip/tooltip.module.css +2 -1
  60. package/lib-esm/app/app.js +132 -102
  61. package/lib-esm/app/app.module.css +11 -4
  62. package/lib-esm/app/header/header.js +1 -9
  63. package/lib-esm/components/asset-info/asset-info.module.css +1 -0
  64. package/lib-esm/components/bundle-assets/bundle-assets.js +97 -56
  65. package/lib-esm/components/bundle-assets/bundle-assets.module.css +24 -26
  66. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +7 -3
  67. package/lib-esm/components/bundle-modules/bundle-modules.js +35 -50
  68. package/lib-esm/components/bundle-packages/bundle-packages.js +88 -41
  69. package/lib-esm/components/bundle-packages/bundle-packages.module.css +17 -21
  70. package/lib-esm/components/delta/delta.module.css +1 -0
  71. package/lib-esm/components/job-header/job-header.js +2 -1
  72. package/lib-esm/components/job-header/job-header.module.css +6 -8
  73. package/lib-esm/components/jobs-header/jobs-header.module.css +5 -0
  74. package/lib-esm/components/metrics-table/metrics-table.js +61 -53
  75. package/lib-esm/components/metrics-table/metrics-table.module.css +18 -7
  76. package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +5 -4
  77. package/lib-esm/components/metrics-table-title/metrics-table-title.js +8 -7
  78. package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +2 -0
  79. package/lib-esm/components/module-info/module-info.js +2 -2
  80. package/lib-esm/components/module-info/module-info.module.css +1 -0
  81. package/lib-esm/components/summary/summary.js +1 -1
  82. package/lib-esm/components/summary-item/summary-item.js +14 -18
  83. package/lib-esm/components/summary-item/summary-item.module.css +1 -23
  84. package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
  85. package/lib-esm/css/default.css +14 -3
  86. package/lib-esm/css/variables.css +17 -17
  87. package/lib-esm/hooks/search-params.js +27 -28
  88. package/lib-esm/layout/box/box.module.css +9 -0
  89. package/lib-esm/layout/footer/footer.module.css +1 -1
  90. package/lib-esm/layout/index.js +1 -0
  91. package/lib-esm/layout/separator.js +28 -0
  92. package/lib-esm/layout/separator.module.css +5 -0
  93. package/lib-esm/ui/dropdown/dropdown.js +20 -25
  94. package/lib-esm/ui/dropdown/dropdown.module.css +11 -12
  95. package/lib-esm/ui/dropdown/dropdown.stories.js +2 -7
  96. package/lib-esm/ui/empty-set/empty-set.js +4 -4
  97. package/lib-esm/ui/empty-set/empty-set.module.css +2 -2
  98. package/lib-esm/ui/filters/filters.js +20 -5
  99. package/lib-esm/ui/filters/filters.module.css +3 -3
  100. package/lib-esm/ui/hover-card/hover-card.js +83 -0
  101. package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
  102. package/lib-esm/ui/hover-card/hover-card.stories.js +35 -0
  103. package/lib-esm/ui/hover-card/index.js +1 -0
  104. package/lib-esm/ui/icon/icon.js +3 -3
  105. package/lib-esm/ui/icon/icon.module.css +1 -0
  106. package/lib-esm/ui/index.js +1 -1
  107. package/lib-esm/ui/table/table.js +5 -65
  108. package/lib-esm/ui/table/table.module.css +41 -25
  109. package/lib-esm/ui/table/table.stories.js +1 -1
  110. package/lib-esm/ui/tag/index.js +1 -0
  111. package/lib-esm/ui/tag/tag.js +45 -0
  112. package/lib-esm/ui/tag/tag.module.css +55 -0
  113. package/lib-esm/ui/tag/tag.stories.js +23 -0
  114. package/lib-esm/ui/tooltip/tooltip.js +10 -9
  115. package/lib-esm/ui/tooltip/tooltip.module.css +2 -1
  116. package/package.json +33 -31
  117. package/src/app/app.jsx +142 -145
  118. package/src/app/app.module.css +11 -4
  119. package/src/app/header/header.jsx +0 -10
  120. package/src/components/asset-info/asset-info.module.css +1 -0
  121. package/src/components/bundle-assets/bundle-assets.jsx +85 -31
  122. package/src/components/bundle-assets/bundle-assets.module.css +24 -26
  123. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +2 -0
  124. package/src/components/bundle-modules/bundle-modules.jsx +36 -36
  125. package/src/components/bundle-packages/bundle-packages.jsx +89 -39
  126. package/src/components/bundle-packages/bundle-packages.module.css +17 -21
  127. package/src/components/delta/delta.module.css +1 -0
  128. package/src/components/job-header/job-header.jsx +2 -1
  129. package/src/components/job-header/job-header.module.css +6 -8
  130. package/src/components/jobs-header/jobs-header.module.css +5 -0
  131. package/src/components/metrics-table/metrics-table.jsx +53 -44
  132. package/src/components/metrics-table/metrics-table.module.css +18 -7
  133. package/src/components/metrics-table-search/metrics-table-search.module.css +5 -4
  134. package/src/components/metrics-table-title/metrics-table-title.jsx +20 -21
  135. package/src/components/metrics-table-title/metrics-table-title.module.css +2 -0
  136. package/src/components/module-info/module-info.jsx +3 -7
  137. package/src/components/module-info/module-info.module.css +1 -0
  138. package/src/components/summary/summary.jsx +1 -1
  139. package/src/components/summary-item/summary-item.jsx +21 -27
  140. package/src/components/summary-item/summary-item.module.css +1 -23
  141. package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
  142. package/src/css/default.css +14 -3
  143. package/src/css/variables.css +17 -17
  144. package/src/hooks/search-params.js +42 -33
  145. package/src/layout/box/box.module.css +9 -0
  146. package/src/layout/footer/footer.module.css +1 -1
  147. package/src/layout/index.js +1 -0
  148. package/src/layout/separator.jsx +25 -0
  149. package/src/layout/separator.module.css +5 -0
  150. package/src/ui/dropdown/dropdown.jsx +16 -22
  151. package/src/ui/dropdown/dropdown.module.css +11 -12
  152. package/src/ui/empty-set/empty-set.jsx +25 -21
  153. package/src/ui/empty-set/empty-set.module.css +2 -2
  154. package/src/ui/filters/filters.jsx +64 -53
  155. package/src/ui/filters/filters.module.css +3 -3
  156. package/src/ui/hover-card/hover-card.jsx +73 -0
  157. package/src/ui/hover-card/hover-card.module.css +29 -0
  158. package/src/ui/hover-card/index.js +1 -0
  159. package/src/ui/icon/icon.jsx +11 -7
  160. package/src/ui/icon/icon.module.css +1 -0
  161. package/src/ui/index.js +1 -1
  162. package/src/ui/table/table.jsx +5 -52
  163. package/src/ui/table/table.module.css +41 -25
  164. package/src/ui/tag/index.js +1 -0
  165. package/src/ui/tag/tag.jsx +49 -0
  166. package/src/ui/tag/tag.module.css +55 -0
  167. package/src/ui/tooltip/tooltip.jsx +10 -14
  168. package/src/ui/tooltip/tooltip.module.css +2 -1
  169. package/lib/ui/popover/popover.js +0 -92
  170. package/lib/ui/popover/popover.module.css +0 -66
  171. package/lib/ui/popover/popover.stories.js +0 -26
  172. package/lib-esm/ui/popover/index.js +0 -1
  173. package/lib-esm/ui/popover/popover.js +0 -71
  174. package/lib-esm/ui/popover/popover.module.css +0 -66
  175. package/lib-esm/ui/popover/popover.stories.js +0 -14
  176. package/src/ui/popover/index.js +0 -1
  177. package/src/ui/popover/popover.jsx +0 -79
  178. package/src/ui/popover/popover.module.css +0 -66
@@ -13,6 +13,7 @@ import css from './filters.module.css';
13
13
  const Filter = props => {
14
14
  const {
15
15
  className,
16
+ buttonClassName,
16
17
  label,
17
18
  name,
18
19
  getOnOnlyClick,
@@ -25,7 +26,7 @@ const Filter = props => {
25
26
  }, /*#__PURE__*/React.createElement(FlexStack, {
26
27
  space: "xxxsmall",
27
28
  as: "label",
28
- className: css.filterCheckbox
29
+ className: cx(css.filterCheckbox, buttonClassName)
29
30
  }, /*#__PURE__*/React.createElement("input", _extends({
30
31
  className: css.filterInput,
31
32
  type: "checkbox",
@@ -43,17 +44,21 @@ const Filter = props => {
43
44
 
44
45
  Filter.propTypes = {
45
46
  className: PropTypes.string,
47
+ buttonClassName: PropTypes.string,
46
48
  name: PropTypes.string.isRequired,
47
49
  label: PropTypes.string.isRequired,
48
50
  getOnOnlyClick: PropTypes.func
49
51
  };
50
52
  Filter.defaultProps = {
51
53
  className: '',
54
+ buttonClassName: '',
52
55
  getOnOnlyClick: null
53
56
  };
54
57
 
55
58
  const FilterGroup = props => {
56
59
  const {
60
+ className,
61
+ buttonClassName,
57
62
  groupKey,
58
63
  data,
59
64
  values,
@@ -98,6 +103,8 @@ const FilterGroup = props => {
98
103
  };
99
104
 
100
105
  return /*#__PURE__*/React.createElement(Dropdown, {
106
+ className: className,
107
+ buttonClassName: buttonClassName,
101
108
  label: dropdownLabel,
102
109
  ariaLabel: `${groupLabel}: ${filterSuffix}`
103
110
  }, _ref4 => {
@@ -147,6 +154,8 @@ const FilterGroup = props => {
147
154
  };
148
155
 
149
156
  FilterGroup.propTypes = {
157
+ className: PropTypes.string,
158
+ buttonClassName: PropTypes.string,
150
159
  groupKey: PropTypes.string.isRequired,
151
160
  data: PropTypes.object.isRequired,
152
161
  // eslint-disable-line react/forbid-prop-types
@@ -155,6 +164,10 @@ FilterGroup.propTypes = {
155
164
  onCheckboxChange: PropTypes.func.isRequired,
156
165
  toggleFilters: PropTypes.func.isRequired
157
166
  };
167
+ FilterGroup.defaultProps = {
168
+ className: '',
169
+ buttonClassName: ''
170
+ };
158
171
  export const Filters = props => {
159
172
  const {
160
173
  className,
@@ -175,6 +188,7 @@ export const Filters = props => {
175
188
  return /*#__PURE__*/React.createElement("form", {
176
189
  className: rootClassName
177
190
  }, /*#__PURE__*/React.createElement(FlexStack, {
191
+ space: "xxsmall",
178
192
  className: css.items
179
193
  }, Object.entries(filters).map(_ref7 => {
180
194
  let [name, data] = _ref7;
@@ -183,6 +197,7 @@ export const Filters = props => {
183
197
  return /*#__PURE__*/React.createElement(Filter, {
184
198
  key: name,
185
199
  className: cx(css.item, css.filterStandalone),
200
+ buttonClassName: css.itemButton,
186
201
  name: name,
187
202
  label: data.label,
188
203
  onChange: onCheckboxChange,
@@ -191,16 +206,16 @@ export const Filters = props => {
191
206
  });
192
207
  }
193
208
 
194
- return /*#__PURE__*/React.createElement("div", {
195
- className: css.item
196
- }, /*#__PURE__*/React.createElement(FilterGroup, {
209
+ return /*#__PURE__*/React.createElement(FilterGroup, {
210
+ className: css.item,
211
+ buttonClassName: css.itemButton,
197
212
  key: name,
198
213
  groupKey: name,
199
214
  data: data,
200
215
  values: values,
201
216
  onCheckboxChange: onCheckboxChange,
202
217
  toggleFilters: toggleFilters
203
- }));
218
+ });
204
219
  })));
205
220
  };
206
221
  Filters.defaultProps = {
@@ -11,6 +11,7 @@
11
11
  }
12
12
 
13
13
  .filterInput {
14
+ border-radius: var(--radius-small) 0 0 var(--radius-small);
14
15
  flex: 0 0 auto;
15
16
  height: 1em;
16
17
  cursor: pointer;
@@ -131,9 +132,8 @@
131
132
  .item {
132
133
  position: relative;
133
134
  flex: 0 0 auto;
134
- margin-right: -1px;
135
135
  }
136
136
 
137
- .item:hover {
138
- z-index: var(--layer-low); /* show collapsed border */
137
+ .itemButton {
138
+ border-radius: var(--radius-small);
139
139
  }
@@ -0,0 +1,83 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { useCallback } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import cx from 'classnames';
6
+ import { Hovercard, HovercardAnchor, HovercardArrow, useHovercard, useHovercardState } from 'ariakit/hovercard';
7
+ import css from './hover-card.module.css';
8
+
9
+ const resolveComponent = (as, href) => {
10
+ if (as) {
11
+ return as;
12
+ }
13
+
14
+ if (href) {
15
+ return 'a';
16
+ }
17
+
18
+ return 'span';
19
+ };
20
+
21
+ export const HoverCard = props => {
22
+ const {
23
+ className,
24
+ hoverCardClassName,
25
+ href,
26
+ as,
27
+ label,
28
+ children
29
+ } = props;
30
+ const state = useHovercardState({
31
+ gutter: 8
32
+ });
33
+ const hoverCardProps = useHovercard({
34
+ state,
35
+ portal: true
36
+ }); // Fallback to span if no href
37
+
38
+ const Component = resolveComponent(as, href);
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ className: cx(css.root, className)
41
+ }, /*#__PURE__*/React.createElement(HovercardAnchor, {
42
+ state: state,
43
+ href: href,
44
+ className: css.anchor,
45
+ as: Component
46
+ }, label), /*#__PURE__*/React.createElement(Hovercard, _extends({}, hoverCardProps, {
47
+ state: state,
48
+ className: cx(css.hoverCard, hoverCardClassName),
49
+ style: {
50
+ zIndex: 10000
51
+ }
52
+ }), /*#__PURE__*/React.createElement(HovercardArrow, {
53
+ size: 24
54
+ }), typeof children === 'function' ? children({
55
+ close: state.hide
56
+ }) : children));
57
+ };
58
+ HoverCard.propTypes = {
59
+ /** Adopted child class name */
60
+ className: PropTypes.string,
61
+
62
+ /** Adopted child class name for hover card */
63
+ hoverCardClassName: PropTypes.string,
64
+
65
+ /** Anchor label */
66
+ label: PropTypes.node,
67
+
68
+ /** Anchor href */
69
+ href: PropTypes.string,
70
+
71
+ /** Anchor component */
72
+ as: PropTypes.elementType,
73
+
74
+ /** Hover card component */
75
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired
76
+ };
77
+ HoverCard.defaultProps = {
78
+ className: '',
79
+ hoverCardClassName: '',
80
+ label: '',
81
+ as: '',
82
+ href: ''
83
+ };
@@ -0,0 +1,29 @@
1
+ .root {
2
+ display: inline-block;
3
+ }
4
+
5
+ .anchor {
6
+ display: inline-block;
7
+ color: inherit;
8
+ text-decoration: none;
9
+ }
10
+
11
+ .anchor:hover {
12
+ color: var(--color-primary);
13
+ }
14
+
15
+ .anchor:focus {
16
+ outline: 0;
17
+ }
18
+
19
+ .hoverCard {
20
+ padding: var(--space-xsmall) var(--space-small);
21
+ border-radius: var(--radius-medium);
22
+ width: calc(100vw - 2 * var(--space-small));
23
+ max-width: 360px;
24
+ outline: none;
25
+ filter: drop-shadow(0 0 var(--space-xxsmall) var(--color-shadow));
26
+ will-change: filter;
27
+ background: var(--color-light);
28
+ font-size: var(--size-small);
29
+ }
@@ -0,0 +1,35 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import { HoverCard } from '.';
5
+ export default {
6
+ title: 'UI/HoverCard',
7
+ component: HoverCard
8
+ };
9
+
10
+ const Template = props => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HoverCard, _extends({}, props, {
11
+ style: {
12
+ zIndex: 2
13
+ }
14
+ })), /*#__PURE__*/React.createElement("p", {
15
+ style: {
16
+ position: 'relative',
17
+ zIndex: 1,
18
+ maxWidth: 360
19
+ }
20
+ }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in neque ante. Curabitur vehicula, lorem sit amet fringilla dapibus, justo mauris varius elit, ut fermentum leo velit eget risus"));
21
+
22
+ export const Default = () => /*#__PURE__*/React.createElement(Template, {
23
+ label: "main.js"
24
+ }, /*#__PURE__*/React.createElement("h1", null, "main.js"), /*#__PURE__*/React.createElement("p", null, "info"));
25
+ export const WithRenderFn = () => /*#__PURE__*/React.createElement(Template, {
26
+ label: "main.js"
27
+ }, _ref => {
28
+ let {
29
+ close
30
+ } = _ref;
31
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "main.js"), /*#__PURE__*/React.createElement("p", null, "info"), /*#__PURE__*/React.createElement("button", {
32
+ type: "button",
33
+ onClick: close
34
+ }, "close"));
35
+ });
@@ -0,0 +1 @@
1
+ export * from './hover-card';
@@ -19,14 +19,14 @@ const ICONS = {
19
19
  SORT: 'sort',
20
20
  WARNING: 'warning'
21
21
  };
22
- export const Icon = _ref => {
23
- let {
22
+ export const Icon = props => {
23
+ const {
24
24
  className,
25
25
  glyph,
26
26
  as: Component,
27
27
  size,
28
28
  ...restProps
29
- } = _ref;
29
+ } = props;
30
30
  return /*#__PURE__*/React.createElement(Component, _extends({
31
31
  className: cx(css.root, className, css[size])
32
32
  }, restProps), /*#__PURE__*/React.createElement("svg", {
@@ -1,5 +1,6 @@
1
1
  .root {
2
2
  display: inline-block;
3
+ vertical-align: middle; /** center align when parent display is inline/inline-block **/
3
4
  }
4
5
 
5
6
  .icon {
@@ -10,9 +10,9 @@ export { Input } from './input';
10
10
  export { Loader } from './loader';
11
11
  export { Logo } from './logo';
12
12
  export { Panels } from './panels';
13
- export { Popover } from './popover';
14
13
  export { Skeleton } from './skeleton';
15
14
  export { SortDropdown } from './sort-dropdown';
16
15
  export { Table } from './table';
17
16
  export { Tabs } from './tabs';
17
+ export { Tag } from './tag';
18
18
  export { Tooltip } from './tooltip';
@@ -1,67 +1,7 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
1
  import React from 'react';
4
2
  import PropTypes from 'prop-types';
5
3
  import cx from 'classnames';
6
4
  import css from './table.module.css';
7
-
8
- const THead = props => /*#__PURE__*/React.createElement("thead", props);
9
-
10
- const TBody = props => /*#__PURE__*/React.createElement("tbody", props);
11
-
12
- const Tr = props => {
13
- const {
14
- className,
15
- ...restProps
16
- } = props;
17
- return /*#__PURE__*/React.createElement("tr", _extends({
18
- className: cx(css.row, className)
19
- }, restProps));
20
- };
21
-
22
- Tr.defaultProps = {
23
- className: ''
24
- };
25
- Tr.propTypes = {
26
- /** Adopted child class name */
27
- className: PropTypes.string
28
- };
29
-
30
- const Th = props => {
31
- const {
32
- className,
33
- ...restProps
34
- } = props;
35
- return /*#__PURE__*/React.createElement("th", _extends({
36
- className: cx(css.cell, className)
37
- }, restProps));
38
- };
39
-
40
- Th.defaultProps = {
41
- className: ''
42
- };
43
- Th.propTypes = {
44
- /** Adopted child class name */
45
- className: PropTypes.string
46
- };
47
-
48
- const Td = props => {
49
- const {
50
- className,
51
- ...restProps
52
- } = props;
53
- return /*#__PURE__*/React.createElement("td", _extends({
54
- className: cx(css.cell, className)
55
- }, restProps));
56
- };
57
-
58
- Td.defaultProps = {
59
- className: ''
60
- };
61
- Td.propTypes = {
62
- /** Adopted child class name */
63
- className: PropTypes.string
64
- };
65
5
  export const Table = _ref => {
66
6
  let {
67
7
  className,
@@ -82,11 +22,11 @@ export const Table = _ref => {
82
22
  className: rootClassName
83
23
  }, children);
84
24
  };
85
- Table.THead = THead;
86
- Table.TBody = TBody;
87
- Table.Th = Th;
88
- Table.Tr = Tr;
89
- Table.Td = Td;
25
+ Table.THead = 'thead';
26
+ Table.TBody = 'tbody';
27
+ Table.Tr = 'tr';
28
+ Table.Th = 'th';
29
+ Table.Td = 'td';
90
30
  Table.defaultProps = {
91
31
  className: '',
92
32
  emptyMessage: 'No entries found.',
@@ -1,54 +1,54 @@
1
1
  .root {
2
2
  border-width: 0;
3
3
  width: 100%;
4
- border-collapse: collapse;
4
+ border-spacing: 0;
5
5
  empty-cells: show;
6
6
  background: var(--color-background);
7
+ text-align: left;
7
8
  }
8
9
 
9
- .cell {
10
+ .root th,
11
+ .root td {
10
12
  border: 1px solid var(--color-outline);
11
13
  border-width: 1px 0 0;
12
- padding: var(--space-small) var(--space-small);
13
- text-align: left;
14
- }
15
-
16
- tr:last-child .cell {
17
- border-bottom-width: 1px;
14
+ padding: var(--space-small);
18
15
  }
19
16
 
20
- .root thead .cell {
21
- border-width: 0 0 2px;
17
+ .root thead th {
18
+ border-width: 0 0 1px;
22
19
  text-transform: uppercase;
23
20
  vertical-align: top;
21
+ background: var(--color-highlight);
24
22
  }
25
23
 
26
- .root thead .cell:empty {
24
+ .root thead th:empty {
27
25
  display: none;
28
26
  }
29
27
 
30
- .root tbody .cell {
28
+ .root tbody th {
31
29
  font-weight: normal;
32
30
  }
33
31
 
34
- .root tbody .cell a {
32
+ .root tbody tr:first-child td,
33
+ .root tbody tr:first-child th {
34
+ border-top: 0;
35
+ }
36
+
37
+ .root tbody td a {
35
38
  color: inherit;
36
39
  text-decoration: none;
37
40
  }
38
41
 
39
- .root tbody .cell a:hover,
40
- .root tbody .cell a:focus,
41
- .root tbody .cell a:active
42
+ .root tbody td a:hover,
43
+ .root tbody td a:focus,
44
+ .root tbody td a:active
42
45
  {
43
46
  color: var(--color-primary);
44
47
  text-decoration: underline;
45
48
  }
46
49
 
47
- .root tbody tr:nth-child(odd) .cell {
48
- background-color: var(--color-highlight);
49
- }
50
-
51
- .root tbody tr:hover .cell {
50
+ .root tbody tr:hover th,
51
+ .root tbody tr:hover td {
52
52
  background-color: var(--color-highlight-warning);
53
53
  }
54
54
 
@@ -62,12 +62,27 @@ tr:last-child .cell {
62
62
 
63
63
  /* outline variation */
64
64
  .outline {
65
+ --table-radius: var(--radius-medium);
65
66
  border: 1px solid var(--color-outline);
66
- border-width: 0 1px;
67
+ border-radius: var(--table-radius);
68
+ }
69
+
70
+ .outline thead:first-child tr:first-child th:first-child,
71
+ .outline tbody:first-child tr:first-child td:first-child {
72
+ border-top-left-radius: var(--table-radius);
73
+ }
74
+
75
+ .outline thead tr:first-child th:last-child,
76
+ .outline tbody:first-child tr:first-child td:last-child {
77
+ border-top-right-radius: var(--table-radius);
78
+ }
79
+
80
+ .outline tbody:last-child tr:last-child td:first-child {
81
+ border-bottom-left-radius: var(--table-radius);
67
82
  }
68
83
 
69
- .outline thead tr:first-child .cell {
70
- border-top-width: 1px;
84
+ .outline tbody:last-child tr:last-child td:last-child {
85
+ border-bottom-right-radius: var(--table-radius);
71
86
  }
72
87
 
73
88
  .outline.empty {
@@ -75,7 +90,8 @@ tr:last-child .cell {
75
90
  }
76
91
 
77
92
  /* compact variation */
78
- .compact .cell {
93
+ .compact td,
94
+ .compact th {
79
95
  padding-top: var(--space-xsmall);
80
96
  padding-bottom: var(--space-xsmall);
81
97
  }
@@ -46,7 +46,7 @@ stories.add('with custom content and attributes', () => /*#__PURE__*/React.creat
46
46
  style: {
47
47
  textDecoration: 'underline'
48
48
  }
49
- }, "Col C(undefiner)"))), /*#__PURE__*/React.createElement(TBody, null, /*#__PURE__*/React.createElement(Tr, null, /*#__PURE__*/React.createElement(Th, null, /*#__PURE__*/React.createElement("strong", null, "row 1")), /*#__PURE__*/React.createElement(Td, {
49
+ }, "Col C(underline)"))), /*#__PURE__*/React.createElement(TBody, null, /*#__PURE__*/React.createElement(Tr, null, /*#__PURE__*/React.createElement(Th, null, /*#__PURE__*/React.createElement("strong", null, "row 1")), /*#__PURE__*/React.createElement(Td, {
50
50
  style: {
51
51
  textAlign: 'right'
52
52
  }
@@ -0,0 +1 @@
1
+ export * from './tag';
@@ -0,0 +1,45 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import cx from 'classnames';
6
+ import css from './tag.module.css';
7
+ export const KINDS = {
8
+ DEFAULT: 'default',
9
+ SUCCESS: 'success',
10
+ INFO: 'info',
11
+ WARNING: 'warning',
12
+ DANGER: 'danger'
13
+ };
14
+ export const SIZES = {
15
+ SMALL: 'small',
16
+ MEDIUM: 'medium',
17
+ LARGE: 'large'
18
+ };
19
+ export const Tag = props => {
20
+ const {
21
+ className = '',
22
+ as: Component = 'span',
23
+ kind = KINDS.DEFAULT,
24
+ size = SIZES.MEDIUM,
25
+ ...restProps
26
+ } = props;
27
+ const rootClassName = cx(css.root, className, css[kind], css[size]);
28
+ return /*#__PURE__*/React.createElement(Component, _extends({
29
+ className: rootClassName
30
+ }, restProps));
31
+ };
32
+ Tag.propTypes = {
33
+ className: PropTypes.string,
34
+ as: PropTypes.elementType,
35
+ kind: PropTypes.oneOf(Object.values(KINDS)),
36
+ size: PropTypes.oneOf(Object.values(SIZES))
37
+ };
38
+ Tag.defaultProps = {
39
+ className: '',
40
+ as: 'span',
41
+ kind: KINDS.DEFAULT,
42
+ size: SIZES.MEDIUM
43
+ };
44
+ Tag.KINDS = KINDS;
45
+ Tag.SIZES = SIZES;
@@ -0,0 +1,55 @@
1
+ .root {
2
+ display: inline-block;
3
+ font-family: var(--font-family);
4
+ font-weight: bold;
5
+ background: var(--color-text-light);
6
+ color: var(--color-light);
7
+ text-align: center;
8
+ text-transform: uppercase;
9
+ }
10
+
11
+ /** Kind variation */
12
+ .success {
13
+ background: var(--color-success);
14
+ }
15
+
16
+ .info {
17
+ background: var(--color-info);
18
+ }
19
+
20
+ .warning {
21
+ background: var(--color-warning-dark);
22
+ }
23
+
24
+ .danger {
25
+ background: var(--color-danger);
26
+ }
27
+
28
+ /** Size variation */
29
+ /** default: medium */
30
+ .root {
31
+ border-radius: var(--radius-medium);
32
+ padding: var(--space-xxxsmall);
33
+ min-width: var(--space-small);
34
+ height: var(--space-small);
35
+ font-size: 9px;
36
+ line-height: 1;
37
+ }
38
+
39
+ .small {
40
+ border-radius: var(--radius-small);
41
+ padding: calc(var(--space-xxxsmall) / 2);
42
+ height: var(--space-xsmall);
43
+ min-width: var(--space-xsmall);
44
+ font-size: 8px;
45
+ line-height: 1;
46
+ }
47
+
48
+ .large {
49
+ border-radius: var(--radius-large);
50
+ padding: var(--space-xxxsmall) var(--space-xxsmall);
51
+ min-width: var(--space-medium);
52
+ height: var(--space-medium);
53
+ font-size: 12px;
54
+ line-height: var(--space-small);
55
+ }
@@ -0,0 +1,23 @@
1
+ import { Tag } from '.';
2
+ export default {
3
+ title: 'UI/Tag',
4
+ component: Tag,
5
+ argTypes: {
6
+ kind: {
7
+ control: 'select',
8
+ options: Object.values(Tag.KINDS)
9
+ },
10
+ size: {
11
+ control: 'select',
12
+ options: Object.values(Tag.SIZES)
13
+ }
14
+ },
15
+ args: {
16
+ children: 'tag'
17
+ }
18
+ };
19
+ export const Default = Tag.bind();
20
+ export const OneLetter = Tag.bind();
21
+ OneLetter.args = {
22
+ children: 'd'
23
+ };