Skip to content

Commit ed431aa

Browse files
committed
fix(ui): apply Chip review findings
The dark outline overlay aliased gray-900-75, whose exported value is the documented pre-2.0 bug (50% alpha instead of 75) - mixed from gray-900 directly, like the light theme already does. The close button gets the standard focus-visible ring. Variant and Size are renamed to ChipVariant/ChipSize and exported - the bare names shadowed two existing public types and rendered misleadingly in the generated props table. Chip now forwards its ref and native span attributes, and the close affordance takes an overridable closeLabel. The outline stroke is an inset ring instead of a border so outline and solid chips render the same width. Spacing metrics bind the space/size primitives from the provisional set.
1 parent 08497b3 commit ed431aa

6 files changed

Lines changed: 56 additions & 34 deletions

File tree

.changeset/conditions-tag-chip.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@workflowbuilder/sdk': patch
33
---
44

5-
The dynamic-conditions counter tag is rendered with the UI `Chip` component; it picks up the DS 2.0 neutral chip surface.
5+
The dynamic-conditions counter tag is rendered with the UI `Chip` component. Same neutral surface colors; the tag gets the DS 2.0 chip metrics — 10px label (was 12px) in a 20px-tall pill with slightly tighter padding.

apps/docs/src/components/ui-examples/chips.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { ComponentPreview } from './component-preview';
66
export function ChipsExample() {
77
return (
88
<ComponentPreview>
9-
<Chip label="tag label" />
10-
<Chip label="tag label" variant="outline" />
11-
<Chip label="with icon" size="l" prefixIcon={<Tag />} />
12-
<Chip label="removable" size="l" variant="outline" onClose={() => {}} />
9+
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
10+
<Chip label="tag label" />
11+
<Chip label="tag label" variant="outline" />
12+
<Chip label="with icon" size="l" prefixIcon={<Tag />} />
13+
<Chip label="removable" size="l" variant="outline" onClose={() => {}} />
14+
</div>
1315
</ComponentPreview>
1416
);
1517
}

packages/sdk/src/features/json-form/controls/dynamic-conditions-control/dynamic-conditions-control.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@
2626

2727
.tag {
2828
margin-top: 0.25rem;
29-
margin-right: auto;
3029
}

packages/ui/src/components/chips/chips.module.css

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.chip {
33
display: inline-flex;
44
align-items: center;
5-
gap: 0.25rem;
5+
gap: var(--wb-space-50);
66
border-radius: var(--wb-radius-50);
77
white-space: nowrap;
88
}
@@ -19,28 +19,30 @@
1919
var(--wb-components-chips-overlay-outline),
2020
var(--wb-components-chips-overlay-outline)
2121
);
22-
border: 0.0625rem solid var(--wb-components-chips-inset-outline);
22+
/* An inset ring, not a border: Figma's inside stroke overlaps the padding,
23+
a CSS border would add to it and widen the chip. */
24+
box-shadow: inset 0 0 0 var(--wb-size-12) var(--wb-components-chips-inset-outline);
2325
color: var(--wb-components-chips-inset-outline);
2426
}
2527

2628
.s {
2729
height: 0.875rem;
28-
padding-inline: 0.25rem;
30+
padding-inline: var(--wb-space-50);
2931
}
3032

3133
.m {
3234
height: 1rem;
33-
padding-inline: 0.25rem;
35+
padding-inline: var(--wb-space-50);
3436
}
3537

3638
.l {
3739
height: 1.25rem;
38-
padding-inline: 0.375rem;
40+
padding-inline: var(--wb-space-75);
3941
}
4042

4143
.xl {
4244
height: 1.375rem;
43-
padding-inline: 0.375rem;
45+
padding-inline: var(--wb-space-75);
4446
}
4547

4648
.icon,
@@ -49,7 +51,7 @@
4951
align-items: center;
5052
}
5153

