@kiva/kv-tokens 2.15.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 +11 -0
- package/build/build.cjs +11 -0
- package/configs/util.cjs +16 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
18
|
|
|
8
19
|
|
package/build/build.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
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
7
|
const dir = '../../dist/kvui';
|
|
@@ -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/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
|
}
|