@usebacklit/design-system 0.0.0-stage → 0.1.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/main.d.ts +112 -0
- package/dist/main.js +194 -0
- package/package.json +72 -3
- package/src/components/ui/badge.tsx +74 -0
- package/src/components/ui/check_mark.tsx +54 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/switch.tsx +34 -0
- package/src/icons/registry.tsx +114 -0
- package/src/index.css +113 -0
- package/src/lib/get_variant_classes.ts +8 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.ts +6 -0
- package/src/themes/default.css +76 -0
- package/README.md +0 -3
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ClassValue } from "clsx";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { IconSvgElement } from "@hugeicons/react";
|
|
4
|
+
import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
|
|
5
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { VariantProps } from "class-variance-authority";
|
|
8
|
+
//#region src/lib/utils.d.ts
|
|
9
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/icons/registry.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* What an icon component receives.
|
|
14
|
+
*
|
|
15
|
+
* It is the few props a component of this package gives an icon, and not the
|
|
16
|
+
* full set of an `svg`. A wide type would tie the registry to one family: each
|
|
17
|
+
* family types its own props its own way, and a prop that one of them declares
|
|
18
|
+
* differently would refuse the other.
|
|
19
|
+
*/
|
|
20
|
+
type IconProps = {
|
|
21
|
+
'className'?: string | undefined;
|
|
22
|
+
'style'?: React.CSSProperties | undefined;
|
|
23
|
+
'aria-hidden'?: boolean | 'true' | 'false' | undefined;
|
|
24
|
+
'data-slot'?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
/** A component that draws one icon. */
|
|
27
|
+
type IconComponent = React.ComponentType<IconProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Every icon a component can ask for, keyed by the name it asks with.
|
|
30
|
+
*
|
|
31
|
+
* A name says what the icon is for and not what it looks like: `close`, not
|
|
32
|
+
* `x`, and `sort-ascending`, not `arrow-up`. A name that says the job can be
|
|
33
|
+
* answered by any icon family, which is what lets an application replace the
|
|
34
|
+
* whole set with another one.
|
|
35
|
+
*/
|
|
36
|
+
type IconRegistry = Record<string, IconComponent>;
|
|
37
|
+
/**
|
|
38
|
+
* Makes an icon component from a Hugeicons icon, with the stroke width of the
|
|
39
|
+
* design system. An application uses it to add the icons of its own
|
|
40
|
+
* navigation to the registry.
|
|
41
|
+
*/
|
|
42
|
+
declare function createIcon(icon: IconSvgElement): IconComponent;
|
|
43
|
+
/**
|
|
44
|
+
* The icons the design system and the renderer draw, from Hugeicons.
|
|
45
|
+
*
|
|
46
|
+
* It holds the icons these two packages need and nothing else. An icon an
|
|
47
|
+
* application draws — one for each entry of its navigation — is added by the
|
|
48
|
+
* application, which keeps every icon out of the bundle except the ones that
|
|
49
|
+
* are used.
|
|
50
|
+
*/
|
|
51
|
+
declare const defaultIcons: IconRegistry;
|
|
52
|
+
/**
|
|
53
|
+
* Gives every component below it the icons to draw with.
|
|
54
|
+
*
|
|
55
|
+
* The context holds the default set, so a component outside a provider still
|
|
56
|
+
* draws. A provider is how an application adds its own icons, or replaces the
|
|
57
|
+
* set with another family.
|
|
58
|
+
*/
|
|
59
|
+
declare function IconsProvider({ icons, children }: {
|
|
60
|
+
icons: IconRegistry;
|
|
61
|
+
children: React.ReactNode;
|
|
62
|
+
}): React.ReactElement;
|
|
63
|
+
/** Every icon in force here: the default set, or what a provider above put in its place. */
|
|
64
|
+
declare function useIcons(): IconRegistry;
|
|
65
|
+
/** The component that draws one name, or nothing when no icon answers to it. */
|
|
66
|
+
declare function useIcon(name: string): IconComponent | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Draws the icon of a name.
|
|
69
|
+
*
|
|
70
|
+
* A name with no icon draws nothing, which is what lets a set be replaced in
|
|
71
|
+
* part: an application that answers the names it cares about loses the rest
|
|
72
|
+
* rather than breaking.
|
|
73
|
+
*/
|
|
74
|
+
declare function Icon({ name, ...props }: IconProps & {
|
|
75
|
+
name: string;
|
|
76
|
+
}): React.ReactElement | null;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/components/ui/checkbox.d.ts
|
|
79
|
+
declare function Checkbox({ className, ...props }: Checkbox$1.Root.Props): import("react").JSX.Element;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/ui/switch.d.ts
|
|
82
|
+
declare function Switch({ className, size, ...props }: Switch$1.Root.Props & {
|
|
83
|
+
size?: 'sm' | 'default';
|
|
84
|
+
}): import("react").JSX.Element;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/components/ui/badge.d.ts
|
|
87
|
+
declare const badgeVariants: (props?: ({
|
|
88
|
+
variant?: "default" | "secondary" | "destructive" | "success" | "warning" | "info" | "outline" | "ghost" | "link" | null | undefined;
|
|
89
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
90
|
+
declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<'span'> & VariantProps<typeof badgeVariants>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
91
|
+
/**
|
|
92
|
+
* Several badges of one value, such as the tags of a person. The badges sit
|
|
93
|
+
* in a row 4px apart and wrap to the next line when the row is full.
|
|
94
|
+
*/
|
|
95
|
+
declare function BadgeGroup({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/components/ui/check_mark.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* A true or false value, read at a glance. True draws the check icon in the
|
|
100
|
+
* text colour. False draws a muted dash, and not an empty space, because an
|
|
101
|
+
* empty space reads as "no value", which is a different state.
|
|
102
|
+
*
|
|
103
|
+
* The labels name the value for a screen reader, and default to "Yes" and
|
|
104
|
+
* "No". The caller passes translated labels.
|
|
105
|
+
*/
|
|
106
|
+
declare function CheckMark({ checked, checkedLabel, uncheckedLabel, className, ...props }: Omit<React.ComponentProps<'span'>, 'children'> & {
|
|
107
|
+
checked: boolean;
|
|
108
|
+
checkedLabel?: string;
|
|
109
|
+
uncheckedLabel?: string;
|
|
110
|
+
}): React.JSX.Element;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { Badge, BadgeGroup, CheckMark, Checkbox, Icon, IconComponent, IconProps, IconRegistry, IconsProvider, Switch, badgeVariants, cn, createIcon, defaultIcons, useIcon, useIcons };
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
5
|
+
import { Tick02Icon } from "@hugeicons/core-free-icons";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
|
|
8
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
9
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
10
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
11
|
+
import { cva } from "class-variance-authority";
|
|
12
|
+
//#region src/lib/utils.ts
|
|
13
|
+
function cn(...inputs) {
|
|
14
|
+
return twMerge(clsx(inputs));
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/icons/registry.tsx
|
|
18
|
+
/**
|
|
19
|
+
* The width of the line of an icon, on the 24 unit grid of Hugeicons. At the
|
|
20
|
+
* usual 16px size the line is about 1.3px, a little heavier than the default
|
|
21
|
+
* of the family, so an icon holds its weight next to the text.
|
|
22
|
+
*/
|
|
23
|
+
const ICON_STROKE_WIDTH = 2;
|
|
24
|
+
/**
|
|
25
|
+
* Makes an icon component from a Hugeicons icon, with the stroke width of the
|
|
26
|
+
* design system. An application uses it to add the icons of its own
|
|
27
|
+
* navigation to the registry.
|
|
28
|
+
*/
|
|
29
|
+
function createIcon(icon) {
|
|
30
|
+
function HugeIcon(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
32
|
+
icon,
|
|
33
|
+
strokeWidth: ICON_STROKE_WIDTH,
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return HugeIcon;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The icons the design system and the renderer draw, from Hugeicons.
|
|
41
|
+
*
|
|
42
|
+
* It holds the icons these two packages need and nothing else. An icon an
|
|
43
|
+
* application draws — one for each entry of its navigation — is added by the
|
|
44
|
+
* application, which keeps every icon out of the bundle except the ones that
|
|
45
|
+
* are used.
|
|
46
|
+
*/
|
|
47
|
+
const defaultIcons = { check: createIcon(Tick02Icon) };
|
|
48
|
+
const IconRegistryContext = React.createContext(defaultIcons);
|
|
49
|
+
/**
|
|
50
|
+
* Gives every component below it the icons to draw with.
|
|
51
|
+
*
|
|
52
|
+
* The context holds the default set, so a component outside a provider still
|
|
53
|
+
* draws. A provider is how an application adds its own icons, or replaces the
|
|
54
|
+
* set with another family.
|
|
55
|
+
*/
|
|
56
|
+
function IconsProvider({ icons, children }) {
|
|
57
|
+
return /* @__PURE__ */ jsx(IconRegistryContext, {
|
|
58
|
+
value: icons,
|
|
59
|
+
children
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Every icon in force here: the default set, or what a provider above put in its place. */
|
|
63
|
+
function useIcons() {
|
|
64
|
+
return React.use(IconRegistryContext);
|
|
65
|
+
}
|
|
66
|
+
/** The component that draws one name, or nothing when no icon answers to it. */
|
|
67
|
+
function useIcon(name) {
|
|
68
|
+
return useIcons()[name];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Draws the icon of a name.
|
|
72
|
+
*
|
|
73
|
+
* A name with no icon draws nothing, which is what lets a set be replaced in
|
|
74
|
+
* part: an application that answers the names it cares about loses the rest
|
|
75
|
+
* rather than breaking.
|
|
76
|
+
*/
|
|
77
|
+
function Icon({ name, ...props }) {
|
|
78
|
+
const drawn = useIcon(name);
|
|
79
|
+
return drawn ? React.createElement(drawn, props) : null;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/lib/get_variant_classes.ts
|
|
83
|
+
function getVariantClasses(prefix, props) {
|
|
84
|
+
return `${prefix} ${Object.entries(props).map(([key, value]) => {
|
|
85
|
+
if (value === null) return "";
|
|
86
|
+
return `${prefix}-${key}-${value}`;
|
|
87
|
+
}).join(" ")}`;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/ui/checkbox.tsx
|
|
91
|
+
function Checkbox({ className, ...props }) {
|
|
92
|
+
const classes = cn("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary data-indeterminate:border-primary data-indeterminate:bg-primary data-indeterminate:text-primary-foreground dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-indeterminate:bg-primary data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary", className, getVariantClasses("cn-checkbox", {}));
|
|
93
|
+
const indicatorClasses = cn("grid place-content-center text-current transition-none [&>svg]:size-3.5", getVariantClasses("cn-checkbox-indicator", {}));
|
|
94
|
+
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
95
|
+
"data-slot": "checkbox",
|
|
96
|
+
className: classes,
|
|
97
|
+
...props,
|
|
98
|
+
children: /* @__PURE__ */ jsxs(Checkbox$1.Indicator, {
|
|
99
|
+
"data-slot": "checkbox-indicator",
|
|
100
|
+
className: indicatorClasses,
|
|
101
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
102
|
+
name: "check",
|
|
103
|
+
className: "in-data-indeterminate:hidden"
|
|
104
|
+
}), /* @__PURE__ */ jsx("span", { className: "hidden h-0.5 w-2 rounded-full bg-current in-data-indeterminate:block" })]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/components/ui/switch.tsx
|
|
110
|
+
function Switch({ className, size = "default", ...props }) {
|
|
111
|
+
const variantClasses = getVariantClasses("cn-switch", { size });
|
|
112
|
+
const thumbVariantClasses = getVariantClasses("cn-switch-thumb", { size });
|
|
113
|
+
const classes = cn("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-[background-color,border-color,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50", className, variantClasses);
|
|
114
|
+
return /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
115
|
+
"data-slot": "switch",
|
|
116
|
+
"data-size": size,
|
|
117
|
+
className: classes,
|
|
118
|
+
...props,
|
|
119
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
|
|
120
|
+
"data-slot": "switch-thumb",
|
|
121
|
+
className: cn("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground", thumbVariantClasses)
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/components/ui/badge.tsx
|
|
127
|
+
const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-baseline justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! [&>svg]:self-center", {
|
|
128
|
+
variants: { variant: {
|
|
129
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
130
|
+
secondary: "border-border bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
131
|
+
destructive: "border-destructive/15 bg-destructive/10 text-destructive-foreground focus-visible:ring-destructive/20 dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
132
|
+
success: "border-success/15 bg-success/10 text-success-foreground focus-visible:ring-success/20 dark:border-success/25 dark:bg-success/15 dark:text-success dark:focus-visible:ring-success/40 [a]:hover:bg-success/20",
|
|
133
|
+
warning: "border-warning/15 bg-warning/10 text-warning-foreground focus-visible:ring-warning/20 dark:border-warning/25 dark:bg-warning/15 dark:text-warning dark:focus-visible:ring-warning/40 [a]:hover:bg-warning/20",
|
|
134
|
+
info: "border-info/15 bg-info/10 text-info-foreground focus-visible:ring-info/20 dark:border-info/25 dark:bg-info/15 dark:text-info dark:focus-visible:ring-info/40 [a]:hover:bg-info/20",
|
|
135
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
136
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
137
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
138
|
+
} },
|
|
139
|
+
defaultVariants: { variant: "default" }
|
|
140
|
+
});
|
|
141
|
+
function Badge({ className, variant = "default", render, ...props }) {
|
|
142
|
+
const variantClasses = getVariantClasses("cn-badge", { variant });
|
|
143
|
+
return useRender({
|
|
144
|
+
defaultTagName: "span",
|
|
145
|
+
props: mergeProps({ className: cn(badgeVariants({ variant }), className, variantClasses) }, props),
|
|
146
|
+
render,
|
|
147
|
+
state: {
|
|
148
|
+
slot: "badge",
|
|
149
|
+
variant
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Several badges of one value, such as the tags of a person. The badges sit
|
|
155
|
+
* in a row 4px apart and wrap to the next line when the row is full.
|
|
156
|
+
*/
|
|
157
|
+
function BadgeGroup({ className, ...props }) {
|
|
158
|
+
return /* @__PURE__ */ jsx("span", {
|
|
159
|
+
"data-slot": "badge-group",
|
|
160
|
+
className: cn("inline-flex max-w-full flex-wrap gap-1", className, getVariantClasses("cn-badge-group", {})),
|
|
161
|
+
...props
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/components/ui/check_mark.tsx
|
|
166
|
+
/**
|
|
167
|
+
* A true or false value, read at a glance. True draws the check icon in the
|
|
168
|
+
* text colour. False draws a muted dash, and not an empty space, because an
|
|
169
|
+
* empty space reads as "no value", which is a different state.
|
|
170
|
+
*
|
|
171
|
+
* The labels name the value for a screen reader, and default to "Yes" and
|
|
172
|
+
* "No". The caller passes translated labels.
|
|
173
|
+
*/
|
|
174
|
+
function CheckMark({ checked, checkedLabel = "Yes", uncheckedLabel = "No", className, ...props }) {
|
|
175
|
+
const variantClasses = getVariantClasses("cn-check-mark", { state: checked ? "checked" : "unchecked" });
|
|
176
|
+
const classes = cn("inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-3.5", checked ? "text-foreground" : "text-muted-foreground", className, variantClasses);
|
|
177
|
+
return /* @__PURE__ */ jsx("span", {
|
|
178
|
+
"data-slot": "check-mark",
|
|
179
|
+
"data-checked": checked,
|
|
180
|
+
role: "img",
|
|
181
|
+
"aria-label": checked ? checkedLabel : uncheckedLabel,
|
|
182
|
+
className: classes,
|
|
183
|
+
...props,
|
|
184
|
+
children: checked ? /* @__PURE__ */ jsx(Icon, {
|
|
185
|
+
name: "check",
|
|
186
|
+
"aria-hidden": true
|
|
187
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
188
|
+
"aria-hidden": true,
|
|
189
|
+
className: "h-0.5 w-2 rounded-full bg-current"
|
|
190
|
+
})
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { Badge, BadgeGroup, CheckMark, Checkbox, Icon, IconsProvider, Switch, badgeVariants, cn, createIcon, defaultIcons, useIcon, useIcons };
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usebacklit/design-system",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"homepage": "https://usebacklit.com",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/crossoverlabs/backlit.git",
|
|
8
|
+
"directory": "packages/design-system"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"*.css"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=26"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"provenance": true
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/main.d.ts",
|
|
24
|
+
"default": "./dist/main.js"
|
|
25
|
+
},
|
|
26
|
+
"./styles.css": "./src/index.css"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@base-ui/react": "1.9.0",
|
|
34
|
+
"@fontsource-variable/inter": "5.3.0",
|
|
35
|
+
"@fontsource-variable/jetbrains-mono": "5.3.0",
|
|
36
|
+
"@hugeicons/core-free-icons": "4.4.0",
|
|
37
|
+
"@hugeicons/react": "1.1.10",
|
|
38
|
+
"class-variance-authority": "0.7.1",
|
|
39
|
+
"clsx": "2.1.1",
|
|
40
|
+
"shadcn": "4.24.0",
|
|
41
|
+
"tailwind-merge": "3.7.3",
|
|
42
|
+
"tw-animate-css": "1.4.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "19.3.1",
|
|
46
|
+
"react-dom": "19.3.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@tailwindcss/vite": "4.3.5",
|
|
50
|
+
"@types/react": "19.3.3",
|
|
51
|
+
"@types/react-dom": "19.3.0",
|
|
52
|
+
"@vitejs/plugin-react": "6.3.1",
|
|
53
|
+
"@vitest/browser-playwright": "5.1.2",
|
|
54
|
+
"oxlint": "1.96.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2009",
|
|
56
|
+
"playwright": "1.65.2",
|
|
57
|
+
"react": "19.3.1",
|
|
58
|
+
"react-dom": "19.3.1",
|
|
59
|
+
"tailwindcss": "4.3.5",
|
|
60
|
+
"tsdown": "0.22.7",
|
|
61
|
+
"typescript": "6.0.3",
|
|
62
|
+
"vite": "8.4.1",
|
|
63
|
+
"vitest": "5.1.2",
|
|
64
|
+
"vitest-browser-react": "2.3.0",
|
|
65
|
+
"@usebacklit/oxlint-config": "0.0.0",
|
|
66
|
+
"@usebacklit/tsconfig": "0.0.0"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsdown",
|
|
70
|
+
"dev": "tsdown --watch",
|
|
71
|
+
"lint": "oxlint",
|
|
72
|
+
"typecheck": "tsc --noEmit",
|
|
73
|
+
"test": "vitest run"
|
|
74
|
+
}
|
|
6
75
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
import { mergeProps } from '@base-ui/react/merge-props'
|
|
3
|
+
import { useRender } from '@base-ui/react/use-render'
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
+
|
|
6
|
+
import { getVariantClasses } from '../../lib/get_variant_classes.ts'
|
|
7
|
+
import { cn } from '../../lib/utils.ts'
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* The badge aligns its text on the baseline and centres its icon. A flex box
|
|
11
|
+
* takes its baseline from the first item that aligns on the baseline, so the
|
|
12
|
+
* text gives the baseline even when an icon comes first. A row that aligns on
|
|
13
|
+
* the baseline, such as the page heading, then puts every badge on one line.
|
|
14
|
+
*/
|
|
15
|
+
const badgeVariants = cva(
|
|
16
|
+
'group/badge inline-flex h-5 w-fit shrink-0 items-baseline justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! [&>svg]:self-center',
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
|
|
21
|
+
secondary: 'border-border bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80',
|
|
22
|
+
destructive:
|
|
23
|
+
'border-destructive/15 bg-destructive/10 text-destructive-foreground focus-visible:ring-destructive/20 dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20',
|
|
24
|
+
success:
|
|
25
|
+
'border-success/15 bg-success/10 text-success-foreground focus-visible:ring-success/20 dark:border-success/25 dark:bg-success/15 dark:text-success dark:focus-visible:ring-success/40 [a]:hover:bg-success/20',
|
|
26
|
+
warning:
|
|
27
|
+
'border-warning/15 bg-warning/10 text-warning-foreground focus-visible:ring-warning/20 dark:border-warning/25 dark:bg-warning/15 dark:text-warning dark:focus-visible:ring-warning/40 [a]:hover:bg-warning/20',
|
|
28
|
+
info: 'border-info/15 bg-info/10 text-info-foreground focus-visible:ring-info/20 dark:border-info/25 dark:bg-info/15 dark:text-info dark:focus-visible:ring-info/40 [a]:hover:bg-info/20',
|
|
29
|
+
outline: 'border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground',
|
|
30
|
+
ghost: 'hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50',
|
|
31
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: 'default',
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
function Badge({
|
|
41
|
+
className,
|
|
42
|
+
variant = 'default',
|
|
43
|
+
render,
|
|
44
|
+
...props
|
|
45
|
+
}: useRender.ComponentProps<'span'> & VariantProps<typeof badgeVariants>) {
|
|
46
|
+
const variantClasses = getVariantClasses('cn-badge', { variant })
|
|
47
|
+
return useRender({
|
|
48
|
+
defaultTagName: 'span',
|
|
49
|
+
props: mergeProps<'span'>(
|
|
50
|
+
{
|
|
51
|
+
className: cn(badgeVariants({ variant }), className, variantClasses),
|
|
52
|
+
},
|
|
53
|
+
props
|
|
54
|
+
),
|
|
55
|
+
render,
|
|
56
|
+
state: {
|
|
57
|
+
slot: 'badge',
|
|
58
|
+
variant,
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Several badges of one value, such as the tags of a person. The badges sit
|
|
65
|
+
* in a row 4px apart and wrap to the next line when the row is full.
|
|
66
|
+
*/
|
|
67
|
+
function BadgeGroup({ className, ...props }: React.ComponentProps<'span'>) {
|
|
68
|
+
const variantClasses = getVariantClasses('cn-badge-group', {})
|
|
69
|
+
const classes = cn('inline-flex max-w-full flex-wrap gap-1', className, variantClasses)
|
|
70
|
+
|
|
71
|
+
return <span data-slot="badge-group" className={classes} {...props} />
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { Badge, BadgeGroup, badgeVariants }
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { getVariantClasses } from '../../lib/get_variant_classes.ts'
|
|
4
|
+
import { cn } from '../../lib/utils.ts'
|
|
5
|
+
import { Icon } from '../../icons/registry.tsx'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A true or false value, read at a glance. True draws the check icon in the
|
|
9
|
+
* text colour. False draws a muted dash, and not an empty space, because an
|
|
10
|
+
* empty space reads as "no value", which is a different state.
|
|
11
|
+
*
|
|
12
|
+
* The labels name the value for a screen reader, and default to "Yes" and
|
|
13
|
+
* "No". The caller passes translated labels.
|
|
14
|
+
*/
|
|
15
|
+
function CheckMark({
|
|
16
|
+
checked,
|
|
17
|
+
checkedLabel = 'Yes',
|
|
18
|
+
uncheckedLabel = 'No',
|
|
19
|
+
className,
|
|
20
|
+
...props
|
|
21
|
+
}: Omit<React.ComponentProps<'span'>, 'children'> & {
|
|
22
|
+
checked: boolean
|
|
23
|
+
checkedLabel?: string
|
|
24
|
+
uncheckedLabel?: string
|
|
25
|
+
}) {
|
|
26
|
+
const variantClasses = getVariantClasses('cn-check-mark', {
|
|
27
|
+
state: checked ? 'checked' : 'unchecked',
|
|
28
|
+
})
|
|
29
|
+
const classes = cn(
|
|
30
|
+
'inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-3.5',
|
|
31
|
+
checked ? 'text-foreground' : 'text-muted-foreground',
|
|
32
|
+
className,
|
|
33
|
+
variantClasses
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<span
|
|
38
|
+
data-slot="check-mark"
|
|
39
|
+
data-checked={checked}
|
|
40
|
+
role="img"
|
|
41
|
+
aria-label={checked ? checkedLabel : uncheckedLabel}
|
|
42
|
+
className={classes}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{checked ? (
|
|
46
|
+
<Icon name="check" aria-hidden />
|
|
47
|
+
) : (
|
|
48
|
+
<span aria-hidden className="h-0.5 w-2 rounded-full bg-current" />
|
|
49
|
+
)}
|
|
50
|
+
</span>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { CheckMark }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox'
|
|
2
|
+
import { getVariantClasses } from '../../lib/get_variant_classes.ts'
|
|
3
|
+
import { cn } from '../../lib/utils.ts'
|
|
4
|
+
import { Icon } from '../../icons/registry.tsx'
|
|
5
|
+
|
|
6
|
+
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
7
|
+
const variantClasses = getVariantClasses('cn-checkbox', {})
|
|
8
|
+
const classes = cn(
|
|
9
|
+
'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary data-indeterminate:border-primary data-indeterminate:bg-primary data-indeterminate:text-primary-foreground dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-indeterminate:bg-primary data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary',
|
|
10
|
+
className,
|
|
11
|
+
variantClasses
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const indicatorVariantClasses = getVariantClasses('cn-checkbox-indicator', {})
|
|
15
|
+
const indicatorClasses = cn(
|
|
16
|
+
'grid place-content-center text-current transition-none [&>svg]:size-3.5',
|
|
17
|
+
indicatorVariantClasses
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<CheckboxPrimitive.Root data-slot="checkbox" className={classes} {...props}>
|
|
22
|
+
<CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className={indicatorClasses}>
|
|
23
|
+
{/* A mixed state, as in a select-all box, draws a dash in place of the check. */}
|
|
24
|
+
<Icon name="check" className="in-data-indeterminate:hidden" />
|
|
25
|
+
<span className="hidden h-0.5 w-2 rounded-full bg-current in-data-indeterminate:block" />
|
|
26
|
+
</CheckboxPrimitive.Indicator>
|
|
27
|
+
</CheckboxPrimitive.Root>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Checkbox }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Switch as SwitchPrimitive } from '@base-ui/react/switch'
|
|
2
|
+
|
|
3
|
+
import { getVariantClasses } from '../../lib/get_variant_classes.ts'
|
|
4
|
+
import { cn } from '../../lib/utils.ts'
|
|
5
|
+
|
|
6
|
+
function Switch({
|
|
7
|
+
className,
|
|
8
|
+
size = 'default',
|
|
9
|
+
...props
|
|
10
|
+
}: SwitchPrimitive.Root.Props & {
|
|
11
|
+
size?: 'sm' | 'default'
|
|
12
|
+
}) {
|
|
13
|
+
const variantClasses = getVariantClasses('cn-switch', { size })
|
|
14
|
+
const thumbVariantClasses = getVariantClasses('cn-switch-thumb', { size })
|
|
15
|
+
const classes = cn(
|
|
16
|
+
'peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-[background-color,border-color,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50',
|
|
17
|
+
className,
|
|
18
|
+
variantClasses
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<SwitchPrimitive.Root data-slot="switch" data-size={size} className={classes} {...props}>
|
|
23
|
+
<SwitchPrimitive.Thumb
|
|
24
|
+
data-slot="switch-thumb"
|
|
25
|
+
className={cn(
|
|
26
|
+
'pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground',
|
|
27
|
+
thumbVariantClasses
|
|
28
|
+
)}
|
|
29
|
+
/>
|
|
30
|
+
</SwitchPrimitive.Root>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { Switch }
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react'
|
|
3
|
+
import { Tick02Icon } from '@hugeicons/core-free-icons'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What an icon component receives.
|
|
7
|
+
*
|
|
8
|
+
* It is the few props a component of this package gives an icon, and not the
|
|
9
|
+
* full set of an `svg`. A wide type would tie the registry to one family: each
|
|
10
|
+
* family types its own props its own way, and a prop that one of them declares
|
|
11
|
+
* differently would refuse the other.
|
|
12
|
+
*/
|
|
13
|
+
export type IconProps = {
|
|
14
|
+
'className'?: string | undefined
|
|
15
|
+
'style'?: React.CSSProperties | undefined
|
|
16
|
+
'aria-hidden'?: boolean | 'true' | 'false' | undefined
|
|
17
|
+
'data-slot'?: string | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A component that draws one icon. */
|
|
21
|
+
export type IconComponent = React.ComponentType<IconProps>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Every icon a component can ask for, keyed by the name it asks with.
|
|
25
|
+
*
|
|
26
|
+
* A name says what the icon is for and not what it looks like: `close`, not
|
|
27
|
+
* `x`, and `sort-ascending`, not `arrow-up`. A name that says the job can be
|
|
28
|
+
* answered by any icon family, which is what lets an application replace the
|
|
29
|
+
* whole set with another one.
|
|
30
|
+
*/
|
|
31
|
+
export type IconRegistry = Record<string, IconComponent>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The width of the line of an icon, on the 24 unit grid of Hugeicons. At the
|
|
35
|
+
* usual 16px size the line is about 1.3px, a little heavier than the default
|
|
36
|
+
* of the family, so an icon holds its weight next to the text.
|
|
37
|
+
*/
|
|
38
|
+
const ICON_STROKE_WIDTH = 2
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Makes an icon component from a Hugeicons icon, with the stroke width of the
|
|
42
|
+
* design system. An application uses it to add the icons of its own
|
|
43
|
+
* navigation to the registry.
|
|
44
|
+
*/
|
|
45
|
+
function createIcon(icon: IconSvgElement): IconComponent {
|
|
46
|
+
function HugeIcon(props: IconProps): React.ReactElement {
|
|
47
|
+
return <HugeiconsIcon icon={icon} strokeWidth={ICON_STROKE_WIDTH} {...props} />
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return HugeIcon
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The icons the design system and the renderer draw, from Hugeicons.
|
|
55
|
+
*
|
|
56
|
+
* It holds the icons these two packages need and nothing else. An icon an
|
|
57
|
+
* application draws — one for each entry of its navigation — is added by the
|
|
58
|
+
* application, which keeps every icon out of the bundle except the ones that
|
|
59
|
+
* are used.
|
|
60
|
+
*/
|
|
61
|
+
export const defaultIcons: IconRegistry = {
|
|
62
|
+
check: createIcon(Tick02Icon),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const IconRegistryContext = React.createContext<IconRegistry>(defaultIcons)
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gives every component below it the icons to draw with.
|
|
69
|
+
*
|
|
70
|
+
* The context holds the default set, so a component outside a provider still
|
|
71
|
+
* draws. A provider is how an application adds its own icons, or replaces the
|
|
72
|
+
* set with another family.
|
|
73
|
+
*/
|
|
74
|
+
function IconsProvider({
|
|
75
|
+
icons,
|
|
76
|
+
children,
|
|
77
|
+
}: {
|
|
78
|
+
icons: IconRegistry
|
|
79
|
+
children: React.ReactNode
|
|
80
|
+
}): React.ReactElement {
|
|
81
|
+
return <IconRegistryContext value={icons}>{children}</IconRegistryContext>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Every icon in force here: the default set, or what a provider above put in its place. */
|
|
85
|
+
function useIcons(): IconRegistry {
|
|
86
|
+
return React.use(IconRegistryContext)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The component that draws one name, or nothing when no icon answers to it. */
|
|
90
|
+
function useIcon(name: string): IconComponent | undefined {
|
|
91
|
+
return useIcons()[name]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Draws the icon of a name.
|
|
96
|
+
*
|
|
97
|
+
* A name with no icon draws nothing, which is what lets a set be replaced in
|
|
98
|
+
* part: an application that answers the names it cares about loses the rest
|
|
99
|
+
* rather than breaking.
|
|
100
|
+
*/
|
|
101
|
+
function Icon({ name, ...props }: IconProps & { name: string }): React.ReactElement | null {
|
|
102
|
+
const drawn = useIcon(name)
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* The element is made with `createElement` rather than written as a tag.
|
|
106
|
+
* A tag whose name is a variable reads to the compiler as a component made
|
|
107
|
+
* while rendering, which it warns about because such a component loses its
|
|
108
|
+
* state on each render. This one is looked up in the registry and is the
|
|
109
|
+
* same component for as long as the registry holds it.
|
|
110
|
+
*/
|
|
111
|
+
return drawn ? React.createElement(drawn, props) : null
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { createIcon, Icon, IconsProvider, useIcon, useIcons }
|
package/src/index.css
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
The design system stylesheet.
|
|
3
|
+
|
|
4
|
+
This file holds what every theme shares: the Tailwind import, the variant
|
|
5
|
+
for dark mode, the map from Tailwind utilities to design tokens, and the
|
|
6
|
+
base layer. It ends with the default theme.
|
|
7
|
+
|
|
8
|
+
A theme file gives values to the tokens. It scopes them to a `data-theme`
|
|
9
|
+
attribute on the `html` element, so a page can change theme at run time.
|
|
10
|
+
To add a theme, import its file and set `data-theme` to its name.
|
|
11
|
+
========================================================================= */
|
|
12
|
+
|
|
13
|
+
@import 'tailwindcss';
|
|
14
|
+
@import 'tw-animate-css';
|
|
15
|
+
@import 'shadcn/tailwind.css';
|
|
16
|
+
@import '@fontsource-variable/inter';
|
|
17
|
+
@import '@fontsource-variable/jetbrains-mono';
|
|
18
|
+
@import './themes/default.css';
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* The design system scans its own components. A `@source` path is read from the
|
|
22
|
+
* file that holds it, so a package that imports this file gets these classes
|
|
23
|
+
* and writes no path of its own.
|
|
24
|
+
*/
|
|
25
|
+
@source './**/*.{ts,tsx}';
|
|
26
|
+
|
|
27
|
+
@custom-variant dark (&:is(.dark *));
|
|
28
|
+
@custom-variant not-dark (&:not(.dark *));
|
|
29
|
+
|
|
30
|
+
/* The font tokens are not inline, so a theme can change them at run time. */
|
|
31
|
+
@theme {
|
|
32
|
+
--font-sans: 'Inter Variable', sans-serif;
|
|
33
|
+
--font-mono: 'JetBrains Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
34
|
+
--font-heading: var(--font-sans);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* The shadows that give the parts their depth. Each one gives a utility of the
|
|
38
|
+
same name, for example `shadow-control`.
|
|
39
|
+
|
|
40
|
+
- control: under a control that takes input or a click, such as an input,
|
|
41
|
+
a select, or an outline button.
|
|
42
|
+
- surface: a 1px ring and a short drop, for a white surface that sits in a
|
|
43
|
+
grey tray, such as the content of a card.
|
|
44
|
+
- primary: a faint light line along the top edge and a short drop, for a
|
|
45
|
+
filled button. It has no dark line along the bottom edge, because that
|
|
46
|
+
line shows as a grey stripe under a light fill in the dark mode.
|
|
47
|
+
- overlay: a short drop and a long soft drop, for a part that floats over
|
|
48
|
+
the page, such as a dialog or a sheet. The values come from the modal
|
|
49
|
+
and the stack of Statamic.
|
|
50
|
+
|
|
51
|
+
The ring of the surface shadow reads the border token, so it follows the
|
|
52
|
+
colour mode. The other values are black and white at low strength, so they
|
|
53
|
+
work in both modes. */
|
|
54
|
+
@theme {
|
|
55
|
+
--shadow-control: 0 2px 3px -2px rgb(0 0 0 / 0.15);
|
|
56
|
+
--shadow-surface: 0 0 0 1px var(--border), 0 2px 4px -2px rgb(0 0 0 / 0.25);
|
|
57
|
+
--shadow-primary: inset 0 1px 0 rgb(255 255 255 / 0.12), 0 1px 2px rgb(0 0 0 / 0.2);
|
|
58
|
+
--shadow-overlay:
|
|
59
|
+
0 8px 5px -6px rgb(0 0 0 / 0.12), 0 3px 8px 0 rgb(0 0 0 / 0.02),
|
|
60
|
+
0 30px 22px -22px rgb(39 39 42 / 0.35);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Each utility reads a token through `var()`, so a theme changes the value. */
|
|
64
|
+
@theme inline {
|
|
65
|
+
--color-ring: var(--ring);
|
|
66
|
+
--color-input: var(--input);
|
|
67
|
+
--color-border: var(--border);
|
|
68
|
+
--color-destructive: var(--destructive);
|
|
69
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
70
|
+
--color-success: var(--success);
|
|
71
|
+
--color-success-foreground: var(--success-foreground);
|
|
72
|
+
--color-info: var(--info);
|
|
73
|
+
--color-info-foreground: var(--info-foreground);
|
|
74
|
+
--color-warning: var(--warning);
|
|
75
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
76
|
+
--color-invert: var(--invert);
|
|
77
|
+
--color-invert-foreground: var(--invert-foreground);
|
|
78
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
79
|
+
--color-accent: var(--accent);
|
|
80
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
81
|
+
--color-muted: var(--muted);
|
|
82
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
83
|
+
--color-secondary: var(--secondary);
|
|
84
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
85
|
+
--color-primary: var(--primary);
|
|
86
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
87
|
+
--color-popover: var(--popover);
|
|
88
|
+
--color-card-foreground: var(--card-foreground);
|
|
89
|
+
--color-card: var(--card);
|
|
90
|
+
--color-foreground: var(--foreground);
|
|
91
|
+
--color-background: var(--background);
|
|
92
|
+
--radius-sm: calc(var(--radius) * 0.6);
|
|
93
|
+
--radius-md: calc(var(--radius) * 0.8);
|
|
94
|
+
--radius-lg: var(--radius);
|
|
95
|
+
--radius-xl: calc(var(--radius) * 1.4);
|
|
96
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
97
|
+
--radius-3xl: calc(var(--radius) * 2.2);
|
|
98
|
+
--radius-4xl: calc(var(--radius) * 2.6);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@layer base {
|
|
102
|
+
* {
|
|
103
|
+
@apply border-border outline-ring/50;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
body {
|
|
107
|
+
@apply bg-background text-foreground;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
html {
|
|
111
|
+
@apply font-sans antialiased;
|
|
112
|
+
}
|
|
113
|
+
}
|
package/src/lib/utils.ts
ADDED
package/src/main.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
THEME: "Default" — neutral greys with an indigo accent.
|
|
3
|
+
|
|
4
|
+
This theme answers to a page with no `data-theme` attribute, so it is the
|
|
5
|
+
theme a host gets when it imports the stylesheet and sets nothing.
|
|
6
|
+
|
|
7
|
+
The light greys are the greys of the Shopify admin, set on our own tokens.
|
|
8
|
+
Shopify has no dark mode, so the dark greys use the same values where they
|
|
9
|
+
fit and values between them where they do not.
|
|
10
|
+
========================================================================= */
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
--background: #ffffff;
|
|
14
|
+
--foreground: #303030;
|
|
15
|
+
--card: #ffffff;
|
|
16
|
+
--card-foreground: #303030;
|
|
17
|
+
--popover: #ffffff;
|
|
18
|
+
--popover-foreground: #303030;
|
|
19
|
+
--primary: #303030;
|
|
20
|
+
--primary-foreground: #ffffff;
|
|
21
|
+
--secondary: #f1f1f1;
|
|
22
|
+
--secondary-foreground: #303030;
|
|
23
|
+
--muted: #f1f1f1;
|
|
24
|
+
--muted-foreground: #616161;
|
|
25
|
+
--accent: var(--color-indigo-500);
|
|
26
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
27
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
28
|
+
--destructive-foreground: oklch(0.577 0.245 27.325);
|
|
29
|
+
--border: #e3e3e3;
|
|
30
|
+
--input: #cccccc;
|
|
31
|
+
--ring: oklch(0.708 0 0);
|
|
32
|
+
--radius: 0.625rem;
|
|
33
|
+
--success: var(--color-emerald-500);
|
|
34
|
+
--success-foreground: var(--color-emerald-900);
|
|
35
|
+
--info: var(--color-blue-500);
|
|
36
|
+
--info-foreground: var(--color-blue-900);
|
|
37
|
+
--warning: var(--color-yellow-500);
|
|
38
|
+
--warning-foreground: var(--color-yellow-900);
|
|
39
|
+
--invert: #0a0a0a;
|
|
40
|
+
--invert-foreground: #f1f1f1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dark {
|
|
44
|
+
--background: #1a1a1a;
|
|
45
|
+
--foreground: #f1f1f1;
|
|
46
|
+
/* A raised surface is lighter than the page, and the muted fill is darker,
|
|
47
|
+
as in the light mode. */
|
|
48
|
+
--card: #1f1f1f;
|
|
49
|
+
--card-foreground: #f1f1f1;
|
|
50
|
+
--popover: #242424;
|
|
51
|
+
--popover-foreground: #f1f1f1;
|
|
52
|
+
--primary: #f1f1f1;
|
|
53
|
+
--primary-foreground: #1a1a1a;
|
|
54
|
+
--secondary: #303030;
|
|
55
|
+
--secondary-foreground: #f1f1f1;
|
|
56
|
+
--muted: #121212;
|
|
57
|
+
--muted-foreground: #8a8a8a;
|
|
58
|
+
--accent: var(--color-indigo-600);
|
|
59
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
60
|
+
--destructive: oklch(0.6551 0.2211 23.47);
|
|
61
|
+
--destructive-foreground: oklch(0.704 0.191 22.216);
|
|
62
|
+
/* A line inside a part, such as a row line, is lighter than the surface. */
|
|
63
|
+
--border: #2a2a2a;
|
|
64
|
+
--input: color-mix(in oklab, var(--color-white) 12%, transparent);
|
|
65
|
+
--ring: oklch(0.556 0 0);
|
|
66
|
+
--success: var(--color-emerald-500);
|
|
67
|
+
--success-foreground: var(--color-emerald-600);
|
|
68
|
+
--info: var(--color-blue-500);
|
|
69
|
+
--info-foreground: var(--color-blue-600);
|
|
70
|
+
--warning: var(--color-yellow-500);
|
|
71
|
+
--warning-foreground: var(--color-yellow-600);
|
|
72
|
+
/* An inverted part, such as a tooltip, is lighter than the page in the dark
|
|
73
|
+
mode, so it reads as raised. */
|
|
74
|
+
--invert: #2a2a2a;
|
|
75
|
+
--invert-foreground: #e3e3e3;
|
|
76
|
+
}
|
package/README.md
DELETED