@rokkit/themes 1.0.0-next.17 → 1.0.0-next.19

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.
Files changed (2) hide show
  1. package/package.json +6 -6
  2. 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.17",
3
+ "version": "1.0.0-next.19",
4
4
  "description": "Themes for use with rokkit components.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -15,16 +15,16 @@
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.4.0",
18
+ "@sveltejs/vite-plugin-svelte": "^2.1.1",
19
19
  "@vitest/ui": "~0.12.10",
20
- "c8": "^7.12.0",
20
+ "c8": "^7.13.0",
21
21
  "eslint": "^7.32.0",
22
22
  "jsdom": "^19.0.0",
23
- "svelte": "^3.55.1",
23
+ "svelte": "^3.58.0",
24
24
  "typescript": "^4.9.5",
25
- "vite": "^3.2.5",
25
+ "vite": "^4.3.3",
26
26
  "vitest": "~0.19.1",
27
- "@rokkit/core": "1.0.0-next.17",
27
+ "@rokkit/core": "1.0.0-next.19",
28
28
  "shared-config": "1.0.0"
29
29
  },
30
30
  "files": [
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] : modifier.none
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
- { DEFAULT: fn(`var(--${name}-500)`) }
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] : modifier.none
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] : modifier.none
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, variant = '') {
71
- const prefix = collection ? collection + ':' : ''
72
- const suffix = variant ? '-' + variant : ''
73
-
74
- const shortcuts = icons.reduce(
75
- (acc, name) => ({
76
- ...acc,
77
- [name]:
78
- prefix +
79
- (name.startsWith('selector')
80
- ? 'chevron-sort'
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
  }