@softure-ai/theme-notion 0.2.0 → 0.3.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/CHANGELOG.md +136 -0
- package/README.md +167 -16
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/messages/en.d.ts +17 -0
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/en.js +10 -0
- package/dist/messages/en.js.map +1 -1
- package/dist/messages/index.d.ts +17 -0
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/notion/Code.d.ts +8 -0
- package/dist/notion/Code.d.ts.map +1 -0
- package/dist/notion/Code.js +12 -0
- package/dist/notion/Code.js.map +1 -0
- package/dist/notion/FilterChip.d.ts +24 -0
- package/dist/notion/FilterChip.d.ts.map +1 -0
- package/dist/notion/FilterChip.js +18 -0
- package/dist/notion/FilterChip.js.map +1 -0
- package/dist/notion/Sortable.d.ts +36 -0
- package/dist/notion/Sortable.d.ts.map +1 -0
- package/dist/notion/Sortable.js +83 -0
- package/dist/notion/Sortable.js.map +1 -0
- package/dist/notion/Stats.d.ts +4 -0
- package/dist/notion/Stats.d.ts.map +1 -1
- package/dist/notion/Stats.js +10 -3
- package/dist/notion/Stats.js.map +1 -1
- package/dist/notion/Steps.d.ts +18 -0
- package/dist/notion/Steps.d.ts.map +1 -0
- package/dist/notion/Steps.js +32 -0
- package/dist/notion/Steps.js.map +1 -0
- package/dist/page.css +22 -0
- package/dist/theme.css +55 -46
- package/dist/tokens.d.ts +82 -64
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +22 -19
- package/dist/tokens.js.map +1 -1
- package/dist/ui/alert.js +1 -1
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/badge.js +33 -13
- package/dist/ui/badge.js.map +1 -1
- package/dist/ui/button-group.js +1 -1
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.js +3 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/empty.js +1 -1
- package/dist/ui/empty.js.map +1 -1
- package/dist/ui/field.js +2 -2
- package/dist/ui/field.js.map +1 -1
- package/dist/ui/item.d.ts.map +1 -1
- package/dist/ui/item.js +8 -3
- package/dist/ui/item.js.map +1 -1
- package/dist/ui/progress.d.ts +4 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +9 -2
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.d.ts.map +1 -0
- package/dist/ui/radio-group.js +14 -0
- package/dist/ui/radio-group.js.map +1 -0
- package/dist/ui/scroll-area.d.ts +3 -1
- package/dist/ui/scroll-area.d.ts.map +1 -1
- package/dist/ui/scroll-area.js +2 -2
- package/dist/ui/scroll-area.js.map +1 -1
- package/dist/ui/select.js +2 -2
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sidebar.js +4 -4
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/tabs.js +1 -1
- package/dist/ui/tabs.js.map +1 -1
- package/package.json +16 -5
- package/src/index.ts +15 -0
- package/src/messages/en.ts +11 -0
- package/src/notion/Code.tsx +39 -0
- package/src/notion/FilterChip.tsx +71 -0
- package/src/notion/Sortable.tsx +235 -0
- package/src/notion/Stats.tsx +23 -3
- package/src/notion/Steps.tsx +102 -0
- package/src/page.css +22 -0
- package/src/tokens.ts +22 -19
- package/src/ui/alert.tsx +1 -1
- package/src/ui/badge.tsx +35 -13
- package/src/ui/button-group.tsx +1 -1
- package/src/ui/button.tsx +3 -3
- package/src/ui/checkbox.tsx +1 -1
- package/src/ui/dropdown-menu.tsx +1 -1
- package/src/ui/empty.tsx +1 -1
- package/src/ui/field.tsx +2 -2
- package/src/ui/item.tsx +16 -7
- package/src/ui/progress.tsx +19 -2
- package/src/ui/radio-group.tsx +44 -0
- package/src/ui/scroll-area.tsx +11 -2
- package/src/ui/select.tsx +2 -2
- package/src/ui/sidebar.tsx +4 -4
- package/src/ui/tabs.tsx +3 -3
package/src/notion/Stats.tsx
CHANGED
|
@@ -2,10 +2,11 @@ import { ChevronRight } from "lucide-react";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
import { Badge } from "../ui/badge.js";
|
|
5
|
+
import { Progress } from "../ui/progress.js";
|
|
5
6
|
import { cn } from "../lib/utils.js";
|
|
6
7
|
|
|
7
8
|
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
-
import { TONE_COLORS, TONE_TEXT, type Tone } from "./tones.js";
|
|
9
|
+
import { TONE_COLORS, TONE_FILL, TONE_TEXT, type Tone } from "./tones.js";
|
|
9
10
|
|
|
10
11
|
export interface StatsFoldProps {
|
|
11
12
|
/** The section's heading. */
|
|
@@ -50,6 +51,10 @@ export interface StatCard {
|
|
|
50
51
|
readonly hint?: string;
|
|
51
52
|
readonly tone?: Tone;
|
|
52
53
|
readonly aside?: StatCardAside;
|
|
54
|
+
/** A bar under the figure, 0–100 (clamped); in the card's `tone` when it has one, primary otherwise. */
|
|
55
|
+
readonly progress?: number;
|
|
56
|
+
/** The bar's accessible name; defaults to `label`. */
|
|
57
|
+
readonly progressLabel?: string;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
export interface StatCardsProps {
|
|
@@ -62,13 +67,19 @@ export interface StatCardsProps {
|
|
|
62
67
|
readonly isOneRow?: boolean;
|
|
63
68
|
}
|
|
64
69
|
|
|
70
|
+
function clampProgress(progress: number): number {
|
|
71
|
+
if (!Number.isFinite(progress)) return 0;
|
|
72
|
+
return Math.min(100, Math.max(0, progress));
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
function getStatCardsLayout(isFullWidth: boolean, isOneRow: boolean): "row" | "full" | "grid" {
|
|
66
76
|
if (isOneRow) return "row";
|
|
67
77
|
return isFullWidth ? "full" : "grid";
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
// Summary figures as a row of cards wrapping on a narrow screen: the label, the figure in its tone's colour (never
|
|
71
|
-
// broken, tabular numbers), an optional
|
|
81
|
+
// broken, tabular numbers), an optional bar under it, an optional note and an optional short figure on its right as a
|
|
82
|
+
// tag.
|
|
72
83
|
export function StatCards({ label, cards, isFullWidth = false, isOneRow = false }: StatCardsProps) {
|
|
73
84
|
return (
|
|
74
85
|
<ul
|
|
@@ -91,11 +102,20 @@ export function StatCards({ label, cards, isFullWidth = false, isOneRow = false
|
|
|
91
102
|
data-stat={card.key}
|
|
92
103
|
className="flex min-w-0 items-start justify-between gap-2 rounded-lg bg-card p-3 text-card-foreground shadow-card"
|
|
93
104
|
>
|
|
94
|
-
<div className="min-w-0">
|
|
105
|
+
<div className={cn("min-w-0", card.progress !== undefined && "flex-1")}>
|
|
95
106
|
<div className="text-section-label text-muted-foreground">{card.label}</div>
|
|
96
107
|
<div data-tone={tone} className={cn("mt-1 text-heading-3 whitespace-nowrap tabular-nums", TONE_TEXT[tone])}>
|
|
97
108
|
{card.value}
|
|
98
109
|
</div>
|
|
110
|
+
{card.progress === undefined ? null : (
|
|
111
|
+
<Progress
|
|
112
|
+
value={clampProgress(card.progress)}
|
|
113
|
+
aria-label={card.progressLabel ?? card.label}
|
|
114
|
+
data-slot="stat-card-progress"
|
|
115
|
+
className="mt-2"
|
|
116
|
+
indicatorClassName={card.tone === undefined ? undefined : TONE_FILL[card.tone]}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
99
119
|
{card.hint === undefined ? null : <div className="mt-1 text-small text-muted-foreground">{card.hint}</div>}
|
|
100
120
|
</div>
|
|
101
121
|
{card.aside === undefined ? null : (
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { en as messages } from "../messages/en.js";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
|
|
6
|
+
export type StepState = "done" | "current" | "todo" | "failed";
|
|
7
|
+
|
|
8
|
+
export interface StepItem {
|
|
9
|
+
// Kept on the step as `data-step`.
|
|
10
|
+
readonly key: string;
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly note?: ReactNode;
|
|
13
|
+
// Defaults to `todo`.
|
|
14
|
+
readonly state?: StepState;
|
|
15
|
+
// Drawn at the step's end, e.g. a tag naming the service the step uses.
|
|
16
|
+
readonly aside?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// `row`: a wrapping grid of cards; `list`: a compact vertical list.
|
|
20
|
+
export type StepsLayout = "row" | "list";
|
|
21
|
+
|
|
22
|
+
export interface StepsProps {
|
|
23
|
+
// The list's accessible name.
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly steps: readonly StepItem[];
|
|
26
|
+
readonly layout?: StepsLayout;
|
|
27
|
+
// Each state's word for assistive technology, from the app's message layer.
|
|
28
|
+
readonly stateLabels?: Partial<Readonly<Record<StepState, string>>>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Literal class names per state, so Tailwind generates each one (the theme's `@source` covers this folder).
|
|
32
|
+
const STEP_NUMBER_STATE: Readonly<Record<StepState, string>> = {
|
|
33
|
+
done: "bg-green-tag text-green-tag-foreground",
|
|
34
|
+
current: "bg-primary text-primary-foreground",
|
|
35
|
+
todo: "bg-muted text-muted-foreground",
|
|
36
|
+
failed: "bg-red-tag text-red-tag-foreground",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const STEPS_LIST: Readonly<Record<StepsLayout, string>> = {
|
|
40
|
+
row: "grid grid-cols-[repeat(auto-fill,minmax(min(12rem,100%),1fr))] gap-2",
|
|
41
|
+
list: "flex flex-col",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const STEP_ITEM: Readonly<Record<StepsLayout, string>> = {
|
|
45
|
+
row: "flex min-w-0 items-start gap-2 rounded-lg bg-card p-3 text-card-foreground shadow-card data-[state=current]:bg-blue-bg",
|
|
46
|
+
list: "flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-120 hover:bg-accent",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const STEP_NUMBER_SHAPE: Readonly<Record<StepsLayout, string>> = {
|
|
50
|
+
row: "rounded-full",
|
|
51
|
+
list: "rounded-sm",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// An ordered process: each step's number in a badge coloured by its state, its title, an optional note under it and
|
|
55
|
+
// an optional aside at its end. The state is also a word for assistive technology, so it never reads by colour alone.
|
|
56
|
+
export function Steps({ label, steps, layout = "row", stateLabels }: StepsProps) {
|
|
57
|
+
const words = { ...messages.steps, ...stateLabels };
|
|
58
|
+
return (
|
|
59
|
+
<ol aria-label={label} data-slot="steps" data-layout={layout} className={STEPS_LIST[layout]}>
|
|
60
|
+
{steps.map((step, index) => {
|
|
61
|
+
const state = step.state ?? "todo";
|
|
62
|
+
return (
|
|
63
|
+
<li
|
|
64
|
+
key={step.key}
|
|
65
|
+
data-step={step.key}
|
|
66
|
+
data-state={state}
|
|
67
|
+
aria-current={state === "current" ? "step" : undefined}
|
|
68
|
+
className={STEP_ITEM[layout]}
|
|
69
|
+
>
|
|
70
|
+
<span
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
data-slot="step-number"
|
|
73
|
+
className={cn(
|
|
74
|
+
"mt-px flex size-5 shrink-0 items-center justify-center text-small font-medium tabular-nums",
|
|
75
|
+
STEP_NUMBER_SHAPE[layout],
|
|
76
|
+
STEP_NUMBER_STATE[state],
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{index + 1}
|
|
80
|
+
</span>
|
|
81
|
+
<div className="min-w-0 flex-1">
|
|
82
|
+
<div className="text-sm font-medium">
|
|
83
|
+
{step.title}
|
|
84
|
+
<span className="sr-only">, {words[state]}</span>
|
|
85
|
+
</div>
|
|
86
|
+
{step.note === undefined ? null : (
|
|
87
|
+
<div data-slot="step-note" className="mt-0.5 text-small text-muted-foreground">
|
|
88
|
+
{step.note}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
{step.aside === undefined ? null : (
|
|
93
|
+
<div data-slot="step-aside" className="shrink-0">
|
|
94
|
+
{step.aside}
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</li>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
</ol>
|
|
101
|
+
);
|
|
102
|
+
}
|
package/src/page.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The Notion page base: the rules of the design system's base layer that the kit's `base.css` leaves to the theme.
|
|
3
|
+
* Text outside the components takes the panel size (14 px, `text-sm`), selected text the blue tag colour, and the page
|
|
4
|
+
* greyscale font smoothing on macOS. In `@layer base`, so every component and utility overrides it.
|
|
5
|
+
*
|
|
6
|
+
* Import it after `theme.css` and the kit's `base.css`, through the app's Tailwind (it reads the type scale with
|
|
7
|
+
* `--theme()`).
|
|
8
|
+
*/
|
|
9
|
+
@layer base {
|
|
10
|
+
html {
|
|
11
|
+
-webkit-font-smoothing: antialiased;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
body {
|
|
15
|
+
font-size: --theme(--text-sm);
|
|
16
|
+
line-height: --theme(--text-sm--line-height);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
::selection {
|
|
20
|
+
background: var(--blue-tag);
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/tokens.ts
CHANGED
|
@@ -14,67 +14,69 @@ export const NOTION_THEME = defineTheme({
|
|
|
14
14
|
"card-foreground": { light: "#37352f", dark: "#d4d4d4" },
|
|
15
15
|
popover: { light: "#ffffff", dark: "#252525" },
|
|
16
16
|
"popover-foreground": { light: "#37352f", dark: "#d4d4d4" },
|
|
17
|
-
primary: { light: "#
|
|
17
|
+
primary: { light: "#0171cf", dark: "#0171cf" },
|
|
18
18
|
"primary-foreground": { light: "#ffffff", dark: "#ffffff" },
|
|
19
|
-
"primary-hover": { light: "#
|
|
19
|
+
"primary-hover": { light: "#0066b8", dark: "#0066b8" },
|
|
20
|
+
link: { light: "#0171cf", dark: "#409cfd" },
|
|
20
21
|
secondary: { light: "#f1f1ef", dark: "#2f2f2f" },
|
|
21
22
|
"secondary-foreground": { light: "#37352f", dark: "#d4d4d4" },
|
|
23
|
+
"code-foreground": { light: "#c33c39", dark: "#f86a66" },
|
|
22
24
|
muted: { light: "#f7f7f5", dark: "#202020" },
|
|
23
|
-
"muted-foreground": { light: "#
|
|
25
|
+
"muted-foreground": { light: "#656461", dark: "#a5a5a5" },
|
|
24
26
|
accent: { light: "rgba(55, 53, 47, 0.08)", dark: "rgba(255, 255, 255, 0.055)" },
|
|
25
27
|
"accent-foreground": { light: "#37352f", dark: "#d4d4d4" },
|
|
26
28
|
"accent-strong": { light: "rgba(55, 53, 47, 0.16)", dark: "rgba(255, 255, 255, 0.1)" },
|
|
27
|
-
destructive: { light: "#
|
|
29
|
+
destructive: { light: "#c63339", dark: "#fd6866" },
|
|
28
30
|
"destructive-foreground": { light: "#ffffff", dark: "#ffffff" },
|
|
29
31
|
border: { light: "#e9e9e7", dark: "#2f2f2f" },
|
|
30
|
-
input: { light: "rgba(15, 15, 15, 0.
|
|
32
|
+
input: { light: "rgba(15, 15, 15, 0.46)", dark: "rgba(255, 255, 255, 0.36)" },
|
|
31
33
|
field: { light: "rgba(242, 241, 238, 0.6)", dark: "rgba(255, 255, 255, 0.055)" },
|
|
32
|
-
"control-off": { light: "rgba(135, 131, 120, 0.
|
|
33
|
-
ring: { light: "rgba(
|
|
34
|
+
"control-off": { light: "rgba(135, 131, 120, 0.95)", dark: "rgba(202, 196, 183, 0.5)" },
|
|
35
|
+
ring: { light: "rgba(1, 113, 207, 0.8)", dark: "rgba(64, 156, 253, 0.65)" },
|
|
34
36
|
sidebar: { light: "#f7f7f5", dark: "#202020" },
|
|
35
37
|
"sidebar-foreground": { light: "#5f5e5b", dark: "#9b9b9b" },
|
|
36
|
-
"sidebar-primary": { light: "#
|
|
38
|
+
"sidebar-primary": { light: "#0171cf", dark: "#0171cf" },
|
|
37
39
|
"sidebar-primary-foreground": { light: "#ffffff", dark: "#ffffff" },
|
|
38
40
|
"sidebar-accent": { light: "rgba(55, 53, 47, 0.08)", dark: "rgba(255, 255, 255, 0.055)" },
|
|
39
41
|
"sidebar-accent-foreground": { light: "#37352f", dark: "#d4d4d4" },
|
|
40
42
|
"sidebar-border": { light: "#ededeb", dark: "#2a2a2a" },
|
|
41
|
-
"sidebar-ring": { light: "rgba(
|
|
43
|
+
"sidebar-ring": { light: "rgba(1, 113, 207, 0.8)", dark: "rgba(64, 156, 253, 0.65)" },
|
|
42
44
|
tooltip: { light: "#0f0f0f", dark: "#373737" },
|
|
43
45
|
"tooltip-foreground": { light: "rgba(255, 255, 255, 0.9)", dark: "rgba(255, 255, 255, 0.9)" },
|
|
44
46
|
overlay: { light: "rgba(15, 15, 15, 0.6)", dark: "rgba(0, 0, 0, 0.6)" },
|
|
45
|
-
gray: { light: "#
|
|
47
|
+
gray: { light: "#656461", dark: "#a5a5a5" },
|
|
46
48
|
"gray-bg": { light: "#f1f1ef", dark: "#2f2f2f" },
|
|
47
49
|
"gray-tag": { light: "#e3e2e0", dark: "#5a5a5a" },
|
|
48
50
|
"gray-tag-foreground": { light: "#32302c", dark: "rgba(255, 255, 255, 0.81)" },
|
|
49
|
-
brown: { light: "#
|
|
51
|
+
brown: { light: "#98644d", dark: "#ba856f" },
|
|
50
52
|
"brown-bg": { light: "#f4eeee", dark: "#4a3228" },
|
|
51
53
|
"brown-tag": { light: "#eee0da", dark: "#603b2c" },
|
|
52
54
|
"brown-tag-foreground": { light: "#442a1e", dark: "rgba(255, 255, 255, 0.81)" },
|
|
53
|
-
orange: { light: "#
|
|
55
|
+
orange: { light: "#af5a02", dark: "#c77d48" },
|
|
54
56
|
"orange-bg": { light: "#fbecdd", dark: "#5c3b23" },
|
|
55
57
|
"orange-tag": { light: "#fadec9", dark: "#854c1d" },
|
|
56
58
|
"orange-tag-foreground": { light: "#49290e", dark: "rgba(255, 255, 255, 0.81)" },
|
|
57
|
-
yellow: { light: "#
|
|
59
|
+
yellow: { light: "#986702", dark: "#ca984d" },
|
|
58
60
|
"yellow-bg": { light: "#fbf3db", dark: "#564328" },
|
|
59
|
-
"yellow-tag": { light: "#fdecc8", dark: "#
|
|
61
|
+
"yellow-tag": { light: "#fdecc8", dark: "#825c23" },
|
|
60
62
|
"yellow-tag-foreground": { light: "#402c1b", dark: "rgba(255, 255, 255, 0.81)" },
|
|
61
|
-
green: { light: "#
|
|
63
|
+
green: { light: "#3e7d5c", dark: "#529e72" },
|
|
62
64
|
"green-bg": { light: "#edf3ec", dark: "#243d30" },
|
|
63
65
|
"green-tag": { light: "#dbeddb", dark: "#2b593f" },
|
|
64
66
|
"green-tag-foreground": { light: "#1c3829", dark: "rgba(255, 255, 255, 0.81)" },
|
|
65
|
-
blue: { light: "#
|
|
67
|
+
blue: { light: "#2b77a2", dark: "#379ad3" },
|
|
66
68
|
"blue-bg": { light: "#e7f3f8", dark: "#143a4e" },
|
|
67
69
|
"blue-tag": { light: "#d3e5ef", dark: "#28456c" },
|
|
68
70
|
"blue-tag-foreground": { light: "#183347", dark: "rgba(255, 255, 255, 0.81)" },
|
|
69
|
-
purple: { light: "#
|
|
71
|
+
purple: { light: "#8a5faa", dark: "#a974e0" },
|
|
70
72
|
"purple-bg": { light: "#f6f3f9", dark: "#3c2d49" },
|
|
71
73
|
"purple-tag": { light: "#e8deee", dark: "#492f64" },
|
|
72
74
|
"purple-tag-foreground": { light: "#412454", dark: "rgba(255, 255, 255, 0.81)" },
|
|
73
|
-
pink: { light: "#
|
|
75
|
+
pink: { light: "#ba4684", dark: "#dc61a0" },
|
|
74
76
|
"pink-bg": { light: "#faf1f5", dark: "#4e2c3c" },
|
|
75
77
|
"pink-tag": { light: "#f5e0e9", dark: "#69314c" },
|
|
76
78
|
"pink-tag-foreground": { light: "#4c2337", dark: "rgba(255, 255, 255, 0.81)" },
|
|
77
|
-
red: { light: "#
|
|
79
|
+
red: { light: "#c8413d", dark: "#ea5e5b" },
|
|
78
80
|
"red-bg": { light: "#fdebec", dark: "#522e2a" },
|
|
79
81
|
"red-tag": { light: "#ffe2dd", dark: "#6e3630" },
|
|
80
82
|
"red-tag-foreground": { light: "#5d1715", dark: "rgba(255, 255, 255, 0.81)" },
|
|
@@ -131,6 +133,7 @@ export const NOTION_THEME = defineTheme({
|
|
|
131
133
|
"content-width-wide": "1152px",
|
|
132
134
|
"control-height": "28px",
|
|
133
135
|
"row-height": "34px",
|
|
136
|
+
"touch-target": "44px",
|
|
134
137
|
},
|
|
135
138
|
// The design system allows only its own colours, so no raw Tailwind colour utility exists.
|
|
136
139
|
clearDefaultPalette: true,
|
package/src/ui/alert.tsx
CHANGED
|
@@ -9,7 +9,7 @@ const alertVariants = cva(
|
|
|
9
9
|
variant: {
|
|
10
10
|
default: "bg-card text-card-foreground",
|
|
11
11
|
destructive:
|
|
12
|
-
"bg-card text-destructive *:data-[slot=alert-description]:text-destructive
|
|
12
|
+
"bg-card text-destructive *:data-[slot=alert-description]:text-destructive [&>svg]:text-current",
|
|
13
13
|
gray: "border-transparent bg-gray-bg text-foreground [&>svg]:text-gray *:data-[slot=alert-description]:text-foreground",
|
|
14
14
|
brown: "border-transparent bg-brown-bg text-foreground [&>svg]:text-brown *:data-[slot=alert-description]:text-foreground",
|
|
15
15
|
orange: "border-transparent bg-orange-bg text-foreground [&>svg]:text-orange *:data-[slot=alert-description]:text-foreground",
|
package/src/ui/badge.tsx
CHANGED
|
@@ -3,36 +3,58 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
3
3
|
import { cn } from "../lib/utils.js"
|
|
4
4
|
import { Slot } from "radix-ui"
|
|
5
5
|
|
|
6
|
+
const TAG_COLORS = {
|
|
7
|
+
default: "bg-default-tag text-default-tag-foreground",
|
|
8
|
+
gray: "bg-gray-tag text-gray-tag-foreground",
|
|
9
|
+
brown: "bg-brown-tag text-brown-tag-foreground",
|
|
10
|
+
orange: "bg-orange-tag text-orange-tag-foreground",
|
|
11
|
+
yellow: "bg-yellow-tag text-yellow-tag-foreground",
|
|
12
|
+
green: "bg-green-tag text-green-tag-foreground",
|
|
13
|
+
blue: "bg-blue-tag text-blue-tag-foreground",
|
|
14
|
+
purple: "bg-purple-tag text-purple-tag-foreground",
|
|
15
|
+
pink: "bg-pink-tag text-pink-tag-foreground",
|
|
16
|
+
red: "bg-red-tag text-red-tag-foreground",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Every variant a palette colour applies to: all but destructive.
|
|
20
|
+
const COLORED_VARIANTS = ["default", "secondary", "outline", "ghost", "link", "tag"] as const
|
|
21
|
+
|
|
6
22
|
const badgeVariants = cva(
|
|
7
23
|
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
8
24
|
{
|
|
9
25
|
variants: {
|
|
10
26
|
variant: {
|
|
11
|
-
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary
|
|
27
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary-hover",
|
|
12
28
|
secondary:
|
|
13
29
|
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
14
30
|
destructive:
|
|
15
|
-
"bg-destructive text-
|
|
31
|
+
"bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90 dark:[a&]:hover:bg-destructive/50",
|
|
16
32
|
outline:
|
|
17
33
|
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
18
34
|
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
19
|
-
link: "text-
|
|
35
|
+
link: "text-link underline-offset-4 [a&]:hover:underline",
|
|
20
36
|
tag: "h-5 rounded-xs px-1.5 py-0 text-sm font-normal",
|
|
21
37
|
},
|
|
22
38
|
color: {
|
|
23
39
|
none: "",
|
|
24
|
-
default: "
|
|
25
|
-
gray: "
|
|
26
|
-
brown: "
|
|
27
|
-
orange: "
|
|
28
|
-
yellow: "
|
|
29
|
-
green: "
|
|
30
|
-
blue: "
|
|
31
|
-
purple: "
|
|
32
|
-
pink: "
|
|
33
|
-
red: "
|
|
40
|
+
default: "",
|
|
41
|
+
gray: "",
|
|
42
|
+
brown: "",
|
|
43
|
+
orange: "",
|
|
44
|
+
yellow: "",
|
|
45
|
+
green: "",
|
|
46
|
+
blue: "",
|
|
47
|
+
purple: "",
|
|
48
|
+
pink: "",
|
|
49
|
+
red: "",
|
|
34
50
|
},
|
|
35
51
|
},
|
|
52
|
+
// A destructive badge keeps its own fill and text whatever its colour.
|
|
53
|
+
compoundVariants: Object.entries(TAG_COLORS).map(([color, className]) => ({
|
|
54
|
+
variant: [...COLORED_VARIANTS],
|
|
55
|
+
color: color as keyof typeof TAG_COLORS,
|
|
56
|
+
className,
|
|
57
|
+
})),
|
|
36
58
|
defaultVariants: {
|
|
37
59
|
variant: "default",
|
|
38
60
|
color: "none",
|
package/src/ui/button-group.tsx
CHANGED
|
@@ -67,7 +67,7 @@ function ButtonGroupSeparator({
|
|
|
67
67
|
data-slot="button-group-separator"
|
|
68
68
|
orientation={orientation}
|
|
69
69
|
className={cn(
|
|
70
|
-
"relative m-0! self-stretch bg-
|
|
70
|
+
"relative m-0! self-stretch bg-border data-[orientation=vertical]:h-auto",
|
|
71
71
|
className
|
|
72
72
|
)}
|
|
73
73
|
{...props}
|
package/src/ui/button.tsx
CHANGED
|
@@ -10,12 +10,12 @@ const buttonVariants = cva(
|
|
|
10
10
|
variant: {
|
|
11
11
|
default: "bg-primary text-primary-foreground hover:bg-primary-hover",
|
|
12
12
|
destructive:
|
|
13
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",
|
|
13
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:hover:bg-destructive/50 dark:focus-visible:ring-destructive/40",
|
|
14
14
|
outline:
|
|
15
|
-
"border border-
|
|
15
|
+
"border border-border bg-background hover:bg-accent hover:text-accent-foreground",
|
|
16
16
|
secondary: "bg-secondary text-secondary-foreground hover:bg-accent-strong",
|
|
17
17
|
ghost: "text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
18
|
-
link: "text-
|
|
18
|
+
link: "text-link underline-offset-4 hover:underline",
|
|
19
19
|
},
|
|
20
20
|
size: {
|
|
21
21
|
default:
|
package/src/ui/checkbox.tsx
CHANGED
|
@@ -22,7 +22,7 @@ function Checkbox({
|
|
|
22
22
|
data-slot="checkbox-indicator"
|
|
23
23
|
className="grid place-content-center text-current transition-none"
|
|
24
24
|
>
|
|
25
|
-
<CheckIcon className="
|
|
25
|
+
<CheckIcon className="size-3.5" />
|
|
26
26
|
</CheckboxPrimitive.Indicator>
|
|
27
27
|
</CheckboxPrimitive.Root>
|
|
28
28
|
)
|
package/src/ui/dropdown-menu.tsx
CHANGED
|
@@ -73,7 +73,7 @@ function DropdownMenuItem({
|
|
|
73
73
|
data-inset={inset}
|
|
74
74
|
data-variant={variant}
|
|
75
75
|
className={cn(
|
|
76
|
-
"relative flex cursor-default items-center gap-2 rounded-md min-h-7 px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/
|
|
76
|
+
"relative flex cursor-default items-center gap-2 rounded-md min-h-7 px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
|
|
77
77
|
className
|
|
78
78
|
)}
|
|
79
79
|
{...props}
|
package/src/ui/empty.tsx
CHANGED
|
@@ -72,7 +72,7 @@ function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
72
72
|
<div
|
|
73
73
|
data-slot="empty-description"
|
|
74
74
|
className={cn(
|
|
75
|
-
"text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-
|
|
75
|
+
"text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-link",
|
|
76
76
|
className
|
|
77
77
|
)}
|
|
78
78
|
{...props}
|
package/src/ui/field.tsx
CHANGED
|
@@ -130,7 +130,7 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
130
130
|
<div
|
|
131
131
|
data-slot="field-label"
|
|
132
132
|
className={cn(
|
|
133
|
-
"
|
|
133
|
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
|
|
134
134
|
className
|
|
135
135
|
)}
|
|
136
136
|
{...props}
|
|
@@ -145,7 +145,7 @@ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
145
145
|
className={cn(
|
|
146
146
|
"text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
|
|
147
147
|
"last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
|
|
148
|
-
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-
|
|
148
|
+
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-link",
|
|
149
149
|
className
|
|
150
150
|
)}
|
|
151
151
|
{...props}
|
package/src/ui/item.tsx
CHANGED
|
@@ -5,14 +5,19 @@ import { Slot } from "radix-ui"
|
|
|
5
5
|
|
|
6
6
|
import { Separator } from "./separator.js"
|
|
7
7
|
|
|
8
|
+
// Set by ItemGroup so that its items render as list items (axe aria-required-children).
|
|
9
|
+
const ItemGroupContext = React.createContext(false)
|
|
10
|
+
|
|
8
11
|
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
9
12
|
return (
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
<ItemGroupContext.Provider value={true}>
|
|
14
|
+
<div
|
|
15
|
+
role="list"
|
|
16
|
+
data-slot="item-group"
|
|
17
|
+
className={cn("group/item-group flex flex-col", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
</ItemGroupContext.Provider>
|
|
16
21
|
)
|
|
17
22
|
}
|
|
18
23
|
|
|
@@ -60,8 +65,12 @@ function Item({
|
|
|
60
65
|
}: React.ComponentProps<"div"> &
|
|
61
66
|
VariantProps<typeof itemVariants> & { asChild?: boolean }) {
|
|
62
67
|
const Comp = asChild ? Slot.Root : "div"
|
|
68
|
+
const isInGroup = React.useContext(ItemGroupContext)
|
|
69
|
+
// An asChild item keeps its child's own role (a link stays a link).
|
|
70
|
+
const role = isInGroup && !asChild ? "listitem" : undefined
|
|
63
71
|
return (
|
|
64
72
|
<Comp
|
|
73
|
+
role={role}
|
|
65
74
|
data-slot="item"
|
|
66
75
|
data-variant={variant}
|
|
67
76
|
data-size={size}
|
|
@@ -135,7 +144,7 @@ function ItemDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
135
144
|
data-slot="item-description"
|
|
136
145
|
className={cn(
|
|
137
146
|
"line-clamp-2 text-sm leading-normal font-normal text-balance text-muted-foreground",
|
|
138
|
-
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-
|
|
147
|
+
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-link",
|
|
139
148
|
className
|
|
140
149
|
)}
|
|
141
150
|
{...props}
|
package/src/ui/progress.tsx
CHANGED
|
@@ -4,14 +4,25 @@ import * as React from "react"
|
|
|
4
4
|
import { cn } from "../lib/utils.js"
|
|
5
5
|
import { Progress as ProgressPrimitive } from "radix-ui"
|
|
6
6
|
|
|
7
|
+
const FILL_CLASS = /(^|\s)bg-/
|
|
8
|
+
|
|
9
|
+
function hasFillClass(className: string | undefined): boolean {
|
|
10
|
+
return className !== undefined && FILL_CLASS.test(className)
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
function Progress({
|
|
8
14
|
className,
|
|
15
|
+
indicatorClassName,
|
|
9
16
|
value,
|
|
10
17
|
...props
|
|
11
|
-
}: React.ComponentProps<typeof ProgressPrimitive.Root>
|
|
18
|
+
}: React.ComponentProps<typeof ProgressPrimitive.Root> & {
|
|
19
|
+
/** Classes merged over the indicator's, e.g. another fill colour. */
|
|
20
|
+
indicatorClassName?: string
|
|
21
|
+
}) {
|
|
12
22
|
return (
|
|
13
23
|
<ProgressPrimitive.Root
|
|
14
24
|
data-slot="progress"
|
|
25
|
+
value={value}
|
|
15
26
|
className={cn(
|
|
16
27
|
"relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20",
|
|
17
28
|
className
|
|
@@ -20,7 +31,13 @@ function Progress({
|
|
|
20
31
|
>
|
|
21
32
|
<ProgressPrimitive.Indicator
|
|
22
33
|
data-slot="progress-indicator"
|
|
23
|
-
className=
|
|
34
|
+
className={cn(
|
|
35
|
+
"h-full w-full flex-1 bg-primary transition-all",
|
|
36
|
+
// In dark the default fill is the lighter link blue, so it reaches 3:1 against its track; a fill colour of
|
|
37
|
+
// the caller's own replaces both.
|
|
38
|
+
!hasFillClass(indicatorClassName) && "dark:bg-link",
|
|
39
|
+
indicatorClassName
|
|
40
|
+
)}
|
|
24
41
|
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
25
42
|
/>
|
|
26
43
|
</ProgressPrimitive.Root>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../lib/utils.js"
|
|
5
|
+
import { CircleIcon } from "lucide-react"
|
|
6
|
+
import { RadioGroup as RadioGroupPrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
function RadioGroup({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<RadioGroupPrimitive.Root
|
|
14
|
+
data-slot="radio-group"
|
|
15
|
+
className={cn("grid gap-3", className)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function RadioGroupItem({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
|
25
|
+
return (
|
|
26
|
+
<RadioGroupPrimitive.Item
|
|
27
|
+
data-slot="radio-group-item"
|
|
28
|
+
className={cn(
|
|
29
|
+
"aspect-square size-4 shrink-0 rounded-full border-[1.5px] border-muted-foreground text-primary transition-shadow outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary dark:aria-invalid:ring-destructive/40",
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<RadioGroupPrimitive.Indicator
|
|
35
|
+
data-slot="radio-group-indicator"
|
|
36
|
+
className="relative flex items-center justify-center"
|
|
37
|
+
>
|
|
38
|
+
<CircleIcon className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-primary" />
|
|
39
|
+
</RadioGroupPrimitive.Indicator>
|
|
40
|
+
</RadioGroupPrimitive.Item>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { RadioGroup, RadioGroupItem }
|
package/src/ui/scroll-area.tsx
CHANGED
|
@@ -7,17 +7,26 @@ import { ScrollArea as ScrollAreaPrimitive } from "radix-ui"
|
|
|
7
7
|
function ScrollArea({
|
|
8
8
|
className,
|
|
9
9
|
children,
|
|
10
|
+
viewportProps,
|
|
10
11
|
...props
|
|
11
|
-
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>
|
|
12
|
+
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root> & {
|
|
13
|
+
viewportProps?: React.ComponentProps<typeof ScrollAreaPrimitive.Viewport>
|
|
14
|
+
}) {
|
|
12
15
|
return (
|
|
13
16
|
<ScrollAreaPrimitive.Root
|
|
14
17
|
data-slot="scroll-area"
|
|
15
18
|
className={cn("relative", className)}
|
|
16
19
|
{...props}
|
|
17
20
|
>
|
|
21
|
+
{/* Focusable, so keyboard users can scroll content without focusable elements (axe scrollable-region-focusable). */}
|
|
18
22
|
<ScrollAreaPrimitive.Viewport
|
|
23
|
+
tabIndex={0}
|
|
19
24
|
data-slot="scroll-area-viewport"
|
|
20
|
-
|
|
25
|
+
{...viewportProps}
|
|
26
|
+
className={cn(
|
|
27
|
+
"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-1",
|
|
28
|
+
viewportProps?.className
|
|
29
|
+
)}
|
|
21
30
|
>
|
|
22
31
|
{children}
|
|
23
32
|
</ScrollAreaPrimitive.Viewport>
|
package/src/ui/select.tsx
CHANGED
|
@@ -108,7 +108,7 @@ function SelectItem({
|
|
|
108
108
|
<SelectPrimitive.Item
|
|
109
109
|
data-slot="select-item"
|
|
110
110
|
className={cn(
|
|
111
|
-
"relative flex w-full cursor-default items-center gap-2 rounded-md py-1 min-h-7 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
111
|
+
"relative flex w-full cursor-default items-center gap-2 rounded-md py-1 min-h-7 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
112
112
|
className
|
|
113
113
|
)}
|
|
114
114
|
{...props}
|
|
@@ -152,7 +152,7 @@ function SelectScrollUpButton({
|
|
|
152
152
|
)}
|
|
153
153
|
{...props}
|
|
154
154
|
>
|
|
155
|
-
<ChevronUpIcon className="
|
|
155
|
+
<ChevronUpIcon className="size-4" />
|
|
156
156
|
</SelectPrimitive.ScrollUpButton>
|
|
157
157
|
)
|
|
158
158
|
}
|