@carbonid1/design-system 5.6.0 → 5.7.0
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/dist/Button/Button.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ButtonProps } from './Button.types';
|
|
|
2
2
|
declare const buttonVariants: (props?: ({
|
|
3
3
|
variant?: "primary" | "attention" | "destructive" | "link" | "ghost" | "outline" | "subtle" | "danger" | null | undefined;
|
|
4
4
|
size?: "default" | "small" | "large" | "icon" | "smallIcon" | "largeIcon" | null | undefined;
|
|
5
|
+
selected?: boolean | null | undefined;
|
|
5
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
-
declare const Button: ({ className, variant, size, fullWidth, loading, disabled, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const Button: ({ className, variant, size, selected, fullWidth, loading, disabled, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export { Button, buttonVariants };
|
package/dist/Button/Button.js
CHANGED
|
@@ -24,11 +24,29 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
|
|
|
24
24
|
smallIcon: 'size-6 rounded-full',
|
|
25
25
|
largeIcon: 'size-12 rounded-full',
|
|
26
26
|
},
|
|
27
|
+
selected: {
|
|
28
|
+
true: 'bg-primary/10 ring-1 ring-primary/20',
|
|
29
|
+
false: '',
|
|
30
|
+
},
|
|
27
31
|
},
|
|
32
|
+
compoundVariants: [
|
|
33
|
+
// Hold the selection tint on hover instead of letting the variant's own hover background win.
|
|
34
|
+
{
|
|
35
|
+
selected: true,
|
|
36
|
+
variant: 'ghost',
|
|
37
|
+
className: 'hover:bg-primary/10 dark:hover:bg-primary/10',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
selected: true,
|
|
41
|
+
variant: 'outline',
|
|
42
|
+
className: 'hover:bg-primary/10 dark:hover:bg-primary/10',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
28
45
|
defaultVariants: {
|
|
29
46
|
variant: 'ghost',
|
|
30
47
|
size: 'default',
|
|
48
|
+
selected: false,
|
|
31
49
|
},
|
|
32
50
|
});
|
|
33
|
-
const Button = ({ className, variant, size, fullWidth, loading, disabled, children, ...props }) => (_jsxs(ButtonPrimitive, { "data-slot": "button", className: cn(buttonVariants({ variant, size }), fullWidth && 'w-full justify-start', className), disabled: disabled ?? loading, "aria-busy": loading ?? undefined, ...props, children: [loading && _jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), children] }));
|
|
51
|
+
const Button = ({ className, variant, size, selected, fullWidth, loading, disabled, children, ...props }) => (_jsxs(ButtonPrimitive, { "data-slot": "button", className: cn(buttonVariants({ variant, size, selected }), fullWidth && 'w-full justify-start', className), disabled: disabled ?? loading, "aria-busy": loading ?? undefined, ...props, children: [loading && _jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), children] }));
|
|
34
52
|
export { Button, buttonVariants };
|
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
useTheme,
|
|
25
25
|
cn,
|
|
26
26
|
getModKey,
|
|
27
|
+
useHotkeys,
|
|
27
28
|
} from '@carbonid1/design-system'
|
|
28
29
|
```
|
|
29
30
|
|
|
@@ -40,6 +41,19 @@ If you're editing `@carbonid1/design-system` itself (adding a primitive, changin
|
|
|
40
41
|
- Tooltip: rely on defaults (`position="top"`, `delay={200}`). Only override when the default is wrong (e.g. header → `position="bottom"`, data-viz progressive disclosure → `delay={600}`). When a tooltip trigger also opens a popover, pass `disabled={open}`.
|
|
41
42
|
- Icon toggle state: `<Icon fill={active ? 'currentColor' : 'none'} />` — not two different components.
|
|
42
43
|
|
|
44
|
+
## Buttons & links
|
|
45
|
+
|
|
46
|
+
- **Active/selected state** — pass `selected` (toolbar toggles, segmented controls, filter chips, tabs, nav links). It applies the selection tokens (`bg-primary/10` + `ring-1 ring-primary/20`, tint held on hover); never hand-layer those classes. `selected` is visual only — set the matching ARIA yourself: `aria-pressed` on toggle buttons, `aria-current` on nav links. It rides both `Button` and `buttonVariants(...)`.
|
|
47
|
+
- **A link that looks like a button** — apply `buttonVariants({ variant, size, selected })` to the `Link`, not `<Button render={<Link/>}>`. Base UI's `Button` is button-semantic: rendering an `<a>` through it either warns or forces `role="button"`, which breaks navigation for screen readers. Keep the element a real link and style it:
|
|
48
|
+
```tsx
|
|
49
|
+
<Link
|
|
50
|
+
href={href}
|
|
51
|
+
aria-current={active ? 'page' : undefined}
|
|
52
|
+
className={cn(buttonVariants({ variant: 'ghost', size: 'small', selected: active }))}
|
|
53
|
+
/>
|
|
54
|
+
```
|
|
55
|
+
Wrap in `cn(...)` so the `selected` hover tint resolves against the variant's own hover background.
|
|
56
|
+
|
|
43
57
|
## Visual Language
|
|
44
58
|
|
|
45
59
|
- **Discrete elements** — rows/cards use `rounded-lg` with `space-y-1` gaps, never flat lists with hairline dividers
|
|
@@ -75,7 +89,7 @@ Two tiers. Pick by how hard the action is to redo, not how scary it feels.
|
|
|
75
89
|
| **Hard to redo** | Undo toast (5s + Cmd/Ctrl+Z) | Delete a record, remove history item |
|
|
76
90
|
| **Easy to redo** | No confirmation | Toggle flag, remove a tag |
|
|
77
91
|
|
|
78
|
-
**Undo toast:** action executes immediately → toast with description `${getModKey()}+Z to undo` + "Undo" action button (5s auto-dismiss) → store holds `lastDeleted` for restoration → global `mod+z` hotkey via `
|
|
92
|
+
**Undo toast:** action executes immediately → toast with description `${getModKey()}+Z to undo` + "Undo" action button (5s auto-dismiss) → store holds `lastDeleted` for restoration → global `mod+z` hotkey via `useHotkeys` (re-exported from the design system) → sequential deletes overwrite the buffer (only latest is undoable). Never add a modal confirmation for hard-to-redo actions — the undo toast is the confirmation.
|
|
79
93
|
|
|
80
94
|
## Layout Stability
|
|
81
95
|
|