@kiva/kv-tokens 2.14.0 → 2.16.0
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/CHANGELOG.md +22 -0
- package/build/build.cjs +12 -1
- package/configs/kivaColors.cjs +1 -1
- package/configs/kivaHeadingUnderline.cjs +1 -1
- package/configs/util.cjs +16 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.16.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@2.15.0...@kiva/kv-tokens@2.16.0) (2024-11-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **kv-tokens:** generate scss variables from primitives.json during build ([1567bbf](https://github.com/kiva/kv-ui-elements/commit/1567bbfe3411f003963b439e63628326822e57ac))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [2.15.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@2.14.0...@kiva/kv-tokens@2.15.0) (2024-11-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* serve static assets from kvui directory MP-544 ([840f6de](https://github.com/kiva/kv-ui-elements/commit/840f6de89f213143218d28e82a7ef0be1de319b6))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [2.14.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@2.13.0...@kiva/kv-tokens@2.14.0) (2024-11-15)
|
|
7
29
|
|
|
8
30
|
|
package/build/build.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const fs = require('node:fs');
|
|
2
|
+
const primitives = require('../primitives.json');
|
|
2
3
|
const { generateExternalSVG } = require('../configs/kivaHeadingUnderline.cjs');
|
|
4
|
+
const { flattenJSON } = require('../configs/util.cjs');
|
|
3
5
|
|
|
4
6
|
// Note: dir is relative to the root of the kv-tokens package
|
|
5
|
-
const dir = '../../dist/
|
|
7
|
+
const dir = '../../dist/kvui';
|
|
6
8
|
|
|
7
9
|
// Create dist folder
|
|
8
10
|
if (!fs.existsSync(dir)) {
|
|
@@ -12,3 +14,12 @@ if (!fs.existsSync(dir)) {
|
|
|
12
14
|
// Generate Heading Underline SVG
|
|
13
15
|
const svg = generateExternalSVG();
|
|
14
16
|
fs.writeFileSync(`${dir}/heading-underline.svg`, svg);
|
|
17
|
+
|
|
18
|
+
// Generate SCSS variables
|
|
19
|
+
const today = new Date().toUTCString();
|
|
20
|
+
const variables = flattenJSON(primitives);
|
|
21
|
+
const scss = Object.keys(variables)
|
|
22
|
+
.map((key) => `$${key.toLowerCase().replace('.', '-')}: ${variables[key]};`)
|
|
23
|
+
.join('\n');
|
|
24
|
+
const withComment = `// Do not edit directly.\n// Generated on ${today}. \n\n${scss}\n`;
|
|
25
|
+
fs.writeFileSync(`${dir}/tw-exported-vars.scss`, withComment);
|
package/configs/kivaColors.cjs
CHANGED
|
@@ -33,7 +33,7 @@ const buildCSSVarsFromTokens = (theme) => {
|
|
|
33
33
|
properties.forEach((property) => {
|
|
34
34
|
const key = `--${twPrefix}-${property}`;
|
|
35
35
|
if (category === 'heading-underline') {
|
|
36
|
-
customProperties[key] = `url('/heading-underline.svg${theme[category][property]}')`;
|
|
36
|
+
customProperties[key] = `url('/kvui/heading-underline.svg${theme[category][property]}')`;
|
|
37
37
|
} else {
|
|
38
38
|
customProperties[key] = hexToRGB(theme[category][property]);
|
|
39
39
|
}
|
|
@@ -10,7 +10,7 @@ const svgOpenTag = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 921 16"
|
|
|
10
10
|
* achieved by creating one path for the brush stroke, and then using multiple <use> elements to
|
|
11
11
|
* reference the path and fill it with the desired color (a sprite sheet technique from
|
|
12
12
|
* https://css-tricks.com/svg-fragment-identifiers-work/). The SVG is then used as a background
|
|
13
|
-
* image, and can be referenced by the color hex code, e.g. `url('/heading-underline.svg#2AA967')`.
|
|
13
|
+
* image, and can be referenced by the color hex code, e.g. `url('/kvui/heading-underline.svg#2AA967')`.
|
|
14
14
|
* This allows us to use the same SVG for all themes, and change the color with CSS custom
|
|
15
15
|
* properties, rather than having to generate a new SVG for each color.
|
|
16
16
|
*/
|
package/configs/util.cjs
CHANGED
|
@@ -20,9 +20,25 @@ const base64 = (str) => {
|
|
|
20
20
|
return window.btoa(str);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
const flattenJSON = (obj, parentKey = '') => {
|
|
24
|
+
const flattened = {};
|
|
25
|
+
|
|
26
|
+
Object.keys(obj).forEach((key) => {
|
|
27
|
+
const newKey = parentKey ? `${parentKey}-${key}` : key;
|
|
28
|
+
if (typeof obj[key] === 'object') {
|
|
29
|
+
Object.assign(flattened, flattenJSON(obj[key], newKey));
|
|
30
|
+
} else {
|
|
31
|
+
flattened[newKey] = obj[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return flattened;
|
|
36
|
+
};
|
|
37
|
+
|
|
23
38
|
module.exports = {
|
|
24
39
|
rem,
|
|
25
40
|
em,
|
|
26
41
|
hexToRGB,
|
|
27
42
|
base64,
|
|
43
|
+
flattenJSON,
|
|
28
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-tokens",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"@tailwindcss/typography": "^0.5.1",
|
|
16
16
|
"tailwindcss": "^3.4.3"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "08194e4f0e494513527cfe20faff626f4843fb98"
|
|
19
19
|
}
|