@krometra/ui-kit 0.6.1 → 0.8.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/README.md +29 -6
- package/dist/ui-kit.js +140 -10
- package/dist/ui-kit.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/theme.js +99 -9
package/package.json
CHANGED
package/src/theme.js
CHANGED
|
@@ -25,7 +25,11 @@ export const schemes = ['light', 'dark', 'system']
|
|
|
25
25
|
* Нейтрали задаются отдельно от акцента: одинаковый синий на холодном и на
|
|
26
26
|
* тёплом сером выглядит как два разных бренда, и подбирать их порознь удобнее,
|
|
27
27
|
* чем держать десяток почти одинаковых палитр. Пресет может уточнить нейтрали
|
|
28
|
-
* точечно через `neutralOverrides` — так живут проектные темы.
|
|
28
|
+
* точечно через `neutralOverrides` — так живут проектные темы. Ещё пресет
|
|
29
|
+
* может задать свои `radius`, `density`, `elevation` и `font`: они действуют,
|
|
30
|
+
* пока ось не задана в теме явно. `accentOverrides` и `semanticOverrides`
|
|
31
|
+
* по схемам (`light`, `dark`) задают акцент и цвета статусов точно, когда
|
|
32
|
+
* подобранная вручную палитра должна совпасть с макетом.
|
|
29
33
|
*/
|
|
30
34
|
export const presets = {
|
|
31
35
|
default: {
|
|
@@ -95,6 +99,83 @@ export const presets = {
|
|
|
95
99
|
accentSoft: '#f4f4f5',
|
|
96
100
|
neutral: 'plain',
|
|
97
101
|
},
|
|
102
|
+
bordeaux: {
|
|
103
|
+
label: 'Bordeaux',
|
|
104
|
+
accent: '#8a3a48',
|
|
105
|
+
accentHover: '#73303c',
|
|
106
|
+
accentSoft: '#f3e6e8',
|
|
107
|
+
neutral: 'warm',
|
|
108
|
+
font: "'Golos Text', -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
109
|
+
accentOverrides: {
|
|
110
|
+
dark: { accent: '#e3929e', accentHover: '#eaa9b3', accentSoft: '#33242a' },
|
|
111
|
+
},
|
|
112
|
+
semanticOverrides: {
|
|
113
|
+
light: {
|
|
114
|
+
success: { base: '#2c7656', hover: '#235f45', soft: '#e3f1ea', strong: '#2c7656' },
|
|
115
|
+
info: { base: '#3b6286', hover: '#2f4f6c', soft: '#e5edf5', strong: '#3b6286' },
|
|
116
|
+
danger: { base: '#b03a37', hover: '#922f2d', soft: '#fbe8e6', strong: '#b03a37' },
|
|
117
|
+
},
|
|
118
|
+
dark: {
|
|
119
|
+
success: { base: '#72c9a2', hover: '#8fd6b6', soft: '#1b3228', strong: '#72c9a2' },
|
|
120
|
+
info: { base: '#94b8db', hover: '#adc9e4', soft: '#1c2936', strong: '#94b8db' },
|
|
121
|
+
danger: { base: '#f08d83', hover: '#f4a69e', soft: '#3a2220', strong: '#f08d83' },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
neutralOverrides: {
|
|
125
|
+
light: {
|
|
126
|
+
bg: '#f6f4f4',
|
|
127
|
+
surface: '#ffffff',
|
|
128
|
+
surfaceMuted: '#faf8f8',
|
|
129
|
+
border: '#e3dcdd',
|
|
130
|
+
borderStrong: '#cdc3c4',
|
|
131
|
+
text: '#1e2327',
|
|
132
|
+
textMuted: '#5f666c',
|
|
133
|
+
textFaint: '#959ca1',
|
|
134
|
+
},
|
|
135
|
+
dark: {
|
|
136
|
+
bg: '#15181b',
|
|
137
|
+
surface: '#1d2125',
|
|
138
|
+
surfaceMuted: '#24292e',
|
|
139
|
+
border: '#30353a',
|
|
140
|
+
borderStrong: '#454b52',
|
|
141
|
+
text: '#ebe7e7',
|
|
142
|
+
textMuted: '#a3a9ae',
|
|
143
|
+
textFaint: '#737a80',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
blocky: {
|
|
148
|
+
label: 'Blocky',
|
|
149
|
+
accent: '#4f8a25',
|
|
150
|
+
accentHover: '#3f711c',
|
|
151
|
+
accentSoft: '#e8f3dc',
|
|
152
|
+
neutral: 'warm',
|
|
153
|
+
radius: 'square',
|
|
154
|
+
elevation: 'hard',
|
|
155
|
+
font: 'rounded',
|
|
156
|
+
neutralOverrides: {
|
|
157
|
+
light: {
|
|
158
|
+
bg: '#e7e1d3',
|
|
159
|
+
surface: '#fbf8f1',
|
|
160
|
+
surfaceMuted: '#f1ebdf',
|
|
161
|
+
border: '#cdc3ae',
|
|
162
|
+
borderStrong: '#8a7a5c',
|
|
163
|
+
text: '#2b2418',
|
|
164
|
+
textMuted: '#675a43',
|
|
165
|
+
textFaint: '#9a8c72',
|
|
166
|
+
},
|
|
167
|
+
dark: {
|
|
168
|
+
bg: '#1b1814',
|
|
169
|
+
surface: '#27231d',
|
|
170
|
+
surfaceMuted: '#302b24',
|
|
171
|
+
border: '#443d32',
|
|
172
|
+
borderStrong: '#6b5f4c',
|
|
173
|
+
text: '#efe8da',
|
|
174
|
+
textMuted: '#b2a58c',
|
|
175
|
+
textFaint: '#7c715f',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
98
179
|
}
|
|
99
180
|
|
|
100
181
|
/** Нейтральные шкалы: фон, поверхности, границы, текст — для обеих схем. */
|
|
@@ -193,6 +274,7 @@ export const radiusScales = {
|
|
|
193
274
|
default: { sm: '6px', md: '8px', lg: '14px' },
|
|
194
275
|
soft: { sm: '9px', md: '12px', lg: '20px' },
|
|
195
276
|
pill: { sm: '12px', md: '16px', lg: '28px' },
|
|
277
|
+
square: { sm: '0px', md: '0px', lg: '0px' },
|
|
196
278
|
}
|
|
197
279
|
|
|
198
280
|
/** Плотность: высота контролов и базовый шаг. */
|
|
@@ -216,6 +298,10 @@ export const elevations = {
|
|
|
216
298
|
light: { sm: '0 1px 3px rgba(15, 23, 42, 0.08)', md: '0 8px 24px rgba(15, 23, 42, 0.12)', lg: '0 24px 60px rgba(15, 23, 42, 0.20)' },
|
|
217
299
|
dark: { sm: '0 1px 3px rgba(0, 0, 0, 0.45)', md: '0 8px 24px rgba(0, 0, 0, 0.55)', lg: '0 24px 60px rgba(0, 0, 0, 0.7)' },
|
|
218
300
|
},
|
|
301
|
+
hard: {
|
|
302
|
+
light: { sm: '0 3px 0 rgba(43, 36, 24, 0.28)', md: '0 4px 0 rgba(43, 36, 24, 0.16)', lg: '0 8px 0 rgba(43, 36, 24, 0.22)' },
|
|
303
|
+
dark: { sm: '0 3px 0 rgba(0, 0, 0, 0.55)', md: '0 4px 0 rgba(0, 0, 0, 0.45)', lg: '0 8px 0 rgba(0, 0, 0, 0.6)' },
|
|
304
|
+
},
|
|
219
305
|
}
|
|
220
306
|
|
|
221
307
|
/** Шрифтовые пары. */
|
|
@@ -224,6 +310,7 @@ export const fontStacks = {
|
|
|
224
310
|
grotesk: "'Inter', 'Segoe UI', system-ui, sans-serif",
|
|
225
311
|
serif: "'Georgia', 'Times New Roman', serif",
|
|
226
312
|
mono: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace",
|
|
313
|
+
rounded: "ui-rounded, 'SF Pro Rounded', 'Nunito', 'Varela Round', 'Segoe UI', system-ui, sans-serif",
|
|
227
314
|
}
|
|
228
315
|
|
|
229
316
|
/** Сводит `system` к конкретной схеме по настройке ОС; вне браузера — light. */
|
|
@@ -254,16 +341,18 @@ export function buildTheme(theme = {}) {
|
|
|
254
341
|
...(spec.textMuted ? { textMuted: spec.textMuted } : {}),
|
|
255
342
|
...(spec.textFaint ? { textFaint: spec.textFaint } : {}),
|
|
256
343
|
}
|
|
257
|
-
const radius = radiusScales[spec.radius] ?? radiusScales.default
|
|
258
|
-
const density = densities[spec.density] ?? densities.default
|
|
259
|
-
const elevation = (elevations[spec.elevation] ?? elevations.default)[scheme]
|
|
260
|
-
const
|
|
344
|
+
const radius = radiusScales[spec.radius ?? preset.radius] ?? radiusScales.default
|
|
345
|
+
const density = densities[spec.density ?? preset.density] ?? densities.default
|
|
346
|
+
const elevation = (elevations[spec.elevation ?? preset.elevation] ?? elevations.default)[scheme]
|
|
347
|
+
const fontKey = spec.font ?? preset.font
|
|
348
|
+
const font = fontStacks[fontKey] ?? fontKey ?? fontStacks.system
|
|
261
349
|
|
|
350
|
+
const own = spec.accent ? null : preset.accentOverrides?.[scheme]
|
|
262
351
|
const baseAccent = spec.accent ?? preset.accent
|
|
263
|
-
const accent = dark ? tint(baseAccent, 0.12) : baseAccent
|
|
264
|
-
const accentHover = spec.accentHover
|
|
352
|
+
const accent = own?.accent ?? (dark ? tint(baseAccent, 0.12) : baseAccent)
|
|
353
|
+
const accentHover = spec.accentHover ?? own?.accentHover
|
|
265
354
|
?? (dark ? tint(accent, 0.14) : spec.accent ? shade(accent, -0.12) : preset.accentHover)
|
|
266
|
-
const accentSoft = spec.accentSoft
|
|
355
|
+
const accentSoft = spec.accentSoft ?? own?.accentSoft
|
|
267
356
|
?? (dark ? mix(accent, neutral.surface, 0.22) : spec.accent ? tint(accent, 0.92) : preset.accentSoft)
|
|
268
357
|
|
|
269
358
|
const vars = {
|
|
@@ -301,7 +390,8 @@ export function buildTheme(theme = {}) {
|
|
|
301
390
|
'--k-font': font,
|
|
302
391
|
}
|
|
303
392
|
|
|
304
|
-
|
|
393
|
+
const tones = { ...semantics[scheme], ...preset.semanticOverrides?.[scheme] }
|
|
394
|
+
for (const [name, tone] of Object.entries(tones)) {
|
|
305
395
|
vars[`--k-${name}`] = tone.base
|
|
306
396
|
vars[`--k-${name}-hover`] = tone.hover
|
|
307
397
|
vars[`--k-${name}-soft`] = tone.soft ?? mix(tone.base, neutral.surface, 0.18)
|