@vocdoni/skills 0.1.1 → 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/.claude-plugin/marketplace.json +22 -2
- package/CHANGELOG.md +22 -0
- package/README.md +25 -0
- package/package.json +1 -1
- package/plugins/agentic-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/agentic-dev/skills/subagent-driven-development/SKILL.md +10 -5
- package/plugins/agentic-dev/skills/subagent-driven-development/references/dispatch.md +20 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/references/ledger.md +1 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/scripts/task-brief.sh +2 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/templates/plan.md +4 -0
- package/plugins/claude-pi-subagent/.claude-plugin/marketplace.json +1 -1
- package/plugins/claude-pi-subagent/plugins/pi-subagent/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-pi-subagent/plugins/pi-subagent/dist/server.mjs +18072 -3144
- package/plugins/claude-pi-subagent/plugins/pi-subagent/package-lock.json +171 -184
- package/plugins/claude-pi-subagent/plugins/pi-subagent/package.json +4 -4
- package/plugins/claude-pi-subagent/plugins/pi-subagent/src/schemas.ts +4 -0
- package/plugins/claude-pi-subagent/plugins/pi-subagent/src/server.ts +1 -1
- package/plugins/claude-pi-subagent/plugins/pi-subagent/test/schemas.test.ts +30 -0
- package/plugins/vocdoni-comments/.claude-plugin/plugin.json +21 -0
- package/plugins/vocdoni-comments/skills/comments/SKILL.md +59 -0
- package/plugins/vocdoni-comments/skills/comments/trim.md +78 -0
- package/plugins/vocdoni-ui-style/.claude-plugin/plugin.json +25 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/SKILL.md +99 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/components/chakra/product.tsx +263 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/components/shadcn/brand.tsx +195 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/components/shadcn/button.tsx +67 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/components/shadcn/status-badge.tsx +93 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-logo-ink.svg +15 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-logo-white.svg +15 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-logo.svg +15 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-mark-ink.svg +7 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-mark-white.svg +7 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/logo/vocdoni-mark.svg +7 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-footer.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-home-hero.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-mobile.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-stats-and-panels.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-vertical-hero.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/editorial-washes-and-comparison.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/product-process-results.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/reference/product-signin.webp +0 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/editorial.chakra.ts +285 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/editorial.css +847 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/editorial.tailwind.css +352 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/product.chakra.ts +410 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/product.css +1116 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/assets/tokens/product.tailwind.css +289 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/editorial-landing.html +358 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/email-vote-invitation.html +58 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/product-auth.html +81 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/product-builder.html +147 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/product-dashboard.html +185 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/examples/product-voting.html +326 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/brand-core.md +166 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/editorial.md +198 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/product.md +173 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/recipes.md +264 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/stacks.md +196 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/references/ux-flows.md +110 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/bad-editorial.tsx +15 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/bad-product.tsx +9 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/doc.md +10 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/escaped.json +1 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/good-editorial.tsx +16 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/good-product.css +6 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/locale.json +1 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/multiline-attr.tsx +8 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/multiline-copy.tsx +10 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style-fixtures/regex-literal.tsx +5 -0
- package/plugins/vocdoni-ui-style/skills/vocdoni-ui-style/scripts/check-style.mjs +436 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocdoni product mode for Chakra UI v3 - a self-contained port of the
|
|
3
|
+
* vocdoni-app theme (src/theme/{colors,tokens,semantic,palette,system}.ts and
|
|
4
|
+
* the recipes that define its look).
|
|
5
|
+
*
|
|
6
|
+
* import { ChakraProvider } from '@chakra-ui/react'
|
|
7
|
+
* import { createVocdoniProductSystem } from './product.chakra'
|
|
8
|
+
* const system = createVocdoniProductSystem() // monochrome (Vocdoni default)
|
|
9
|
+
* const system = createVocdoniProductSystem('#1a73e8') // white-label accent
|
|
10
|
+
* <ChakraProvider value={system}>...</ChakraProvider>
|
|
11
|
+
*
|
|
12
|
+
* Fonts: import '@fontsource/inter/300.css', '400.css', '500.css', '600.css'.
|
|
13
|
+
* Color mode: next-themes with attribute='class' (see references/stacks.md).
|
|
14
|
+
* Custom variant names (button 'listmenu', card 'data-list-item', tabs
|
|
15
|
+
* 'settings') only typecheck after `npx @chakra-ui/cli typegen ./product.chakra.ts`.
|
|
16
|
+
* assets/components/chakra/product.tsx wraps them (NavItem, DataListCard) so
|
|
17
|
+
* pages compile without typegen; tabs default to 'settings'.
|
|
18
|
+
*/
|
|
19
|
+
import { createSystem, defaultConfig, defineRecipe, defineSemanticTokens, defineSlotRecipe, defineTokens } from '@chakra-ui/react'
|
|
20
|
+
import { cardAnatomy, tabsAnatomy } from '@chakra-ui/react/anatomy'
|
|
21
|
+
|
|
22
|
+
/* ------------------------------------------------------------------ */
|
|
23
|
+
/* Palette generation from one brand color (OKLab tints/shades) */
|
|
24
|
+
/* ------------------------------------------------------------------ */
|
|
25
|
+
|
|
26
|
+
type Step = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950
|
|
27
|
+
export type PaletteScale = Record<Step, string>
|
|
28
|
+
type Rgb = [number, number, number]
|
|
29
|
+
type Lab = [number, number, number]
|
|
30
|
+
|
|
31
|
+
const HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i
|
|
32
|
+
|
|
33
|
+
export const normalizeHex = (value?: string): string | undefined => {
|
|
34
|
+
const m = typeof value === 'string' ? HEX.exec(value.trim()) : null
|
|
35
|
+
if (!m) return undefined
|
|
36
|
+
const h = m[1].toLowerCase()
|
|
37
|
+
return `#${h.length === 3 ? [...h].map((c) => c + c).join('') : h}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const hexToRgb = (hex: string): Rgb => {
|
|
41
|
+
const v = normalizeHex(hex)
|
|
42
|
+
if (!v) throw new Error(`Invalid hex color: ${hex}`)
|
|
43
|
+
return [1, 3, 5].map((i) => parseInt(v.slice(i, i + 2), 16) / 255) as Rgb
|
|
44
|
+
}
|
|
45
|
+
const rgbToHex = (rgb: Rgb) =>
|
|
46
|
+
`#${rgb.map((c) => Math.round(Math.min(1, Math.max(0, c)) * 255).toString(16).padStart(2, '0')).join('')}`
|
|
47
|
+
const toLinear = (c: number) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)
|
|
48
|
+
const fromLinear = (c: number) => (c <= 0.0031308 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055)
|
|
49
|
+
|
|
50
|
+
const rgbToLab = (rgb: Rgb): Lab => {
|
|
51
|
+
const [r, g, b] = rgb.map(toLinear)
|
|
52
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
|
|
53
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
|
|
54
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
|
|
55
|
+
return [
|
|
56
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
57
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
58
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
const labToRgb = ([L, a, b]: Lab): Rgb => {
|
|
62
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3
|
|
63
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3
|
|
64
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3
|
|
65
|
+
return [
|
|
66
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
67
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
68
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
|
|
69
|
+
].map(fromLinear) as Rgb
|
|
70
|
+
}
|
|
71
|
+
// Mix t of white (1) or black (0) into the color; chroma fades with it.
|
|
72
|
+
const mix = ([L, a, b]: Lab, target: 0 | 1, t: number): Lab => [L * (1 - t) + target * t, a * (1 - t), b * (1 - t)]
|
|
73
|
+
|
|
74
|
+
const luminance = (hex: string) => {
|
|
75
|
+
const [r, g, b] = hexToRgb(hex).map(toLinear)
|
|
76
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
|
77
|
+
}
|
|
78
|
+
export const contrastRatio = (a: string, b: string) => {
|
|
79
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x)
|
|
80
|
+
return (hi + 0.05) / (lo + 0.05)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const TINTS: Array<[Step, number]> = [[50, 0.95], [100, 0.9], [200, 0.8], [300, 0.6], [400, 0.3]]
|
|
84
|
+
const SHADES: Array<[Step, number]> = [[600, 0.15], [700, 0.3], [800, 0.45], [900, 0.6], [950, 0.75]]
|
|
85
|
+
|
|
86
|
+
/** 50..950 scale; 500 is the configured color verbatim. */
|
|
87
|
+
export const generatePaletteScale = (baseHex: string): PaletteScale => {
|
|
88
|
+
const base = normalizeHex(baseHex)
|
|
89
|
+
if (!base) throw new Error(`Invalid hex color: ${baseHex}`)
|
|
90
|
+
const lab = rgbToLab(hexToRgb(base))
|
|
91
|
+
const scale = { 500: base } as PaletteScale
|
|
92
|
+
for (const [step, t] of TINTS) scale[step] = rgbToHex(labToRgb(mix(lab, 1, t)))
|
|
93
|
+
for (const [step, t] of SHADES) scale[step] = rgbToHex(labToRgb(mix(lab, 0, t)))
|
|
94
|
+
return scale
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** White unless it fails 4.5:1; then black (which then always passes). */
|
|
98
|
+
export const contrastColor = (hex: string): '#ffffff' | '#000000' =>
|
|
99
|
+
contrastRatio(hex, '#ffffff') >= 4.5 ? '#ffffff' : '#000000'
|
|
100
|
+
|
|
101
|
+
const PAGE_BG = { light: '#ffffff', dark: '#0a0a0a' }
|
|
102
|
+
const LIGHT_SOLID: Step[] = [500, 600, 700, 800, 900, 950]
|
|
103
|
+
const DARK_SOLID: Step[] = [500, 400, 300, 200, 100, 50]
|
|
104
|
+
// A filled surface must reach 3:1 (WCAG non-text) against the page; accent
|
|
105
|
+
// text must reach 4.5:1 (WCAG AA text).
|
|
106
|
+
const readableStep = (scale: PaletteScale, steps: Step[], bg: string, min = 3) =>
|
|
107
|
+
steps.find((s) => contrastRatio(scale[s], bg) >= min) ?? steps[steps.length - 1]
|
|
108
|
+
const LIGHT_FG: Step[] = [700, 800, 900, 950]
|
|
109
|
+
const DARK_FG: Step[] = [300, 200, 100, 50]
|
|
110
|
+
|
|
111
|
+
const brandSemanticTokens = (scale: PaletteScale) => {
|
|
112
|
+
const light = readableStep(scale, LIGHT_SOLID, PAGE_BG.light)
|
|
113
|
+
const dark = readableStep(scale, DARK_SOLID, PAGE_BG.dark)
|
|
114
|
+
// vocdoni-app fixes fg at 700/300, which fails AA for pale brands (a white or
|
|
115
|
+
// yellow brand gives ~2.7:1); walking the scale keeps the same result for
|
|
116
|
+
// ordinary colors and fixes the extremes.
|
|
117
|
+
const lightFg = readableStep(scale, LIGHT_FG, PAGE_BG.light, 4.5)
|
|
118
|
+
const darkFg = readableStep(scale, DARK_FG, PAGE_BG.dark, 4.5)
|
|
119
|
+
const ref = (s: Step) => `{colors.brand.${s}}`
|
|
120
|
+
const slot = (l: string, d: string) => ({ value: { _light: l, _dark: d } })
|
|
121
|
+
return {
|
|
122
|
+
solid: slot(ref(light), ref(dark)),
|
|
123
|
+
contrast: slot(contrastColor(scale[light]), contrastColor(scale[dark])),
|
|
124
|
+
fg: slot(ref(lightFg), ref(darkFg)),
|
|
125
|
+
muted: slot(ref(200), ref(800)),
|
|
126
|
+
subtle: slot(ref(100), ref(900)),
|
|
127
|
+
emphasized: slot(ref(300), ref(700)),
|
|
128
|
+
focusRing: slot(ref(light), ref(dark)),
|
|
129
|
+
// Easy to miss: outline recipes read colorPalette.border and silently
|
|
130
|
+
// fall back to a near-white hairline when it is absent.
|
|
131
|
+
border: slot(ref(light), ref(dark)),
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* ------------------------------------------------------------------ */
|
|
136
|
+
/* Tokens */
|
|
137
|
+
/* ------------------------------------------------------------------ */
|
|
138
|
+
|
|
139
|
+
const colors = {
|
|
140
|
+
// Near-black neutrals for dark-mode surfaces; never tinted by the brand.
|
|
141
|
+
ink: {
|
|
142
|
+
500: { value: '#000000' },
|
|
143
|
+
550: { value: '#262626' },
|
|
144
|
+
600: { value: '#353535' },
|
|
145
|
+
650: { value: '#0a0a0a' },
|
|
146
|
+
700: { value: '#2e2e2e' },
|
|
147
|
+
800: { value: '#3f3f3f' },
|
|
148
|
+
},
|
|
149
|
+
// Partial override of Chakra's zinc gray; other steps merge through.
|
|
150
|
+
gray: {
|
|
151
|
+
50: { value: '#fcfcfc' },
|
|
152
|
+
100: { value: '#f5f5f5' },
|
|
153
|
+
400: { value: '#b2b2b2' },
|
|
154
|
+
500: { value: '#737373' },
|
|
155
|
+
},
|
|
156
|
+
dashboardMenu: { light: { value: '#fbfbfb' }, dark: { value: '#18181b' } },
|
|
157
|
+
separator: { value: 'rgba(135, 140, 189, 0.3)' },
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const tokens = {
|
|
161
|
+
colors,
|
|
162
|
+
fonts: {
|
|
163
|
+
body: { value: `"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif` },
|
|
164
|
+
heading: { value: `"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif` },
|
|
165
|
+
mono: { value: `'Menlo', monospace` },
|
|
166
|
+
},
|
|
167
|
+
// Shifted one step light on purpose: "bold" renders 400.
|
|
168
|
+
fontWeights: {
|
|
169
|
+
normal: { value: '300' },
|
|
170
|
+
medium: { value: '300' },
|
|
171
|
+
bold: { value: '400' },
|
|
172
|
+
bolder: { value: '500' },
|
|
173
|
+
},
|
|
174
|
+
radii: {
|
|
175
|
+
none: { value: '0rem' },
|
|
176
|
+
xxs: { value: '2px' },
|
|
177
|
+
xs: { value: '4px' },
|
|
178
|
+
sm: { value: '6px' },
|
|
179
|
+
md: { value: '8px' },
|
|
180
|
+
lg: { value: '10px' },
|
|
181
|
+
xl: { value: '12px' },
|
|
182
|
+
'2xl': { value: '16px' },
|
|
183
|
+
'3xl': { value: '20px' },
|
|
184
|
+
'4xl': { value: '24px' },
|
|
185
|
+
full: { value: '9999px' },
|
|
186
|
+
},
|
|
187
|
+
sizes: {
|
|
188
|
+
'dashboard-menu': { default: { value: '255px' }, reduced: { value: '48px' } },
|
|
189
|
+
'max-content-width': { value: '1200px' },
|
|
190
|
+
'max-window-width': { value: '2560px' },
|
|
191
|
+
'user-profile': { value: '280px' },
|
|
192
|
+
voting: {
|
|
193
|
+
sidebar: { value: '320px' },
|
|
194
|
+
contents: { min: { value: 'calc(640px + 320px)' }, max: { value: '1560px' } },
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
zIndex: {
|
|
198
|
+
background: { value: 0 },
|
|
199
|
+
contents: { value: 1 },
|
|
200
|
+
sidebar: { value: 2 },
|
|
201
|
+
topbar: { value: 3 },
|
|
202
|
+
modal: { value: 1400 },
|
|
203
|
+
hovering: { value: 1500 },
|
|
204
|
+
top: { value: 9999 },
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const semanticColors = {
|
|
209
|
+
bg: {
|
|
210
|
+
DEFAULT: { value: { _light: '{colors.white}', _dark: '{colors.ink.650}' } },
|
|
211
|
+
muted: { value: { _light: '{colors.gray.100}', _dark: '{colors.ink.800}' } },
|
|
212
|
+
},
|
|
213
|
+
auth: {
|
|
214
|
+
bg: { value: { _light: '{colors.gray.50}', _dark: '{colors.ink.550}' } },
|
|
215
|
+
showcase: {
|
|
216
|
+
fg: { DEFAULT: { value: '{colors.white}' }, muted: { value: '{colors.gray.400}' } },
|
|
217
|
+
rule: { value: 'rgba(255, 255, 255, 0.16)' },
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
dashboard: { menu: { value: { _light: '{colors.dashboardMenu.light}', _dark: '{colors.dashboardMenu.dark}' } } },
|
|
221
|
+
input: { placeholder: { value: '{colors.gray.500}' } },
|
|
222
|
+
tabs: {
|
|
223
|
+
bg: { value: { _light: '{colors.gray.100}', _dark: '{colors.ink.700}' } },
|
|
224
|
+
tab: {
|
|
225
|
+
color: { value: { _light: '{colors.gray.500}', _dark: '{colors.gray.400}' } },
|
|
226
|
+
active: {
|
|
227
|
+
color: { value: { _light: '{colors.brand.fg}', _dark: '{colors.white}' } },
|
|
228
|
+
bg: { value: { _light: '{colors.white}', _dark: '{colors.ink.500}' } },
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ------------------------------------------------------------------ */
|
|
235
|
+
/* Recipes (the subset that defines the look) */
|
|
236
|
+
/* ------------------------------------------------------------------ */
|
|
237
|
+
|
|
238
|
+
const button = defineRecipe({
|
|
239
|
+
base: { minW: 0, fontWeight: 'bold', borderRadius: 'sm', fontSize: 'sm' },
|
|
240
|
+
variants: {
|
|
241
|
+
variant: {
|
|
242
|
+
// Sidebar navigation item
|
|
243
|
+
listmenu: {
|
|
244
|
+
display: 'flex',
|
|
245
|
+
justifyContent: 'flex-start',
|
|
246
|
+
alignItems: 'center',
|
|
247
|
+
fontWeight: 'normal',
|
|
248
|
+
borderRadius: 'sm',
|
|
249
|
+
_hover: { bg: 'bg.muted' },
|
|
250
|
+
_currentPage: { bg: { _light: 'colorPalette.200', _dark: 'colorPalette.800' }, fontWeight: 'bold' },
|
|
251
|
+
},
|
|
252
|
+
link: { textAlign: 'left', w: 'auto', h: 'auto', p: 0, _hover: { textDecoration: 'underline' } },
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const heading = defineRecipe({
|
|
258
|
+
base: { fontWeight: 'bold' },
|
|
259
|
+
variants: { variant: { header: { fontWeight: 'extrabold' } } },
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
const link = defineRecipe({
|
|
263
|
+
base: {
|
|
264
|
+
color: 'gray.800',
|
|
265
|
+
textDecoration: 'underline',
|
|
266
|
+
textDecorationThickness: 'from-font',
|
|
267
|
+
textUnderlineOffset: '0.15em',
|
|
268
|
+
_hover: { color: 'gray.500' },
|
|
269
|
+
_dark: { color: 'gray.400', _hover: { color: 'gray.200' } },
|
|
270
|
+
},
|
|
271
|
+
variants: {
|
|
272
|
+
variant: {
|
|
273
|
+
plain: { _hover: { textDecorationColor: 'currentColor', textUnderlineOffset: '0.15em' } },
|
|
274
|
+
unstyled: { textDecoration: 'none', _hover: { textDecoration: 'none' } },
|
|
275
|
+
footer: { textDecoration: 'none', color: 'fg.muted', _hover: { textDecoration: 'underline' } },
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
const formLabel = defineRecipe({ base: { fontSize: 'sm', fontWeight: 'normal' } })
|
|
281
|
+
|
|
282
|
+
// iOS Safari zooms focused inputs under 16px: 16px on mobile, 14px from md.
|
|
283
|
+
const mobileSafe = { fontSize: { base: 'md', md: 'sm' }, _placeholder: { fontSize: { base: 'md', md: 'sm' } } }
|
|
284
|
+
const input = defineRecipe({
|
|
285
|
+
base: { _placeholder: { color: 'input.placeholder' } },
|
|
286
|
+
variants: {
|
|
287
|
+
size: { sm: { borderRadius: 'sm', ...mobileSafe }, md: { borderRadius: 'sm', ...mobileSafe } },
|
|
288
|
+
variant: {
|
|
289
|
+
borderless: {
|
|
290
|
+
border: 'none',
|
|
291
|
+
px: 0,
|
|
292
|
+
bg: 'transparent',
|
|
293
|
+
// no border means no border-based focus: keep a visible ring
|
|
294
|
+
_focusVisible: { outline: '2px solid', outlineColor: 'colorPalette.focusRing', outlineOffset: '4px', borderRadius: '2px' },
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
const badge = defineRecipe({
|
|
301
|
+
variants: {
|
|
302
|
+
size: {
|
|
303
|
+
xs: { fontSize: 'xs', lineHeight: 'xs', px: 1, py: 0.5 },
|
|
304
|
+
sm: { fontSize: 'sm', lineHeight: 'sm', px: 2, py: 1 },
|
|
305
|
+
md: { fontSize: 'md', lineHeight: 'md', px: 3, py: 2 },
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
defaultVariants: { size: 'xs' },
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
// Settings tabs: a gray pill rail with a white raised active tab.
|
|
312
|
+
const tabs = defineSlotRecipe({
|
|
313
|
+
slots: tabsAnatomy.keys(),
|
|
314
|
+
variants: {
|
|
315
|
+
variant: {
|
|
316
|
+
settings: {
|
|
317
|
+
root: { '--tabs-height': 'auto' },
|
|
318
|
+
list: { p: 1, bgColor: 'tabs.bg', borderRadius: 'sm', w: 'fit-content', maxW: 'full', overflowX: 'auto' },
|
|
319
|
+
trigger: {
|
|
320
|
+
py: 1.5,
|
|
321
|
+
px: 3,
|
|
322
|
+
whiteSpace: 'nowrap',
|
|
323
|
+
borderRadius: 'sm',
|
|
324
|
+
fontWeight: 'medium', // = 300 in this system
|
|
325
|
+
color: 'tabs.tab.color',
|
|
326
|
+
fontSize: 'sm',
|
|
327
|
+
_selected: { bgColor: 'tabs.tab.active.bg', color: 'tabs.tab.active.color', boxShadow: 'xs' },
|
|
328
|
+
},
|
|
329
|
+
content: { borderRadius: 'md', p: 6 },
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
// Default, as in vocdoni-app: <Tabs.Root> gets the pill rail with no variant
|
|
334
|
+
// prop (so no typegen needed). Use variant='line' for fitted content tabs.
|
|
335
|
+
defaultVariants: { variant: 'settings' },
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// Mobile replacement for table rows.
|
|
339
|
+
const card = defineSlotRecipe({
|
|
340
|
+
slots: cardAnatomy.keys(),
|
|
341
|
+
variants: {
|
|
342
|
+
variant: {
|
|
343
|
+
'data-list-item': {
|
|
344
|
+
root: { w: 'full', bg: 'transparent', border: '1px solid', borderColor: 'border', borderRadius: 'sm', p: 4, gap: 2 },
|
|
345
|
+
header: { p: 0, flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', gap: 2 },
|
|
346
|
+
body: { p: 0, gap: 1, fontSize: 'sm', color: 'fg.muted' },
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
// Voter-authentication strength (weak / mid / strong).
|
|
353
|
+
export const securityLevelRecipe = defineRecipe({
|
|
354
|
+
base: {
|
|
355
|
+
border: '2px solid',
|
|
356
|
+
borderColor: 'border',
|
|
357
|
+
borderRadius: 'md',
|
|
358
|
+
py: 2,
|
|
359
|
+
px: 4,
|
|
360
|
+
fontWeight: 'bold',
|
|
361
|
+
textAlign: 'center',
|
|
362
|
+
w: 'full',
|
|
363
|
+
color: 'white',
|
|
364
|
+
textTransform: 'uppercase',
|
|
365
|
+
},
|
|
366
|
+
variants: {
|
|
367
|
+
variant: {
|
|
368
|
+
weak: { bg: 'red.800', borderColor: 'red.600' },
|
|
369
|
+
mid: { bg: 'orange.800', borderColor: 'orange.600' },
|
|
370
|
+
strong: { bg: 'green.800', borderColor: 'green.600' },
|
|
371
|
+
inactive: { bg: 'gray.900' },
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
/* ------------------------------------------------------------------ */
|
|
377
|
+
/* System */
|
|
378
|
+
/* ------------------------------------------------------------------ */
|
|
379
|
+
|
|
380
|
+
export const createVocdoniProductSystem = (primaryColor?: string) => {
|
|
381
|
+
const brand = normalizeHex(primaryColor)
|
|
382
|
+
const scale = generatePaletteScale(brand ?? '#000000')
|
|
383
|
+
const brandTokens = Object.fromEntries(Object.entries(scale).map(([k, value]) => [k, { value }]))
|
|
384
|
+
|
|
385
|
+
return createSystem(defaultConfig, {
|
|
386
|
+
// Without a brand the stock gray palette drives every colorPalette-aware
|
|
387
|
+
// component (gray.solid = #18181b); with one, `brand` takes over.
|
|
388
|
+
globalCss: {
|
|
389
|
+
html: { colorPalette: brand ? 'brand' : 'gray' },
|
|
390
|
+
'*, *::before, *::after': {
|
|
391
|
+
_motionReduce: {
|
|
392
|
+
animationDuration: '0.01ms !important',
|
|
393
|
+
animationIterationCount: '1 !important',
|
|
394
|
+
transitionDuration: '0.01ms !important',
|
|
395
|
+
scrollBehavior: 'auto !important',
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
theme: {
|
|
400
|
+
tokens: defineTokens({ ...tokens, colors: { ...colors, brand: brandTokens } }),
|
|
401
|
+
semanticTokens: defineSemanticTokens({
|
|
402
|
+
colors: { ...semanticColors, brand: brandSemanticTokens(scale) },
|
|
403
|
+
}),
|
|
404
|
+
recipes: { button, heading, link, formLabel, input, badge, securityLevel: securityLevelRecipe },
|
|
405
|
+
slotRecipes: { tabs, card },
|
|
406
|
+
},
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export const system = createVocdoniProductSystem()
|