@rokkit/core 1.10.1 → 1.11.1
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/dist/theme.d.ts +6 -4
- package/package.json +2 -2
- package/src/theme.ts +15 -9
package/dist/theme.d.ts
CHANGED
|
@@ -27,10 +27,12 @@ export declare function themeRules(mapping?: Mapping, colors?: Colors, colorSpac
|
|
|
27
27
|
* Generates "on-color" text shortcuts for readable text on colored backgrounds.
|
|
28
28
|
*
|
|
29
29
|
* The on-color is whichever of near-black / near-white best contrasts with the
|
|
30
|
-
* role's
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* role's fill (the principle: a fill takes black OR white text — never a mid
|
|
31
|
+
* tint, which fails AA on bright fills like vermillion). The utility reads the
|
|
32
|
+
* skin's `--on-{name}` variable, which the preset derives per skin and mode from
|
|
33
|
+
* the fill that skin actually paints; `onColor` (the build-time pick for the
|
|
34
|
+
* role's 500, see `Theme.#onColorHex`) is the fallback where no variable is set,
|
|
35
|
+
* e.g. a stylesheet compiled ahead of the app.
|
|
34
36
|
*
|
|
35
37
|
* - `text-on-{name}` → readable text on a z5+ fill
|
|
36
38
|
* - `text-on-{name}-muted` → same on-color (kept for back-compat callers)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"ramda": "^0.32.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@rokkit/icons": "1.
|
|
50
|
+
"@rokkit/icons": "1.11.1"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/theme.ts
CHANGED
|
@@ -91,10 +91,12 @@ export function themeRules(
|
|
|
91
91
|
* Generates "on-color" text shortcuts for readable text on colored backgrounds.
|
|
92
92
|
*
|
|
93
93
|
* The on-color is whichever of near-black / near-white best contrasts with the
|
|
94
|
-
* role's
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
94
|
+
* role's fill (the principle: a fill takes black OR white text — never a mid
|
|
95
|
+
* tint, which fails AA on bright fills like vermillion). The utility reads the
|
|
96
|
+
* skin's `--on-{name}` variable, which the preset derives per skin and mode from
|
|
97
|
+
* the fill that skin actually paints; `onColor` (the build-time pick for the
|
|
98
|
+
* role's 500, see `Theme.#onColorHex`) is the fallback where no variable is set,
|
|
99
|
+
* e.g. a stylesheet compiled ahead of the app.
|
|
98
100
|
*
|
|
99
101
|
* - `text-on-{name}` → readable text on a z5+ fill
|
|
100
102
|
* - `text-on-{name}-muted` → same on-color (kept for back-compat callers)
|
|
@@ -104,12 +106,16 @@ export function themeRules(
|
|
|
104
106
|
* @returns {Array} Array of shortcut definitions
|
|
105
107
|
*/
|
|
106
108
|
export function contrastShortcuts(name: string, onColor = '#fafafa') {
|
|
109
|
+
const color = `var(--on-${name},${onColor})`
|
|
110
|
+
// An app's UnoCSS scans this file; without the skip it extracts the template below as a
|
|
111
|
+
// class and emits its placeholder text as CSS, which postcss rejects (scanned-sources.spec).
|
|
112
|
+
// @unocss-skip-start
|
|
113
|
+
const text = ([, end]: string[]) =>
|
|
114
|
+
end ? `text-[color-mix(in_srgb,${color}_${end.slice(1)}%,transparent)]` : `text-[${color}]`
|
|
115
|
+
// @unocss-skip-end
|
|
107
116
|
return [
|
|
108
|
-
[new RegExp(`^text-on-${name}(\\/\\d+)?$`),
|
|
109
|
-
[
|
|
110
|
-
new RegExp(`^text-on-${name}-muted(\\/\\d+)?$`),
|
|
111
|
-
([, end]: string[]) => `text-[${onColor}]${end || ''}`
|
|
112
|
-
]
|
|
117
|
+
[new RegExp(`^text-on-${name}(\\/\\d+)?$`), text],
|
|
118
|
+
[new RegExp(`^text-on-${name}-muted(\\/\\d+)?$`), text]
|
|
113
119
|
]
|
|
114
120
|
}
|
|
115
121
|
|