@wrikka/theme 0.0.0-stage → 0.1.3
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/README.md +48 -2
- package/dist/brand-DIJLf6Xs.d.mts +68 -0
- package/dist/css-vars-WEUFBMjy.mjs +850 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.mjs +96 -0
- package/dist/preset.d.mts +23 -0
- package/dist/preset.mjs +189 -0
- package/dist/vite.d.mts +58 -0
- package/dist/vite.mjs +100 -0
- package/package.json +58 -3
- package/src/styles/markdown.css +87 -0
- package/src/styles/theme.css +247 -0
- package/src/styles/tokens.css +311 -0
- package/src/styles/tokens.dtcg.json +3656 -0
- package/tokens.json +535 -0
- package/uno.config.ts +246 -0
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
> 
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @wrikka/theme
|
|
4
|
+
|
|
5
|
+
Design tokens, theme presets, theme CSS, and the shared UnoCSS config behind
|
|
6
|
+
`@wrikka/ui`. No SolidJS runtime dependency — usable by any UnoCSS project.
|
|
7
|
+
|
|
8
|
+
 
|
|
9
|
+
|
|
10
|
+
| api | description | options | default |
|
|
11
|
+
| ------------------------ | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ------- |
|
|
12
|
+
| `@wrikka/theme` | Token scales, color schemes, presets, and CSS-variable builders | — | — |
|
|
13
|
+
| `@wrikka/theme/preset` | UnoCSS preset mapping tokens to `var(--color-*)` / `var(--su-*)` | `color`, `font`, `space`, `radius`, `mode`, `brand`, `preflight` | — |
|
|
14
|
+
| `@wrikka/theme/uno` | Shared UnoCSS config (presetWind4 + token rules) | — | — |
|
|
15
|
+
| `@wrikka/theme/styles/*` | Theme CSS: `tokens.css`, `theme.css`, `markdown.css` | — | — |
|
|
16
|
+
|
|
17
|
+
## Get Started
|
|
18
|
+
|
|
19
|
+
1. Import the tokens and theme CSS once at your app entry
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import "@wrikka/theme/styles/tokens.css";
|
|
23
|
+
import "@wrikka/theme/styles/theme.css";
|
|
24
|
+
```
|
|
25
|
+
2. Extend the shared UnoCSS config
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { defineConfig } from "unocss";
|
|
29
|
+
import baseConfig from "@wrikka/theme/uno";
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
...baseConfig,
|
|
33
|
+
content: { filesystem: ["./src/**/*.{ts,tsx}"] },
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
3. Optional: swap tokens at runtime with the preset
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { presetSolidUI } from "@wrikka/theme/preset";
|
|
40
|
+
|
|
41
|
+
presets: [presetSolidUI({ brand: "#7c5cff", mode: "dark" })];
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Dark mode is driven by `html[data-theme="dark"]` / `html[data-theme="light"]`; the
|
|
45
|
+
z-index, duration, control-height and row-height scales resolve through CSS variables
|
|
46
|
+
(`--su-z-*`, `--su-duration-*`, `--su-control-h-*`, `--su-row-h`).
|
|
47
|
+
|
|
48
|
+
`tokens.json` is the portable DTCG export; regenerate it with
|
|
49
|
+
`bun run --filter @wrikka/theme gen:tokens` after touching `tokens.css` or `theme.css`.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
type ThemeMode = "light" | "dark";
|
|
2
|
+
type ThemeColor = "auto" | "slate" | "blue" | "indigo" | "violet" | "rose" | "pink" | "red" | "orange" | "amber" | "yellow" | "green" | "teal" | "cyan";
|
|
3
|
+
type ThemeFont = "sans" | "serif" | "mono" | "thai";
|
|
4
|
+
type ThemeSpace = "compact" | "normal" | "spacious" | "touch";
|
|
5
|
+
type ThemeRadius = "none" | "small" | "medium" | "large" | "rounded";
|
|
6
|
+
interface ThemeState {
|
|
7
|
+
name: string;
|
|
8
|
+
mode: ThemeMode;
|
|
9
|
+
/** true = user picked a mode manually, so don't auto-switch on day/night. */
|
|
10
|
+
modeLocked?: boolean;
|
|
11
|
+
color: ThemeColor;
|
|
12
|
+
font: ThemeFont;
|
|
13
|
+
space: ThemeSpace;
|
|
14
|
+
radius: ThemeRadius;
|
|
15
|
+
}
|
|
16
|
+
interface ThemePreset {
|
|
17
|
+
name: string;
|
|
18
|
+
label: string;
|
|
19
|
+
state: ThemeState;
|
|
20
|
+
}
|
|
21
|
+
type ColorSet = {
|
|
22
|
+
primary: string;
|
|
23
|
+
primaryForeground: string;
|
|
24
|
+
secondary: string;
|
|
25
|
+
secondaryForeground: string;
|
|
26
|
+
accent: string;
|
|
27
|
+
accentForeground: string;
|
|
28
|
+
ring: string;
|
|
29
|
+
info: string;
|
|
30
|
+
success: string;
|
|
31
|
+
warning: string;
|
|
32
|
+
destructive: string;
|
|
33
|
+
};
|
|
34
|
+
interface ColorScheme {
|
|
35
|
+
light: ColorSet;
|
|
36
|
+
dark: ColorSet;
|
|
37
|
+
}
|
|
38
|
+
/** A brand color per mode, for palettes that need a brighter dark-mode fill. */
|
|
39
|
+
interface BrandPair {
|
|
40
|
+
light: string;
|
|
41
|
+
dark: string;
|
|
42
|
+
}
|
|
43
|
+
/** One color for both modes, or a per-mode pair. */
|
|
44
|
+
type BrandInput = string | BrandPair;
|
|
45
|
+
interface BrandRamp {
|
|
46
|
+
/** Normalized "h s% l%" triplet. */
|
|
47
|
+
brand: string;
|
|
48
|
+
primary: string;
|
|
49
|
+
primaryForeground: string;
|
|
50
|
+
primaryHover: string;
|
|
51
|
+
primaryActive: string;
|
|
52
|
+
ring: string;
|
|
53
|
+
}
|
|
54
|
+
/** Accept a six-digit hex color or an "h s% l%" triplet; returns the triplet form. */
|
|
55
|
+
declare function normalizeBrand(brand: string): string | undefined;
|
|
56
|
+
/** Pick whichever of ink/white reads better on the given fill (WCAG contrast). */
|
|
57
|
+
declare function readableForeground(triplet: string): string;
|
|
58
|
+
/** Resolve the color a mode should use; a plain string applies to both modes. */
|
|
59
|
+
declare function brandForMode(brand: BrandInput, mode?: ThemeMode): string;
|
|
60
|
+
/**
|
|
61
|
+
* Build the primary ramp for a brand color.
|
|
62
|
+
* Hover/active follow the same lightness direction as the built-in palettes:
|
|
63
|
+
* lighter in light mode, darker in dark mode.
|
|
64
|
+
*/
|
|
65
|
+
declare function brandRamp(brand: BrandInput, mode?: ThemeMode): BrandRamp;
|
|
66
|
+
/** CSS custom properties consumed by theme.css / the UnoCSS preset. */
|
|
67
|
+
declare function brandVars(brand: BrandInput, mode?: ThemeMode): Record<string, string>;
|
|
68
|
+
export { ThemeState as _, brandRamp as a, readableForeground as c, ThemeColor as d, ThemeFont as f, ThemeSpace as g, ThemeRadius as h, brandForMode as i, ColorScheme as l, ThemePreset as m, BrandPair as n, brandVars as o, ThemeMode as p, BrandRamp as r, normalizeBrand as s, BrandInput as t, ColorSet as u };
|