@kiva/kv-tokens 2.16.1 → 3.1.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/.eslintrc.cjs +8 -0
- package/CHANGELOG.md +25 -0
- package/README.md +5 -3
- package/build/{build.cjs → build.js} +5 -5
- package/configs/{kivaColors.cjs → kivaColors.js} +15 -30
- package/configs/kivaHeadingUnderline.js +55 -0
- package/configs/{kivaTypography.cjs → kivaTypography.js} +7 -14
- package/configs/{tailwind.config.cjs → tailwind.config.js} +14 -10
- package/configs/{kivaHeadingUnderline.cjs → underlinePath.js} +1 -58
- package/configs/{util.cjs → util.js} +5 -13
- package/index.js +5 -1
- package/package.json +3 -3
- package/primitives.js +522 -0
- package/primitives.json +0 -522
package/.eslintrc.cjs
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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
|
+
# [3.1.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@3.0.0...@kiva/kv-tokens@3.1.0) (2025-01-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **kv-tokens:** export configs from main ([f405e6d](https://github.com/kiva/kv-ui-elements/commit/f405e6def81d504d7558068f8aba52b1388b073b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.0.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@2.16.1...@kiva/kv-tokens@3.0.0) (2025-01-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
* refactor(kv-tokens)!: convert all modules to esm ([f09dd82](https://github.com/kiva/kv-ui-elements/commit/f09dd821e4060570767abb490db45836ecd9b80a))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
* modules now use import/export and .js extensions
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
## [2.16.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-tokens@2.16.0...@kiva/kv-tokens@2.16.1) (2025-01-04)
|
|
7
32
|
|
|
8
33
|
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The package contains
|
|
|
12
12
|
## Using the Design Definitions
|
|
13
13
|
|
|
14
14
|
```js
|
|
15
|
-
|
|
15
|
+
import designTokens from '@kiva/kv-tokens';
|
|
16
16
|
|
|
17
17
|
const primaryTextColor = designTokens.colors.theme.DEFAULT.text.primary;
|
|
18
18
|
```
|
|
@@ -21,8 +21,10 @@ const primaryTextColor = designTokens.colors.theme.DEFAULT.text.primary;
|
|
|
21
21
|
|
|
22
22
|
```js
|
|
23
23
|
// tailwind.config.js
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import { tailwindConfig } from "@kiva/kv-tokens";
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
presets: [tailwindConfig],
|
|
26
28
|
// Project-specific customizations
|
|
27
29
|
theme: {
|
|
28
30
|
//...
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import designTokens from '../primitives.js';
|
|
3
|
+
import { generateExternalSVG } from '../configs/kivaHeadingUnderline.js';
|
|
4
|
+
import { flattenJSON } from '../configs/util.js';
|
|
5
5
|
|
|
6
6
|
// Note: dir is relative to the root of the kv-tokens package
|
|
7
7
|
const dir = '../../dist/kvui';
|
|
@@ -17,7 +17,7 @@ fs.writeFileSync(`${dir}/heading-underline.svg`, svg);
|
|
|
17
17
|
|
|
18
18
|
// Generate SCSS variables
|
|
19
19
|
const today = new Date().toUTCString();
|
|
20
|
-
const variables = flattenJSON(
|
|
20
|
+
const variables = flattenJSON(designTokens);
|
|
21
21
|
const scss = Object.keys(variables)
|
|
22
22
|
.map((key) => `$${key.toLowerCase().replace('.', '-')}: ${variables[key]};`)
|
|
23
23
|
.join('\n');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { hexToRGB } from './util.js';
|
|
2
|
+
import designTokens from '../primitives.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
DEFAULT: defaultThemeTokens,
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
mint: mintThemeTokens,
|
|
14
14
|
'dark-mint': darkMintThemeTokens,
|
|
15
15
|
'dark-stone': darkStoneThemeTokens,
|
|
16
|
-
} =
|
|
16
|
+
} = designTokens.colors.theme;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Loops through a theme object and builds a set of CSS custom properties
|
|
@@ -42,17 +42,17 @@ const buildCSSVarsFromTokens = (theme) => {
|
|
|
42
42
|
return customProperties;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const defaultTheme = buildCSSVarsFromTokens(defaultThemeTokens);
|
|
46
|
-
const greenLightTheme = buildCSSVarsFromTokens(greenLightThemeTokens);
|
|
47
|
-
const greenDarkTheme = buildCSSVarsFromTokens(greenDarkThemeTokens);
|
|
48
|
-
const marigoldLightTheme = buildCSSVarsFromTokens(marigoldLightThemeTokens);
|
|
49
|
-
const stoneLightTheme = buildCSSVarsFromTokens(stoneLightThemeTokens);
|
|
50
|
-
const stoneDarkTheme = buildCSSVarsFromTokens(stoneDarkThemeTokens);
|
|
51
|
-
const darkTheme = buildCSSVarsFromTokens(darkThemeTokens);
|
|
52
|
-
const mintTheme = buildCSSVarsFromTokens(mintThemeTokens);
|
|
53
|
-
const darkGreenTheme = buildCSSVarsFromTokens(darkGreenThemeTokens);
|
|
54
|
-
const darkMintTheme = buildCSSVarsFromTokens(darkMintThemeTokens);
|
|
55
|
-
const darkStoneTheme = buildCSSVarsFromTokens(darkStoneThemeTokens);
|
|
45
|
+
export const defaultTheme = buildCSSVarsFromTokens(defaultThemeTokens);
|
|
46
|
+
export const greenLightTheme = buildCSSVarsFromTokens(greenLightThemeTokens);
|
|
47
|
+
export const greenDarkTheme = buildCSSVarsFromTokens(greenDarkThemeTokens);
|
|
48
|
+
export const marigoldLightTheme = buildCSSVarsFromTokens(marigoldLightThemeTokens);
|
|
49
|
+
export const stoneLightTheme = buildCSSVarsFromTokens(stoneLightThemeTokens);
|
|
50
|
+
export const stoneDarkTheme = buildCSSVarsFromTokens(stoneDarkThemeTokens);
|
|
51
|
+
export const darkTheme = buildCSSVarsFromTokens(darkThemeTokens);
|
|
52
|
+
export const mintTheme = buildCSSVarsFromTokens(mintThemeTokens);
|
|
53
|
+
export const darkGreenTheme = buildCSSVarsFromTokens(darkGreenThemeTokens);
|
|
54
|
+
export const darkMintTheme = buildCSSVarsFromTokens(darkMintThemeTokens);
|
|
55
|
+
export const darkStoneTheme = buildCSSVarsFromTokens(darkStoneThemeTokens);
|
|
56
56
|
|
|
57
57
|
// function to allow background opacity and text opacity with tailwind colors
|
|
58
58
|
// https://www.youtube.com/watch?v=MAtaT8BZEAo
|
|
@@ -82,7 +82,7 @@ const withOpacity = (variableName) => ({ opacityValue }) => {
|
|
|
82
82
|
* ...
|
|
83
83
|
* }
|
|
84
84
|
*/
|
|
85
|
-
const buildColorChoices = (themeProperty) => {
|
|
85
|
+
export const buildColorChoices = (themeProperty) => {
|
|
86
86
|
let twPrefix = themeProperty;
|
|
87
87
|
if (themeProperty === 'background') {
|
|
88
88
|
twPrefix = 'bg';
|
|
@@ -96,18 +96,3 @@ const buildColorChoices = (themeProperty) => {
|
|
|
96
96
|
});
|
|
97
97
|
return property;
|
|
98
98
|
};
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
buildColorChoices,
|
|
102
|
-
defaultTheme,
|
|
103
|
-
greenLightTheme,
|
|
104
|
-
greenDarkTheme,
|
|
105
|
-
marigoldLightTheme,
|
|
106
|
-
stoneLightTheme,
|
|
107
|
-
stoneDarkTheme,
|
|
108
|
-
darkTheme,
|
|
109
|
-
darkGreenTheme,
|
|
110
|
-
mintTheme,
|
|
111
|
-
darkMintTheme,
|
|
112
|
-
darkStoneTheme,
|
|
113
|
-
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import designTokens from '../primitives.js';
|
|
2
|
+
import { base64 } from './util.js';
|
|
3
|
+
import underlinePath from './underlinePath.js';
|
|
4
|
+
|
|
5
|
+
const { colors } = designTokens;
|
|
6
|
+
const svgOpenTag = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 921 16" preserveAspectRatio="none">';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Generates an SVG string for brush-stroke underlines, with colors from each theme. This is
|
|
10
|
+
* achieved by creating one path for the brush stroke, and then using multiple <use> elements to
|
|
11
|
+
* reference the path and fill it with the desired color (a sprite sheet technique from
|
|
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('/kvui/heading-underline.svg#2AA967')`.
|
|
14
|
+
* This allows us to use the same SVG for all themes, and change the color with CSS custom
|
|
15
|
+
* properties, rather than having to generate a new SVG for each color.
|
|
16
|
+
*/
|
|
17
|
+
export function generateExternalSVG() {
|
|
18
|
+
const { theme } = colors;
|
|
19
|
+
const themeColors = Object.keys(theme)
|
|
20
|
+
.filter((key) => theme[key]['heading-underline'])
|
|
21
|
+
.flatMap((key) => Object.values(theme[key]['heading-underline']));
|
|
22
|
+
const colorList = [...new Set(themeColors)];
|
|
23
|
+
|
|
24
|
+
const colorDefs = colorList.map((color) => {
|
|
25
|
+
return `<g id="${color.replace('#', '')}"><use href="#hu-path" fill="${color}" /></g>`;
|
|
26
|
+
});
|
|
27
|
+
return `${svgOpenTag}
|
|
28
|
+
<defs>
|
|
29
|
+
<style>
|
|
30
|
+
g { display: none; }
|
|
31
|
+
g:target { display: inline; }
|
|
32
|
+
</style>
|
|
33
|
+
</defs>
|
|
34
|
+
${colorDefs.join('')}
|
|
35
|
+
<symbol id="hu-path">
|
|
36
|
+
${underlinePath}
|
|
37
|
+
</symbol>
|
|
38
|
+
</svg>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Generates an inline-style SVG string for brush-stroke underlines, in one color only, to be used as a background image in css.
|
|
43
|
+
*
|
|
44
|
+
* THIS SHOULD ONLY BE USED FOR DEMO PURPOSES.
|
|
45
|
+
*
|
|
46
|
+
* This will greatly increase the size of your css file if used in production with multiple colors.
|
|
47
|
+
*/
|
|
48
|
+
export function generateInlineSVG(color) {
|
|
49
|
+
const svg = `${svgOpenTag}
|
|
50
|
+
<g fill="${color}">
|
|
51
|
+
${underlinePath}
|
|
52
|
+
</g>
|
|
53
|
+
</svg>`;
|
|
54
|
+
return `url('data:image/svg+xml;base64,${base64(svg)}')`;
|
|
55
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { rem, em } from './util.js';
|
|
2
|
+
import designTokens from '../primitives.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
fonts,
|
|
@@ -9,12 +9,12 @@ const {
|
|
|
9
9
|
lineHeights,
|
|
10
10
|
radii,
|
|
11
11
|
space,
|
|
12
|
-
} =
|
|
12
|
+
} = designTokens;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
WEB FONT DEFINITIONS
|
|
16
16
|
*/
|
|
17
|
-
const webFonts = [
|
|
17
|
+
export const webFonts = [
|
|
18
18
|
// Note corresponding font weight in Tailwind is "normal"
|
|
19
19
|
{
|
|
20
20
|
'@font-face': {
|
|
@@ -61,12 +61,12 @@ const webFonts = [
|
|
|
61
61
|
];
|
|
62
62
|
|
|
63
63
|
/** BASE TEXT COLOR */
|
|
64
|
-
const textBaseColor = 'rgb(var(--text-primary))';
|
|
64
|
+
export const textBaseColor = 'rgb(var(--text-primary))';
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
REUSABLE TYPE STYLES
|
|
68
68
|
*/
|
|
69
|
-
const textStyles = (() => {
|
|
69
|
+
export const textStyles = (() => {
|
|
70
70
|
const textJumbo = {
|
|
71
71
|
fontFamily: fonts.serif,
|
|
72
72
|
fontWeight: fontWeights.medium,
|
|
@@ -234,7 +234,7 @@ See plugin styling here:
|
|
|
234
234
|
https://github.com/tailwindlabs/tailwindcss-typography/blob/master/src/styles.js
|
|
235
235
|
*/
|
|
236
236
|
|
|
237
|
-
const proseOverrides = () => ({
|
|
237
|
+
export const proseOverrides = () => ({
|
|
238
238
|
DEFAULT: {
|
|
239
239
|
css: [{
|
|
240
240
|
color: false,
|
|
@@ -448,10 +448,3 @@ const proseOverrides = () => ({
|
|
|
448
448
|
xl: false,
|
|
449
449
|
'2xl': false,
|
|
450
450
|
});
|
|
451
|
-
|
|
452
|
-
module.exports = {
|
|
453
|
-
webFonts,
|
|
454
|
-
textBaseColor,
|
|
455
|
-
textStyles,
|
|
456
|
-
proseOverrides,
|
|
457
|
-
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import plugin from 'tailwindcss/plugin.js';
|
|
2
|
+
import typographyPlugin from '@tailwindcss/typography';
|
|
3
|
+
import {
|
|
4
|
+
proseOverrides,
|
|
5
|
+
textBaseColor,
|
|
6
|
+
textStyles,
|
|
7
|
+
webFonts,
|
|
8
|
+
} from './kivaTypography.js';
|
|
9
|
+
import { defaultTheme, buildColorChoices } from './kivaColors.js';
|
|
10
|
+
import designTokens from '../primitives.js';
|
|
11
|
+
import { rem } from './util.js';
|
|
7
12
|
|
|
8
13
|
const {
|
|
9
14
|
fonts,
|
|
@@ -15,9 +20,9 @@ const {
|
|
|
15
20
|
space,
|
|
16
21
|
radii,
|
|
17
22
|
zIndices,
|
|
18
|
-
} =
|
|
23
|
+
} = designTokens;
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
export default {
|
|
21
26
|
content: ['./**.*.js'],
|
|
22
27
|
prefix: 'tw-', // prefixes all tailwinds classes with tw. e.g., 'tw-flex tw-mb-2'
|
|
23
28
|
corePlugins: {
|
|
@@ -136,7 +141,7 @@ module.exports = {
|
|
|
136
141
|
lg: '0 4px 12px rgba(0, 0, 0, 0.08)',
|
|
137
142
|
},
|
|
138
143
|
extend: {
|
|
139
|
-
typography:
|
|
144
|
+
typography: proseOverrides, // prose plugin overrides
|
|
140
145
|
height: {
|
|
141
146
|
40: rem(320),
|
|
142
147
|
57.5: rem(460),
|
|
@@ -182,7 +187,6 @@ module.exports = {
|
|
|
182
187
|
plugins: [
|
|
183
188
|
typographyPlugin, // prose plugin. See overrides in theme.extend.typography
|
|
184
189
|
plugin(({ addBase, addUtilities }) => {
|
|
185
|
-
const { webFonts, textStyles, textBaseColor } = kivaTypography;
|
|
186
190
|
addBase(webFonts);
|
|
187
191
|
addBase({
|
|
188
192
|
body: {
|