52-
.icon > svg,
54+
.icon svg,
5355
.close svg {
5456
width: 0.625rem;
5557
height: 0.625rem;
@@ -61,5 +63,10 @@
6163
background: none;
6264
color: inherit;
6365
cursor: pointer;
66+
67+
&:focus-visible {
68+
box-shadow: 0 0 0 2px var(--ax-focus-ring-element);
69+
outline: none;
70+
}
6471
}
6572
}
Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { X } from '@phosphor-icons/react';
22
import clsx from 'clsx';
3-
import type { ReactNode } from 'react';
3+
import { HTMLAttributes, ReactNode, forwardRef } from 'react';
44

55
import styles from './chips.module.css';
66

@@ -14,11 +14,11 @@ export type ChipProps = {
1414
* outline treatment.
1515
* @default 'solid'
1616
*/
17-
variant?: Variant;
17+
variant?: ChipVariant;
1818
/**
1919
* @default 'm'
2020
*/
21-
size?: Size;
21+
size?: ChipSize;
2222
/**
2323
* Icon rendered before the label.
2424
*/
@@ -27,25 +27,36 @@ export type ChipProps = {
2727
* When provided, a close affordance is rendered and invokes this callback.
2828
*/
2929
onClose?: () => void;
30-
className?: string;
31-
};
30+
/**
31+
* Accessible name of the close affordance.
32+
* @default `Remove ${label}`
33+
*/
34+
closeLabel?: string;
35+
} & HTMLAttributes<HTMLSpanElement>;
3236

33-
type Variant = 'solid' | 'outline';
34-
type Size = 's' | 'm' | 'l' | 'xl';
37+
export type ChipVariant = 'solid' | 'outline';
38+
export type ChipSize = 's' | 'm' | 'l' | 'xl';
3539

3640
/**
3741
* Compact tag for labeling and filtering, in the two DS 2.0 treatments.
3842
*/
39-
export function Chip({ label, variant = 'solid', size = 'm', prefixIcon, onClose, className }: ChipProps) {
40-
return (
41-
<span className={clsx(styles['chip'], styles[variant], styles[size], className)}>
42-
{prefixIcon && <span className={styles['icon']}>{prefixIcon}</span>}
43-
<span className="wb-text-label-s">{label}</span>
44-
{onClose && (
45-
<button type="button" className={styles['close']} aria-label={`Remove ${label}`} onClick={onClose}>
46-
<X />
47-
</button>
48-
)}
49-
</span>
50-
);
51-
}
43+
export const Chip = forwardRef<HTMLSpanElement, ChipProps>(
44+
({ label, variant = 'solid', size = 'm', prefixIcon, onClose, closeLabel, className, ...rest }, ref) => {
45+
return (
46+
<span ref={ref} {...rest} className={clsx(styles['chip'], styles[variant], styles[size], className)}>
47+
{prefixIcon && <span className={styles['icon']}>{prefixIcon}</span>}
48+
<span className="wb-text-label-s">{label}</span>
49+
{onClose && (
50+
<button
51+
type="button"
52+
className={styles['close']}
53+
aria-label={closeLabel ?? `Remove ${label}`}
54+
onClick={onClose}
55+
>
56+
<X />
57+
</button>
58+
)}
59+
</span>
60+
);
61+
},
62+
);

packages/ui/src/styles/_provisional.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
--wb-font-size-400: 2rem;
2222

2323
--wb-radius-50: 0.25rem;
24+
--wb-space-50: 0.25rem;
25+
--wb-space-75: 0.375rem;
26+
--wb-size-12: 0.0625rem;
2427
--wb-components-chips-inset-outline: var(--ax-colors-acc1-500);
2528
}
2629

@@ -33,6 +36,6 @@
3336
html[data-theme='dark'] {
3437
--wb-components-chips-solid: var(--ax-colors-gray-650);
3538
--wb-components-chips-solid-text: var(--ax-colors-gray-100);
36-
--wb-components-chips-overlay-outline: var(--ax-colors-gray-900-75);
39+
--wb-components-chips-overlay-outline: color-mix(in srgb, var(--ax-colors-gray-900) 75%, transparent);
3740
}
3841
}

0 commit comments

Comments
 (0)