@carbonid1/design-system 5.7.3 → 5.7.5
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/Badge/Badge.js +2 -2
- package/dist/Button/Button.js +1 -1
- package/dist/helpers/contrast/contrast.d.ts +12 -0
- package/dist/helpers/contrast/contrast.js +37 -0
- package/package.json +1 -1
- package/skills/design-system/SKILL.md +0 -1
- package/themes/dashboard.css +10 -1
- package/themes/reader.css +10 -1
package/dist/Badge/Badge.js
CHANGED
|
@@ -3,10 +3,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { cn } from '../helpers/cn/cn';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { X } from 'lucide-react';
|
|
6
|
-
const badgeVariants = cva('inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap', {
|
|
6
|
+
const badgeVariants = cva('inline-flex max-w-full min-w-0 items-center gap-1 rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap', {
|
|
7
7
|
variants: {
|
|
8
8
|
variant: {
|
|
9
|
-
default: 'bg-muted text-
|
|
9
|
+
default: 'border-muted-foreground bg-muted text-foreground',
|
|
10
10
|
primary: 'bg-primary-border/30 text-primary',
|
|
11
11
|
success: 'bg-success/15 text-success-foreground',
|
|
12
12
|
attention: 'bg-attention-muted text-attention-foreground',
|
package/dist/Button/Button.js
CHANGED
|
@@ -9,7 +9,7 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
|
|
|
9
9
|
variant: {
|
|
10
10
|
ghost: 'hover:bg-accent aria-expanded:bg-accent dark:hover:bg-accent/50',
|
|
11
11
|
primary: 'bg-primary text-primary-foreground font-medium hover:bg-primary/90',
|
|
12
|
-
outline: 'border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:
|
|
12
|
+
outline: 'border-input-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30 dark:hover:bg-input/50',
|
|
13
13
|
destructive: 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40',
|
|
14
14
|
attention: 'text-attention-foreground hover:bg-attention-muted',
|
|
15
15
|
subtle: 'text-muted-foreground hover:text-primary',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Oklch = {
|
|
2
|
+
lightness: number;
|
|
3
|
+
chroma: number;
|
|
4
|
+
hue: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* WCAG 2.x contrast ratio between two oklch colors, in the range [1, 21].
|
|
8
|
+
* Order-independent. Alpha is not modeled — pass an already-composited color if a
|
|
9
|
+
* token is translucent.
|
|
10
|
+
*/
|
|
11
|
+
export declare const contrastRatio: (foreground: Oklch, background: Oklch) => number;
|
|
12
|
+
export type { Oklch };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const DEGREES_TO_RADIANS = Math.PI / 180;
|
|
2
|
+
const clampUnit = (value) => Math.min(1, Math.max(0, value));
|
|
3
|
+
/**
|
|
4
|
+
* Linear-sRGB channels for an oklch color, via Björn Ottosson's oklab→linear
|
|
5
|
+
* matrices. Channels are clamped into gamut so an out-of-sRGB color folds to its
|
|
6
|
+
* nearest representable luminance rather than producing a nonsense ratio.
|
|
7
|
+
*/
|
|
8
|
+
const toLinearSrgb = ({ lightness, chroma, hue }) => {
|
|
9
|
+
const hueRadians = hue * DEGREES_TO_RADIANS;
|
|
10
|
+
const a = chroma * Math.cos(hueRadians);
|
|
11
|
+
const b = chroma * Math.sin(hueRadians);
|
|
12
|
+
const longRoot = lightness + 0.3963377774 * a + 0.2158037573 * b;
|
|
13
|
+
const mediumRoot = lightness - 0.1055613458 * a - 0.0638541728 * b;
|
|
14
|
+
const shortRoot = lightness - 0.0894841775 * a - 1.291485548 * b;
|
|
15
|
+
const long = longRoot ** 3;
|
|
16
|
+
const medium = mediumRoot ** 3;
|
|
17
|
+
const short = shortRoot ** 3;
|
|
18
|
+
return [
|
|
19
|
+
clampUnit(4.0767416621 * long - 3.3077115913 * medium + 0.2309699292 * short),
|
|
20
|
+
clampUnit(-1.2684380046 * long + 2.6097574011 * medium - 0.3413193965 * short),
|
|
21
|
+
clampUnit(-0.0041960863 * long - 0.7034186147 * medium + 1.707614701 * short),
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
const relativeLuminance = (color) => {
|
|
25
|
+
const [red, green, blue] = toLinearSrgb(color);
|
|
26
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* WCAG 2.x contrast ratio between two oklch colors, in the range [1, 21].
|
|
30
|
+
* Order-independent. Alpha is not modeled — pass an already-composited color if a
|
|
31
|
+
* token is translucent.
|
|
32
|
+
*/
|
|
33
|
+
export const contrastRatio = (foreground, background) => {
|
|
34
|
+
const lighter = Math.max(relativeLuminance(foreground), relativeLuminance(background));
|
|
35
|
+
const darker = Math.min(relativeLuminance(foreground), relativeLuminance(background));
|
|
36
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -35,7 +35,6 @@ If you're editing `@carbonid1/design-system` itself (adding a primitive, changin
|
|
|
35
35
|
|
|
36
36
|
## Core rules
|
|
37
37
|
|
|
38
|
-
- Never use native `<select>` — use `Select`
|
|
39
38
|
- Never build a tooltip, context menu, or toast from scratch — use `Tooltip`, `ContextMenu`, `toast()`
|
|
40
39
|
- All icons from `lucide-react` — search `lucide.dev/icons` before creating anything custom. If nothing fits, build via Lucide's `Icon` + `iconNode`, don't reach for another library.
|
|
41
40
|
- All color through semantic tokens — no hardcoded Tailwind color classes. See [references/theming.md](references/theming.md).
|
package/themes/dashboard.css
CHANGED
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
--color-success-foreground: var(--success-foreground);
|
|
59
59
|
--color-border: var(--border);
|
|
60
60
|
--color-input: var(--input);
|
|
61
|
+
--color-input-border: var(--input-border);
|
|
61
62
|
--color-ring: var(--ring);
|
|
62
63
|
/* Font families. Override a role by setting its `--font-*-custom` variable;
|
|
63
64
|
* each falls back to a system stack. */
|
|
@@ -122,7 +123,14 @@
|
|
|
122
123
|
--destructive: oklch(0.58 0.22 27);
|
|
123
124
|
--border: oklch(0.922 0 0);
|
|
124
125
|
--input: oklch(0.922 0 0);
|
|
125
|
-
|
|
126
|
+
/* Resting boundary for form controls (Button outline, inputs) — distinct from
|
|
127
|
+
* decorative --border and the --input fill. Dark enough to clear WCAG 1.4.11
|
|
128
|
+
* (3:1) against the surfaces controls sit on; the contrast test guards it. */
|
|
129
|
+
--input-border: oklch(0.62 0 0);
|
|
130
|
+
/* Neutral focus ring (border-ring + ring-ring/50 halo). Dark enough that the
|
|
131
|
+
* solid border clears WCAG 1.4.11 (3:1 non-text) against the lightest surface
|
|
132
|
+
* — the themes contrast test guards this floor. */
|
|
133
|
+
--ring: oklch(0.6 0 0);
|
|
126
134
|
--highlight: oklch(0.901 0.082 85.84);
|
|
127
135
|
--highlight-foreground: oklch(0.344 0.06 58.6);
|
|
128
136
|
--highlight-muted: oklch(0.962 0.042 95.28);
|
|
@@ -159,6 +167,7 @@
|
|
|
159
167
|
--destructive: oklch(0.704 0.191 22.216);
|
|
160
168
|
--border: oklch(0.373 0.031 260 / 50%);
|
|
161
169
|
--input: oklch(0.373 0.031 260 / 60%);
|
|
170
|
+
--input-border: oklch(0.58 0.025 262);
|
|
162
171
|
--ring: oklch(0.551 0.023 264);
|
|
163
172
|
--highlight: oklch(0.55 0.07 268);
|
|
164
173
|
--highlight-foreground: oklch(0.95 0.02 265);
|
package/themes/reader.css
CHANGED
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
--color-success-foreground: var(--success-foreground);
|
|
81
81
|
--color-border: var(--border);
|
|
82
82
|
--color-input: var(--input);
|
|
83
|
+
--color-input-border: var(--input-border);
|
|
83
84
|
--color-ring: var(--ring);
|
|
84
85
|
/* Font families. Override a role by setting its `--font-*-custom` variable;
|
|
85
86
|
* each falls back to a system stack. */
|
|
@@ -147,7 +148,14 @@
|
|
|
147
148
|
--destructive: oklch(0.58 0.22 27);
|
|
148
149
|
--border: oklch(0.922 0 0);
|
|
149
150
|
--input: oklch(0.922 0 0);
|
|
150
|
-
|
|
151
|
+
/* Resting boundary for form controls (Button outline, inputs) — distinct from
|
|
152
|
+
* decorative --border and the --input fill. Dark enough to clear WCAG 1.4.11
|
|
153
|
+
* (3:1) against the surfaces controls sit on; the contrast test guards it. */
|
|
154
|
+
--input-border: oklch(0.62 0 0);
|
|
155
|
+
/* Neutral focus ring (border-ring + ring-ring/50 halo). Dark enough that the
|
|
156
|
+
* solid border clears WCAG 1.4.11 (3:1 non-text) against the lightest surface
|
|
157
|
+
* — the themes contrast test guards this floor. */
|
|
158
|
+
--ring: oklch(0.6 0 0);
|
|
151
159
|
--highlight: oklch(0.901 0.082 85.84);
|
|
152
160
|
--highlight-foreground: oklch(0.344 0.06 58.6);
|
|
153
161
|
--highlight-muted: oklch(0.962 0.042 95.28);
|
|
@@ -189,6 +197,7 @@
|
|
|
189
197
|
--destructive: oklch(0.704 0.191 22.216);
|
|
190
198
|
--border: oklch(0.373 0.031 260 / 50%);
|
|
191
199
|
--input: oklch(0.373 0.031 260 / 60%);
|
|
200
|
+
--input-border: oklch(0.58 0.025 262);
|
|
192
201
|
--ring: oklch(0.551 0.023 264);
|
|
193
202
|
--highlight: oklch(0.55 0.07 268);
|
|
194
203
|
--highlight-foreground: oklch(0.95 0.02 265);
|