@rokkit/themes 1.0.0-next.17 → 1.0.0-next.18
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/package.json +7 -7
- package/src/utils.js +29 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/themes",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.18",
|
|
4
4
|
"description": "Themes for use with rokkit components.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@jerrythomas/eslint-config-svelte": "^1.0.2",
|
|
17
17
|
"@jerrythomas/prettier-config": "^1.0.0",
|
|
18
|
-
"@sveltejs/vite-plugin-svelte": "^1.
|
|
18
|
+
"@sveltejs/vite-plugin-svelte": "^2.1.1",
|
|
19
19
|
"@vitest/ui": "~0.12.10",
|
|
20
|
-
"c8": "^7.
|
|
20
|
+
"c8": "^7.13.0",
|
|
21
21
|
"eslint": "^7.32.0",
|
|
22
22
|
"jsdom": "^19.0.0",
|
|
23
|
-
"svelte": "^3.
|
|
23
|
+
"svelte": "^3.58.0",
|
|
24
24
|
"typescript": "^4.9.5",
|
|
25
|
-
"vite": "^3.2
|
|
25
|
+
"vite": "^4.3.2",
|
|
26
26
|
"vitest": "~0.19.1",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"shared-config": "1.0.0",
|
|
28
|
+
"@rokkit/core": "1.0.0-next.18"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"src/**/*.js",
|
package/src/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ const modifiers = {
|
|
|
3
3
|
rgb: (value) => `rgb(${value})`,
|
|
4
4
|
none: (value) => value
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Generate shades for a color using css varuable
|
|
8
9
|
*
|
|
@@ -11,19 +12,31 @@ const modifiers = {
|
|
|
11
12
|
*/
|
|
12
13
|
export function shadesOf(name, modifier = 'none') {
|
|
13
14
|
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]
|
|
14
|
-
const fn = modifier in modifiers ? modifiers[modifier] :
|
|
15
|
+
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.none
|
|
15
16
|
|
|
16
17
|
return shades.reduce(
|
|
17
18
|
(result, shade) => ({
|
|
18
19
|
...result,
|
|
19
20
|
[shade]: fn(`var(--${name}-${shade})`)
|
|
20
21
|
}),
|
|
21
|
-
{
|
|
22
|
+
{
|
|
23
|
+
DEFAULT: fn(`var(--${name}-500)`),
|
|
24
|
+
inset: fn(`var(--${name}-50)`),
|
|
25
|
+
sunken: fn(`var(--${name}-50)`),
|
|
26
|
+
recessed: fn(`var(--${name}-50)`),
|
|
27
|
+
base: fn(`var(--${name}-100)`),
|
|
28
|
+
subtle: fn(`var(--${name}-200)`),
|
|
29
|
+
muted: fn(`var(--${name}-300)`),
|
|
30
|
+
raised: fn(`var(--${name}-400)`),
|
|
31
|
+
elevated: fn(`var(--${name}-500)`),
|
|
32
|
+
floating: fn(`var(--${name}-600)`),
|
|
33
|
+
contrast: fn(`var(--${name}-700)`)
|
|
34
|
+
}
|
|
22
35
|
)
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
export function stateColors(name, modifier = 'none') {
|
|
26
|
-
const fn = modifier in modifiers ? modifiers[modifier] :
|
|
39
|
+
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.none
|
|
27
40
|
return {
|
|
28
41
|
DEFAULT: fn(`var(--${name}-500)`),
|
|
29
42
|
light: fn(`var(--${name}-100)`),
|
|
@@ -32,7 +45,7 @@ export function stateColors(name, modifier = 'none') {
|
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
export function themeColors(modifier = 'none') {
|
|
35
|
-
const fn = modifier in modifiers ? modifiers[modifier] :
|
|
48
|
+
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.none
|
|
36
49
|
|
|
37
50
|
let states = ['info', 'error', 'warn', 'pass']
|
|
38
51
|
let variants = ['skin', 'primary', 'secondary', 'accent']
|
|
@@ -44,11 +57,10 @@ export function themeColors(modifier = 'none') {
|
|
|
44
57
|
(acc, variant) => ({ ...acc, [variant]: shadesOf(variant, modifier) }),
|
|
45
58
|
colors
|
|
46
59
|
)
|
|
47
|
-
|
|
60
|
+
// console.log('colors', colors)
|
|
48
61
|
colors.skin = {
|
|
49
62
|
...colors.skin,
|
|
50
63
|
contrast: fn(`var(--skin-800)`),
|
|
51
|
-
base: fn(`var(--skin-100)`),
|
|
52
64
|
zebra: fn(`var(--skin-zebra)`)
|
|
53
65
|
}
|
|
54
66
|
|
|
@@ -67,22 +79,17 @@ export function themeColors(modifier = 'none') {
|
|
|
67
79
|
// )
|
|
68
80
|
// }
|
|
69
81
|
|
|
70
|
-
export function iconShortcuts(icons, collection,
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
: name.replace('rating', 'star').replace('navigate', 'chevron')) +
|
|
82
|
-
suffix
|
|
83
|
-
}),
|
|
84
|
-
{}
|
|
85
|
-
)
|
|
82
|
+
export function iconShortcuts(icons, collection, variants) {
|
|
83
|
+
const suffix = variants ? `-${variants}` : ''
|
|
84
|
+
const shortcuts = !collection
|
|
85
|
+
? {}
|
|
86
|
+
: icons.reduce(
|
|
87
|
+
(acc, name) => ({
|
|
88
|
+
...acc,
|
|
89
|
+
[name]: [collection, name].join(':') + suffix
|
|
90
|
+
}),
|
|
91
|
+
{}
|
|
92
|
+
)
|
|
86
93
|
|
|
87
94
|
return shortcuts
|
|
88
95
|
}
|