@bundle-stats/ui 4.13.0-beta.10 → 4.13.0-beta.12
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.
- package/lib/components/metrics-treemap/metrics-treemap.js +25 -25
- package/lib/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.module.css +20 -20
- package/lib/css/variables.css +3 -3
- package/lib/ui/button/button.js +5 -4
- package/lib/ui/button/button.js.map +1 -1
- package/lib/ui/button/button.module.css +55 -53
- package/lib/ui/icon/icon.js +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.js +25 -25
- package/lib-esm/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.module.css +20 -20
- package/lib-esm/css/variables.css +3 -3
- package/lib-esm/ui/button/button.js +5 -4
- package/lib-esm/ui/button/button.js.map +1 -1
- package/lib-esm/ui/button/button.module.css +55 -53
- package/lib-esm/ui/icon/icon.js +1 -1
- package/package.json +4 -4
- package/src/components/metrics-treemap/metrics-treemap.module.css +20 -20
- package/src/components/metrics-treemap/metrics-treemap.tsx +45 -45
- package/src/css/variables.css +3 -3
- package/src/ui/button/button.module.css +55 -53
- package/src/ui/button/button.stories.tsx +16 -9
- package/src/ui/button/button.tsx +8 -7
- package/src/ui/icon/icon.tsx +1 -1
- package/types/ui/icon/icon.d.ts +2 -2
|
@@ -29,7 +29,7 @@ const VERTICAL_SPACING = 4;
|
|
|
29
29
|
const LINE_HEIGHT = 16;
|
|
30
30
|
const LINE_HEIGHT_SMALL = 13.3;
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function resolveTileSizeDisplay(width: number, height: number): TileSizeDisplay {
|
|
33
33
|
if (
|
|
34
34
|
height > PADDING_TOP + PADDING_BOTTOM + VERTICAL_SPACING + LINE_HEIGHT * 2 &&
|
|
35
35
|
width > PADDING_LEFT + PADDING_RIGHT + 128
|
|
@@ -47,19 +47,19 @@ function resolveLeafSizeDisplay(width: number, height: number): TileSizeDisplay
|
|
|
47
47
|
return 'minimal';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
interface
|
|
50
|
+
interface TileTooltipContentProps {
|
|
51
51
|
item: ReportMetricRow;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const
|
|
54
|
+
const TileTooltipContent = (props: TileTooltipContentProps) => {
|
|
55
55
|
const { item } = props;
|
|
56
56
|
|
|
57
57
|
const currentRun = item.runs[0] as MetricRunInfo;
|
|
58
58
|
const baselineRun = item.runs[item.runs.length - 1] as MetricRunInfoBaseline;
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
|
-
<Stack space="small" className={css.
|
|
62
|
-
<h3 className={css.
|
|
61
|
+
<Stack space="small" className={css.tileTooltipContent}>
|
|
62
|
+
<h3 className={css.tileTooltipContentTitle}>
|
|
63
63
|
<FileName as="code" name={item.label} />
|
|
64
64
|
</h3>
|
|
65
65
|
<RunInfo
|
|
@@ -72,21 +72,21 @@ const LeafTooltipContent = (props: LeafTooltipContentProps) => {
|
|
|
72
72
|
);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
interface
|
|
75
|
+
interface TileContentProps {
|
|
76
76
|
sizeDisplay: 'minimal' | 'small' | 'default';
|
|
77
77
|
item: ReportMetricRow;
|
|
78
78
|
runInfo: MetricRunInfo;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const
|
|
81
|
+
const TileContent = forwardRef((props: TileContentProps, ref: React.Ref<HTMLDivElement>) => {
|
|
82
82
|
const { sizeDisplay, item, runInfo } = props;
|
|
83
83
|
|
|
84
84
|
if (sizeDisplay === 'minimal') {
|
|
85
|
-
return <div className={css.
|
|
85
|
+
return <div className={css.tileContent} ref={ref} />;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<div className={css.
|
|
89
|
+
<div className={css.tileContent} ref={ref}>
|
|
90
90
|
<FileName as="p" className={css.leadContentLabel} name={item.label} />
|
|
91
91
|
{sizeDisplay !== 'small' && (
|
|
92
92
|
<p className={css.leadContentValue}>
|
|
@@ -102,7 +102,7 @@ const LeafContent = forwardRef((props: LeafContentProps, ref: React.Ref<HTMLDivE
|
|
|
102
102
|
);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
const
|
|
105
|
+
const TileContentWithTooltip = (props: TileContentProps & { parentRef: RefObject<Element> }) => {
|
|
106
106
|
const { sizeDisplay, item, runInfo, parentRef } = props;
|
|
107
107
|
|
|
108
108
|
const pointer = useMouseHovered(parentRef, { whenHovered: true });
|
|
@@ -131,12 +131,12 @@ const LeafContentWithTooltip = (props: LeafContentProps & { parentRef: RefObject
|
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
133
|
<>
|
|
134
|
-
<TooltipAnchor state={tooltipState} className={css.
|
|
135
|
-
<
|
|
134
|
+
<TooltipAnchor state={tooltipState} className={css.tileContentTooltipAnchor}>
|
|
135
|
+
<TileContent sizeDisplay={sizeDisplay} item={item} runInfo={runInfo} />
|
|
136
136
|
</TooltipAnchor>
|
|
137
137
|
<Tooltip state={tooltipState} className={css.tooltip}>
|
|
138
|
-
<TooltipArrow state={tooltipState} size={16} className={css.
|
|
139
|
-
<
|
|
138
|
+
<TooltipArrow state={tooltipState} size={16} className={css.tileTooltipArrow} />
|
|
139
|
+
<TileTooltipContent item={item} />
|
|
140
140
|
</Tooltip>
|
|
141
141
|
</>
|
|
142
142
|
);
|
|
@@ -155,7 +155,7 @@ interface RootTree {
|
|
|
155
155
|
children: Array<TreeNode>;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
interface
|
|
158
|
+
interface TileProps {
|
|
159
159
|
left: number;
|
|
160
160
|
top: number;
|
|
161
161
|
width: number;
|
|
@@ -164,42 +164,42 @@ interface LeafProps {
|
|
|
164
164
|
onClick?: (id: string) => void;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
const
|
|
167
|
+
const Tile = (props: TileProps) => {
|
|
168
168
|
const { left, top, width, height, data, onClick } = props;
|
|
169
169
|
|
|
170
170
|
const { item } = data;
|
|
171
171
|
const runInfo = item.runs?.[0] as MetricRunInfo;
|
|
172
172
|
|
|
173
|
-
const sizeDisplay = useMemo(() =>
|
|
173
|
+
const sizeDisplay = useMemo(() => resolveTileSizeDisplay(width, height), [width, height]);
|
|
174
174
|
const handleOnClick = useCallback(() => onClick?.(item.key), [item.key, onClick]);
|
|
175
175
|
|
|
176
|
-
const
|
|
177
|
-
const hover = useHoverDirty(
|
|
176
|
+
const contentRef = useRef<HTMLButtonElement>(null);
|
|
177
|
+
const hover = useHoverDirty(contentRef);
|
|
178
178
|
|
|
179
|
-
const
|
|
180
|
-
css.
|
|
181
|
-
css[`
|
|
182
|
-
sizeDisplay === 'small' && css.
|
|
183
|
-
left === 0 && css.
|
|
179
|
+
const className = cx(
|
|
180
|
+
css.tile,
|
|
181
|
+
css[`tile-${runInfo.deltaType}`],
|
|
182
|
+
sizeDisplay === 'small' && css.tileSmall,
|
|
183
|
+
left === 0 && css.tileFirstCol,
|
|
184
184
|
);
|
|
185
185
|
|
|
186
186
|
return (
|
|
187
187
|
<button
|
|
188
188
|
type="button"
|
|
189
189
|
onClick={handleOnClick}
|
|
190
|
-
ref={
|
|
190
|
+
ref={contentRef}
|
|
191
191
|
style={{ left, top, width, height }}
|
|
192
|
-
className={
|
|
192
|
+
className={className}
|
|
193
193
|
>
|
|
194
194
|
{hover ? (
|
|
195
|
-
<
|
|
195
|
+
<TileContentWithTooltip
|
|
196
196
|
sizeDisplay={sizeDisplay}
|
|
197
197
|
item={item}
|
|
198
198
|
runInfo={runInfo}
|
|
199
|
-
parentRef={
|
|
199
|
+
parentRef={contentRef}
|
|
200
200
|
/>
|
|
201
201
|
) : (
|
|
202
|
-
<
|
|
202
|
+
<TileContent sizeDisplay={sizeDisplay} item={item} runInfo={runInfo} />
|
|
203
203
|
)}
|
|
204
204
|
</button>
|
|
205
205
|
);
|
|
@@ -217,8 +217,8 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
217
217
|
const treemapHierarchy = useMemo(() => {
|
|
218
218
|
const children = items.map((item) => {
|
|
219
219
|
/**
|
|
220
|
-
* Set
|
|
221
|
-
* display the impact of deleted
|
|
220
|
+
* Set tile value to the largest run value to allow to
|
|
221
|
+
* display the impact of deleted/new entries
|
|
222
222
|
*/
|
|
223
223
|
const values = item.runs.map((run) => run?.value || 0);
|
|
224
224
|
const value = Math.max(...values);
|
|
@@ -245,7 +245,7 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
245
245
|
return customHierarchy;
|
|
246
246
|
}, [items]);
|
|
247
247
|
|
|
248
|
-
const
|
|
248
|
+
const tiles = useMemo(() => {
|
|
249
249
|
const createTremapLayout = treemap()
|
|
250
250
|
.size([width, height])
|
|
251
251
|
.tile(treemapSquarify.ratio(SQUARIFY_RATIO))
|
|
@@ -254,10 +254,10 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
254
254
|
// @ts-expect-error
|
|
255
255
|
const tremapLayout = createTremapLayout(treemapHierarchy);
|
|
256
256
|
|
|
257
|
-
return tremapLayout.leaves().filter((
|
|
257
|
+
return tremapLayout.leaves().filter((tile) => Boolean(tile.parent));
|
|
258
258
|
}, [height, width, treemapHierarchy]);
|
|
259
259
|
|
|
260
|
-
return
|
|
260
|
+
return tiles;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
interface MetricsTreemapProps {
|
|
@@ -270,26 +270,26 @@ export const MetricsTreemap = (props: MetricsTreemapProps & React.ComponentProps
|
|
|
270
270
|
const { className = '', items, onItemClick, emptyMessage = 'No data', ...restProps } = props;
|
|
271
271
|
|
|
272
272
|
const [containerRef, { width, height }] = useMeasure<HTMLDivElement>();
|
|
273
|
-
const
|
|
273
|
+
const tiles = useMetricsTreemapHierarchy({ items, width, height });
|
|
274
274
|
|
|
275
275
|
return (
|
|
276
276
|
<div className={cx(css.root, className)} {...restProps} ref={containerRef}>
|
|
277
|
-
{
|
|
277
|
+
{tiles.length > 0 ? (
|
|
278
278
|
<div className={css.canvas}>
|
|
279
|
-
{
|
|
280
|
-
if (!
|
|
279
|
+
{tiles.map((tile) => {
|
|
280
|
+
if (!tile.parent) {
|
|
281
281
|
return null;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
return (
|
|
285
|
-
<
|
|
286
|
-
data={
|
|
287
|
-
left={
|
|
288
|
-
top={
|
|
289
|
-
width={
|
|
290
|
-
height={
|
|
285
|
+
<Tile
|
|
286
|
+
data={tile.data as TreeNode}
|
|
287
|
+
left={tile.x0}
|
|
288
|
+
top={tile.y0}
|
|
289
|
+
width={tile.x1 - tile.x0}
|
|
290
|
+
height={tile.y1 - tile.y0}
|
|
291
291
|
onClick={onItemClick}
|
|
292
|
-
key={
|
|
292
|
+
key={tile.id}
|
|
293
293
|
/>
|
|
294
294
|
);
|
|
295
295
|
})}
|
package/src/css/variables.css
CHANGED
|
@@ -192,9 +192,9 @@
|
|
|
192
192
|
--shadow-layer: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
193
193
|
--shadow-layer-high: 0 0 var(--space-xxsmall) var(--color-shadow);
|
|
194
194
|
|
|
195
|
-
--radius-small:
|
|
196
|
-
--radius-medium:
|
|
197
|
-
--radius-large:
|
|
195
|
+
--radius-small: 5px;
|
|
196
|
+
--radius-medium: 7px;
|
|
197
|
+
--radius-large: 9px;
|
|
198
198
|
|
|
199
199
|
--outline-hover: 0 0 0 3px var(--color-highlight);
|
|
200
200
|
|
|
@@ -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
|
-
|
|
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:
|
|
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
|
|
224
|
+
--border-width: 1px;
|
|
225
|
+
border-color: var(--color-outline);
|
|
178
226
|
}
|
|
179
227
|
|
|
180
228
|
.outline:hover,
|
|
@@ -244,58 +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
|
-
margin: 1px; /* compensate to keep the same height when the text is not provided */
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.medium {
|
|
263
|
-
font-size: var(--size-medium);
|
|
264
|
-
gap: var(--space-xxsmall);
|
|
265
|
-
line-height: var(--space-small);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.large {
|
|
269
|
-
font-size: var(--size-large);
|
|
270
|
-
gap: var(--space-xxsmall);
|
|
271
|
-
line-height: var(--space-small);
|
|
272
|
-
}
|
|
273
295
|
|
|
274
296
|
/**
|
|
275
297
|
* Padding variation
|
|
276
298
|
*/
|
|
277
|
-
.padding
|
|
278
|
-
padding: var(--space-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.outline--padding--small {
|
|
282
|
-
padding: calc(var(--space-xxsmall) - 1px);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.padding--medium {
|
|
286
|
-
padding: var(--space-xsmall);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.outline--padding--medium {
|
|
290
|
-
padding: calc(var(--space-xsmall) - 1px);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.padding--large {
|
|
294
|
-
padding: var(--space-small);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.outline--padding--large {
|
|
298
|
-
padding: calc(var(--space-small) - 1px);
|
|
299
|
+
.padding {
|
|
300
|
+
padding: calc(var(--button-space) - var(--border-width));
|
|
299
301
|
}
|
|
300
302
|
|
|
301
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
211
|
+
glyph={Icon.ICONS.ARROW_RIGHT_CIRCLE}
|
|
205
212
|
solid
|
|
206
213
|
kind={kind}
|
|
207
214
|
size={size}
|
package/src/ui/button/button.tsx
CHANGED
|
@@ -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
|
|
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}
|
|
89
|
+
{glyph && <Icon glyph={glyph} className={css.glyph} />}
|
|
89
90
|
{children && <span className={css.content}>{children}</span>}
|
|
90
|
-
{rightGlyph && <Icon glyph={
|
|
91
|
+
{rightGlyph && <Icon glyph={rightGlyph} className={css.glyph} />}
|
|
91
92
|
</Component>
|
|
92
93
|
);
|
|
93
94
|
};
|
package/src/ui/icon/icon.tsx
CHANGED
package/types/ui/icon/icon.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const ICONS: {
|
|
3
3
|
readonly ARROW: "arrow";
|
|
4
|
-
readonly
|
|
4
|
+
readonly ARROW_RIGHT_CIRCLE: "arrow-right-circle";
|
|
5
5
|
readonly CANCEL: "close";
|
|
6
6
|
readonly CHEVRON_DOWN: "chevron-down";
|
|
7
7
|
readonly CHEVRON_UP: "chevron-up";
|
|
@@ -36,7 +36,7 @@ export declare const Icon: {
|
|
|
36
36
|
(props: IconProps & React.ComponentProps<'span'>): React.JSX.Element;
|
|
37
37
|
ICONS: {
|
|
38
38
|
readonly ARROW: "arrow";
|
|
39
|
-
readonly
|
|
39
|
+
readonly ARROW_RIGHT_CIRCLE: "arrow-right-circle";
|
|
40
40
|
readonly CANCEL: "close";
|
|
41
41
|
readonly CHEVRON_DOWN: "chevron-down";
|
|
42
42
|
readonly CHEVRON_UP: "chevron-up";
|