vueless 1.2.12-beta.0 → 1.2.12-beta.2
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/bin/constants.d.ts +1 -1
- package/bin/constants.js +1 -0
- package/constants.d.ts +2 -0
- package/constants.js +2 -0
- package/package.json +1 -1
- package/tailwind.css +3 -0
- package/types.ts +6 -1
- package/utils/theme.ts +27 -0
package/bin/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DEFAULT_VUELESS_CONFIG_CONTENT: "import { componentConfigs } from \"./.vueless\";\n\nexport default {\n /**\n * Global settings.\n */\n primary: \"grayscale\",\n neutral: \"gray\",\n text: 14,\n outline: 2,\n rounding: 8,\n letterSpacing: 0,\n disabledOpacity: 50,\n colorMode: \"auto\",\n\n /**\n * Component settings.\n */\n components: /*tw*/ {\n ...componentConfigs,\n },\n\n /**\n * Directive settings.\n */\n directives: {},\n\n /**\n * Light theme CSS variable settings.\n */\n lightTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-600\",\n \"--vl-primary-lifted\": \"--vl-primary-700\",\n \"--vl-primary-accented\": \"--vl-primary-800\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-500\",\n \"--vl-secondary-lifted\": \"--vl-neutral-600\",\n \"--vl-secondary-accented\": \"--vl-neutral-700\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-600\",\n \"--vl-success-lifted\": \"--color-green-700\",\n \"--vl-success-accented\": \"--color-green-800\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-600\",\n \"--vl-info-lifted\": \"--color-blue-700\",\n \"--vl-info-accented\": \"--color-blue-800\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-600\",\n \"--vl-notice-lifted\": \"--color-violet-700\",\n \"--vl-notice-accented\": \"--color-violet-800\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-600\",\n \"--vl-warning-lifted\": \"--color-orange-700\",\n \"--vl-warning-accented\": \"--color-orange-800\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-600\",\n \"--vl-error-lifted\": \"--color-red-700\",\n \"--vl-error-accented\": \"--color-red-800\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-900\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-800\",\n \"--vl-grayscale-accented\": \"--vl-neutral-700\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-500\",\n \"--vl-neutral-lifted\": \"--vl-neutral-600\",\n \"--vl-neutral-accented\": \"--vl-neutral-700\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--color-white\",\n \"--vl-text-muted\": \"--vl-neutral-400\",\n \"--vl-text-lifted\": \"--vl-neutral-500\",\n \"--vl-text-accented\": \"--vl-neutral-600\",\n \"--vl-text\": \"--vl-neutral-900\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-200\",\n \"--vl-border\": \"--vl-neutral-300\",\n \"--vl-border-lifted\": \"--vl-neutral-400\",\n \"--vl-border-accented\": \"--vl-neutral-600\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--color-white\",\n \"--vl-bg-muted\": \"--vl-neutral-50\",\n \"--vl-bg-lifted\": \"--vl-neutral-100\",\n \"--vl-bg-accented\": \"--vl-neutral-200\",\n \"--vl-bg-inverted\": \"--vl-neutral-900\",\n },\n\n /**\n * Dark theme CSS variable settings.\n */\n darkTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-400\",\n \"--vl-primary-lifted\": \"--vl-primary-500\",\n \"--vl-primary-accented\": \"--vl-primary-600\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-300\",\n \"--vl-secondary-lifted\": \"--vl-neutral-400\",\n \"--vl-secondary-accented\": \"--vl-neutral-500\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-400\",\n \"--vl-success-lifted\": \"--color-green-500\",\n \"--vl-success-accented\": \"--color-green-600\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-400\",\n \"--vl-info-lifted\": \"--color-blue-500\",\n \"--vl-info-accented\": \"--color-blue-600\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-400\",\n \"--vl-notice-lifted\": \"--color-violet-500\",\n \"--vl-notice-accented\": \"--color-violet-600\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-400\",\n \"--vl-warning-lifted\": \"--color-orange-500\",\n \"--vl-warning-accented\": \"--color-orange-600\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-400\",\n \"--vl-error-lifted\": \"--color-red-500\",\n \"--vl-error-accented\": \"--color-red-600\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-100\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-200\",\n \"--vl-grayscale-accented\": \"--vl-neutral-300\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-300\",\n \"--vl-neutral-lifted\": \"--vl-neutral-400\",\n \"--vl-neutral-accented\": \"--vl-neutral-500\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--vl-neutral-900\",\n \"--vl-text-muted\": \"--vl-neutral-600\",\n \"--vl-text-lifted\": \"--vl-neutral-400\",\n \"--vl-text-accented\": \"--vl-neutral-300\",\n \"--vl-text\": \"--vl-neutral-100\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-800\",\n \"--vl-border\": \"--vl-neutral-700\",\n \"--vl-border-lifted\": \"--vl-neutral-600\",\n \"--vl-border-accented\": \"--vl-neutral-400\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--vl-neutral-900\",\n \"--vl-bg-muted\": \"--vl-neutral-800\",\n \"--vl-bg-lifted\": \"--vl-neutral-800\",\n \"--vl-bg-accented\": \"--vl-neutral-700\",\n \"--vl-bg-inverted\": \"--vl-neutral-100\",\n },\n};\n";
|
|
1
|
+
export const DEFAULT_VUELESS_CONFIG_CONTENT: "import { componentConfigs } from \"./.vueless\";\n\nexport default {\n /**\n * Global settings.\n */\n primary: \"grayscale\",\n neutral: \"gray\",\n text: 14,\n outline: 2,\n rounding: 8,\n spacing: 8,\n letterSpacing: 0,\n disabledOpacity: 50,\n colorMode: \"auto\",\n\n /**\n * Component settings.\n */\n components: /*tw*/ {\n ...componentConfigs,\n },\n\n /**\n * Directive settings.\n */\n directives: {},\n\n /**\n * Light theme CSS variable settings.\n */\n lightTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-600\",\n \"--vl-primary-lifted\": \"--vl-primary-700\",\n \"--vl-primary-accented\": \"--vl-primary-800\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-500\",\n \"--vl-secondary-lifted\": \"--vl-neutral-600\",\n \"--vl-secondary-accented\": \"--vl-neutral-700\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-600\",\n \"--vl-success-lifted\": \"--color-green-700\",\n \"--vl-success-accented\": \"--color-green-800\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-600\",\n \"--vl-info-lifted\": \"--color-blue-700\",\n \"--vl-info-accented\": \"--color-blue-800\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-600\",\n \"--vl-notice-lifted\": \"--color-violet-700\",\n \"--vl-notice-accented\": \"--color-violet-800\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-600\",\n \"--vl-warning-lifted\": \"--color-orange-700\",\n \"--vl-warning-accented\": \"--color-orange-800\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-600\",\n \"--vl-error-lifted\": \"--color-red-700\",\n \"--vl-error-accented\": \"--color-red-800\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-900\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-800\",\n \"--vl-grayscale-accented\": \"--vl-neutral-700\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-500\",\n \"--vl-neutral-lifted\": \"--vl-neutral-600\",\n \"--vl-neutral-accented\": \"--vl-neutral-700\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--color-white\",\n \"--vl-text-muted\": \"--vl-neutral-400\",\n \"--vl-text-lifted\": \"--vl-neutral-500\",\n \"--vl-text-accented\": \"--vl-neutral-600\",\n \"--vl-text\": \"--vl-neutral-900\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-200\",\n \"--vl-border\": \"--vl-neutral-300\",\n \"--vl-border-lifted\": \"--vl-neutral-400\",\n \"--vl-border-accented\": \"--vl-neutral-600\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--color-white\",\n \"--vl-bg-muted\": \"--vl-neutral-50\",\n \"--vl-bg-lifted\": \"--vl-neutral-100\",\n \"--vl-bg-accented\": \"--vl-neutral-200\",\n \"--vl-bg-inverted\": \"--vl-neutral-900\",\n },\n\n /**\n * Dark theme CSS variable settings.\n */\n darkTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-400\",\n \"--vl-primary-lifted\": \"--vl-primary-500\",\n \"--vl-primary-accented\": \"--vl-primary-600\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-300\",\n \"--vl-secondary-lifted\": \"--vl-neutral-400\",\n \"--vl-secondary-accented\": \"--vl-neutral-500\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-400\",\n \"--vl-success-lifted\": \"--color-green-500\",\n \"--vl-success-accented\": \"--color-green-600\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-400\",\n \"--vl-info-lifted\": \"--color-blue-500\",\n \"--vl-info-accented\": \"--color-blue-600\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-400\",\n \"--vl-notice-lifted\": \"--color-violet-500\",\n \"--vl-notice-accented\": \"--color-violet-600\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-400\",\n \"--vl-warning-lifted\": \"--color-orange-500\",\n \"--vl-warning-accented\": \"--color-orange-600\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-400\",\n \"--vl-error-lifted\": \"--color-red-500\",\n \"--vl-error-accented\": \"--color-red-600\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-100\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-200\",\n \"--vl-grayscale-accented\": \"--vl-neutral-300\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-300\",\n \"--vl-neutral-lifted\": \"--vl-neutral-400\",\n \"--vl-neutral-accented\": \"--vl-neutral-500\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--vl-neutral-900\",\n \"--vl-text-muted\": \"--vl-neutral-600\",\n \"--vl-text-lifted\": \"--vl-neutral-400\",\n \"--vl-text-accented\": \"--vl-neutral-300\",\n \"--vl-text\": \"--vl-neutral-100\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-800\",\n \"--vl-border\": \"--vl-neutral-700\",\n \"--vl-border-lifted\": \"--vl-neutral-600\",\n \"--vl-border-accented\": \"--vl-neutral-400\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--vl-neutral-900\",\n \"--vl-bg-muted\": \"--vl-neutral-800\",\n \"--vl-bg-lifted\": \"--vl-neutral-800\",\n \"--vl-bg-accented\": \"--vl-neutral-700\",\n \"--vl-bg-inverted\": \"--vl-neutral-100\",\n },\n};\n";
|
package/bin/constants.js
CHANGED
package/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const TEXT: "text";
|
|
|
8
8
|
export const OUTLINE: "outline";
|
|
9
9
|
export const ROUNDING: "rounding";
|
|
10
10
|
export const DISABLED_OPACITY: "disabled-opacity";
|
|
11
|
+
export const SPACING: "spacing";
|
|
11
12
|
export const LETTER_SPACING: "letter-spacing";
|
|
12
13
|
export const LIGHT_THEME: "light-theme";
|
|
13
14
|
export const DARK_THEME: "dark-theme";
|
|
@@ -26,6 +27,7 @@ export const OUTLINE_INCREMENT: 1;
|
|
|
26
27
|
export const DEFAULT_ROUNDING: 8;
|
|
27
28
|
export const ROUNDING_DECREMENT: 4;
|
|
28
29
|
export const ROUNDING_INCREMENT: 6;
|
|
30
|
+
export const DEFAULT_SPACING: 8;
|
|
29
31
|
export const DEFAULT_DISABLED_OPACITY: 50;
|
|
30
32
|
export const DEFAULT_LETTER_SPACING: 0;
|
|
31
33
|
export const PRIMARY_COLORS: string[];
|
package/constants.js
CHANGED
|
@@ -16,6 +16,7 @@ export const TEXT = "text";
|
|
|
16
16
|
export const OUTLINE = "outline";
|
|
17
17
|
export const ROUNDING = "rounding";
|
|
18
18
|
export const DISABLED_OPACITY = "disabled-opacity";
|
|
19
|
+
export const SPACING = "spacing";
|
|
19
20
|
export const LETTER_SPACING = "letter-spacing";
|
|
20
21
|
export const LIGHT_THEME = "light-theme";
|
|
21
22
|
export const DARK_THEME = "dark-theme";
|
|
@@ -38,6 +39,7 @@ export const OUTLINE_INCREMENT = 1; /* pixels */
|
|
|
38
39
|
export const DEFAULT_ROUNDING = 8; /* pixels */
|
|
39
40
|
export const ROUNDING_DECREMENT = 4; /* pixels */
|
|
40
41
|
export const ROUNDING_INCREMENT = 6; /* pixels */
|
|
42
|
+
export const DEFAULT_SPACING = 8; /* pixels */
|
|
41
43
|
export const DEFAULT_DISABLED_OPACITY = 50; /* presents */
|
|
42
44
|
export const DEFAULT_LETTER_SPACING = 0; /* em */
|
|
43
45
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "1.2.12-beta.
|
|
3
|
+
"version": "1.2.12-beta.2",
|
|
4
4
|
"description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
|
|
5
5
|
"author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
|
|
6
6
|
"homepage": "https://vueless.com",
|
package/tailwind.css
CHANGED
|
@@ -113,6 +113,9 @@
|
|
|
113
113
|
--radius-medium: var(--vl-rounding-md);
|
|
114
114
|
--radius-large: var(--vl-rounding-lg);
|
|
115
115
|
|
|
116
|
+
/* Spacing value */
|
|
117
|
+
--spacing: var(--vl-spacing);
|
|
118
|
+
|
|
116
119
|
/* Mobile safe area spaceing. */
|
|
117
120
|
--spacing-safe-top: "env(safe-area-inset-top)";
|
|
118
121
|
--spacing-safe-bottom: "env(safe-area-inset-bottom)";
|
package/types.ts
CHANGED
|
@@ -115,6 +115,11 @@ export interface ThemeConfig {
|
|
|
115
115
|
*/
|
|
116
116
|
outline?: number | Partial<ThemeConfigOutline>;
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Default components spacing.
|
|
120
|
+
*/
|
|
121
|
+
spacing?: number;
|
|
122
|
+
|
|
118
123
|
/**
|
|
119
124
|
* Default components letter spacing.
|
|
120
125
|
*/
|
|
@@ -497,7 +502,7 @@ export interface VuelessCssVariables {
|
|
|
497
502
|
"--vl-bg-accented": string;
|
|
498
503
|
"--vl-bg-muted": string;
|
|
499
504
|
"--vl-bg-inverted": string;
|
|
500
|
-
/*
|
|
505
|
+
/* Any other design system CSS variables */
|
|
501
506
|
[key: string]: string;
|
|
502
507
|
}
|
|
503
508
|
|
package/utils/theme.ts
CHANGED
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
DEFAULT_LETTER_SPACING,
|
|
38
38
|
LIGHT_THEME,
|
|
39
39
|
DARK_THEME,
|
|
40
|
+
SPACING,
|
|
41
|
+
DEFAULT_SPACING,
|
|
40
42
|
} from "../constants";
|
|
41
43
|
|
|
42
44
|
import type {
|
|
@@ -183,6 +185,7 @@ export function resetTheme() {
|
|
|
183
185
|
`vl-${ROUNDING}-sm`,
|
|
184
186
|
`vl-${ROUNDING}-md`,
|
|
185
187
|
`vl-${ROUNDING}-lg`,
|
|
188
|
+
`vl-${SPACING}`,
|
|
186
189
|
`vl-${LETTER_SPACING}`,
|
|
187
190
|
`vl-${DISABLED_OPACITY}`,
|
|
188
191
|
`vl-${LIGHT_THEME}`,
|
|
@@ -210,6 +213,7 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
210
213
|
const text = getText(config?.text);
|
|
211
214
|
const outline = getOutlines(config?.outline);
|
|
212
215
|
const rounding = getRoundings(config?.rounding);
|
|
216
|
+
const spacing = getSpacing(config?.spacing);
|
|
213
217
|
const letterSpacing = getLetterSpacing(config?.letterSpacing);
|
|
214
218
|
const disabledOpacity = getDisabledOpacity(config?.disabledOpacity);
|
|
215
219
|
|
|
@@ -224,6 +228,7 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
224
228
|
text,
|
|
225
229
|
outline,
|
|
226
230
|
rounding,
|
|
231
|
+
spacing,
|
|
227
232
|
letterSpacing,
|
|
228
233
|
disabledOpacity,
|
|
229
234
|
lightTheme,
|
|
@@ -244,6 +249,7 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
244
249
|
const text = getText(config.text);
|
|
245
250
|
const outline = getOutlines(config.outline);
|
|
246
251
|
const rounding = getRoundings(config.rounding);
|
|
252
|
+
const spacing = getSpacing(config.spacing);
|
|
247
253
|
const letterSpacing = getLetterSpacing(config.letterSpacing);
|
|
248
254
|
const disabledOpacity = getDisabledOpacity(config.disabledOpacity);
|
|
249
255
|
|
|
@@ -310,6 +316,7 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
310
316
|
text,
|
|
311
317
|
outline,
|
|
312
318
|
rounding,
|
|
319
|
+
spacing,
|
|
313
320
|
letterSpacing,
|
|
314
321
|
disabledOpacity,
|
|
315
322
|
lightTheme,
|
|
@@ -346,6 +353,7 @@ export function normalizeThemeConfig(theme: any): MergedThemeConfig {
|
|
|
346
353
|
md: toNumber(theme.rounding?.md),
|
|
347
354
|
lg: toNumber(theme.rounding?.lg),
|
|
348
355
|
},
|
|
356
|
+
spacing: toNumber(theme.spacing),
|
|
349
357
|
letterSpacing: toNumber(theme.letterSpacing),
|
|
350
358
|
disabledOpacity: toNumber(theme.disabledOpacity),
|
|
351
359
|
};
|
|
@@ -596,6 +604,24 @@ function getRoundings(rounding?: ThemeConfig["rounding"]) {
|
|
|
596
604
|
return mergedRounding;
|
|
597
605
|
}
|
|
598
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Retrieve spacing value and save them to cookie and localStorage.
|
|
609
|
+
* @return number - spacing value.
|
|
610
|
+
*/
|
|
611
|
+
function getSpacing(spacing?: ThemeConfig["spacing"]) {
|
|
612
|
+
const storageKey = `vl-${SPACING}`;
|
|
613
|
+
|
|
614
|
+
const storedSpacing = spacing ?? getStored(storageKey) ?? vuelessConfig.spacing;
|
|
615
|
+
const mergedSpacing = Number(storedSpacing ?? DEFAULT_SPACING);
|
|
616
|
+
|
|
617
|
+
if (isCSR && spacing !== undefined) {
|
|
618
|
+
setCookie(storageKey, String(mergedSpacing));
|
|
619
|
+
localStorage.setItem(storageKey, String(mergedSpacing));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
return mergedSpacing;
|
|
623
|
+
}
|
|
624
|
+
|
|
599
625
|
/**
|
|
600
626
|
* Retrieve letter spacing value and save them to cookie and localStorage.
|
|
601
627
|
* @return number - letter spacing value.
|
|
@@ -702,6 +728,7 @@ export function setRootCSSVariables(vars: MergedThemeConfig) {
|
|
|
702
728
|
"--vl-rounding-sm": `${Number(vars.rounding.sm ?? 0) / PX_IN_REM}rem`,
|
|
703
729
|
"--vl-rounding-md": `${Number(vars.rounding.md ?? 0) / PX_IN_REM}rem`,
|
|
704
730
|
"--vl-rounding-lg": `${Number(vars.rounding.lg ?? 0) / PX_IN_REM}rem`,
|
|
731
|
+
"--vl-spacing": `${Number(vars.spacing ?? 0) / PX_IN_REM}rem`,
|
|
705
732
|
"--vl-letter-spacing": `${vars.letterSpacing}em`,
|
|
706
733
|
"--vl-disabled-opacity": `${vars.disabledOpacity}%`,
|
|
707
734
|
};
|