@rokkit/themes 1.0.0-next.11

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jerry Thomas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Themes
2
+
3
+ Contains the following themes for use with `Rokkit` components.
4
+
5
+ - Rokkit
6
+ - Modern
7
+ - Material
8
+
9
+ This package also includes some mixins which make it easy to implement `light` and `dark` modes.
10
+
11
+ - markdown.css: A customized variant of Github flavored markdown
12
+ - prism.css: A variation of the prism syntax highlighting colors using CSS variables to support light and dark modes.
13
+ - palette.css: Light and dark palettes using CSS variables.
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@rokkit/themes",
3
+ "version": "1.0.0-next.11",
4
+ "description": "Themes for use with rokkit components.",
5
+ "author": "Jerry Thomas <me@jerrythomas.name>",
6
+ "license": "MIT",
7
+ "svelte": "src/index.js",
8
+ "module": "src/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "type": "module",
11
+ "prettier": "@jerrythomas/prettier-config",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "devDependencies": {
16
+ "@jerrythomas/eslint-config-svelte": "^1.0.2",
17
+ "@jerrythomas/prettier-config": "^1.0.0",
18
+ "@sveltejs/vite-plugin-svelte": "^1.4.0",
19
+ "@vitest/ui": "~0.12.10",
20
+ "c8": "^7.12.0",
21
+ "eslint": "^7.32.0",
22
+ "jsdom": "^19.0.0",
23
+ "svelte": "^3.55.1",
24
+ "typescript": "^4.9.5",
25
+ "vite": "^3.2.5",
26
+ "vitest": "~0.19.1",
27
+ "@rokkit/core": "1.0.0-next.11",
28
+ "shared-config": "1.0.0"
29
+ },
30
+ "files": [
31
+ "src/**/*.js",
32
+ "src/**/*.svelte",
33
+ "!src/fixtures",
34
+ "!src/**/*.spec.js"
35
+ ],
36
+ "exports": {
37
+ "./modern.css": "./src/modern.css",
38
+ "./material.css": "./src/material.css",
39
+ "./minimal.css": "./src/minimal.css",
40
+ "./rokkit.css": "./src/rokkit.css",
41
+ "./prism.css": "./src/prism.css",
42
+ "./palette.css": "./src/palette.css",
43
+ "./markdown.css": "./src/markdown.css",
44
+ "./package.json": "./src/package.json",
45
+ ".": {
46
+ "import": "./src/index.js"
47
+ }
48
+ },
49
+ "scripts": {
50
+ "lint": "prettier --check --plugin-search-dir=. . && eslint .",
51
+ "format": "prettier --write --plugin-search-dir=. .",
52
+ "test:ct": "playwright test -c playwright.config.js",
53
+ "test:ui": "vitest --ui",
54
+ "test:ci": "vitest run",
55
+ "test": "vitest",
56
+ "coverage": "vitest run --coverage",
57
+ "upgrade": "pnpm upgrade"
58
+ }
59
+ }
@@ -0,0 +1,4 @@
1
+ import { themeColors } from './utils'
2
+ export { defaultStateIcons, defaultIcons } from '@rokkit/core/constants'
3
+
4
+ export const defaultThemeColors = themeColors()
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './utils'
2
+ export * from './constants'
package/src/utils.js ADDED
@@ -0,0 +1,88 @@
1
+ const modifiers = {
2
+ hsl: (value) => `hsl(${value})`,
3
+ rgb: (value) => `rgb(${value})`,
4
+ none: (value) => value
5
+ }
6
+ /**
7
+ * Generate shades for a color using css varuable
8
+ *
9
+ * @param {string} name
10
+ * @returns
11
+ */
12
+ export function shadesOf(name, modifier = 'none') {
13
+ const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]
14
+ const fn = modifier in modifiers ? modifiers[modifier] : modifier.none
15
+
16
+ return shades.reduce(
17
+ (result, shade) => ({
18
+ ...result,
19
+ [shade]: fn(`var(--${name}-${shade})`)
20
+ }),
21
+ { DEFAULT: fn(`var(--${name}-500)`) }
22
+ )
23
+ }
24
+
25
+ export function stateColors(name, modifier = 'none') {
26
+ const fn = modifier in modifiers ? modifiers[modifier] : modifier.none
27
+ return {
28
+ DEFAULT: fn(`var(--${name}-500)`),
29
+ light: fn(`var(--${name}-100)`),
30
+ dark: fn(`var(--${name}-800)`)
31
+ }
32
+ }
33
+
34
+ export function themeColors(modifier = 'none') {
35
+ const fn = modifier in modifiers ? modifiers[modifier] : modifier.none
36
+
37
+ let states = ['info', 'error', 'warn', 'pass']
38
+ let variants = ['skin', 'primary', 'secondary', 'accent']
39
+ let colors = states.reduce(
40
+ (acc, state) => ({ ...acc, [state]: stateColors(state, modifier) }),
41
+ {}
42
+ )
43
+ colors = variants.reduce(
44
+ (acc, variant) => ({ ...acc, [variant]: shadesOf(variant, modifier) }),
45
+ colors
46
+ )
47
+
48
+ colors.skin = {
49
+ ...colors.skin,
50
+ contrast: fn(`var(--skin-800)`),
51
+ base: fn(`var(--skin-100)`),
52
+ zebra: fn(`var(--skin-zebra)`)
53
+ }
54
+
55
+ return colors
56
+ }
57
+
58
+ // export function stateIconsFromNames(names) {
59
+ // return names
60
+ // .map((k) => [...k.split('-'), k])
61
+ // .reduce(
62
+ // (acc, [element, state, icon]) => ({
63
+ // ...acc,
64
+ // [element]: { ...acc[element], [state]: icon }
65
+ // }),
66
+ // {}
67
+ // )
68
+ // }
69
+
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
+ )
86
+
87
+ return shortcuts
88
+ }