@kong/design-tokens 1.6.2 → 1.7.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/README.md +56 -18
- package/TOKENS.md +1477 -402
- package/dist/tokens/README.md +1477 -402
- package/dist/tokens/css/custom-properties-list.css +317 -0
- package/dist/tokens/css/custom-properties.css +157 -0
- package/dist/tokens/js/cjs/index.d.ts +1 -1
- package/dist/tokens/js/cjs/index.js +1 -1
- package/dist/tokens/js/index.d.ts +1 -1
- package/dist/tokens/js/index.mjs +1 -1
- package/dist/tokens/js/tokens.json +148 -0
- package/dist/tokens/less/variables.less +154 -0
- package/dist/tokens/scss/_map.scss +278 -0
- package/dist/tokens/scss/_mixins.scss +1 -1
- package/dist/tokens/scss/_variables.scss +1 -1
- package/package.json +6 -2
- package/dist/tokens/css/variables.css +0 -171
package/README.md
CHANGED
|
@@ -6,9 +6,10 @@ Kong Design Tokens, via [Style Dictionary](https://github.com/amzn/style-diction
|
|
|
6
6
|
|
|
7
7
|
- [Tokens](#tokens)
|
|
8
8
|
- [Token Formats](#token-formats)
|
|
9
|
-
- [SCSS
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
9
|
+
- [SCSS](#scss)
|
|
10
|
+
- [LESS](#less)
|
|
11
|
+
- [JavaScript](#javascript)
|
|
12
|
+
- [CSS Custom Properties](#css-custom-properties)
|
|
12
13
|
- [Usage](#usage)
|
|
13
14
|
- [Installation](#installation)
|
|
14
15
|
- [Recommended VS Code extension](#recommended-vs-code-extension)
|
|
@@ -44,19 +45,21 @@ Exports are available from the package root, meaning you do not need to include
|
|
|
44
45
|
import { KUI_COLOR_BACKGROUND_PRIMARY_STRONG } from '@kong/design-tokens'
|
|
45
46
|
```
|
|
46
47
|
|
|
47
|
-
### SCSS
|
|
48
|
+
### SCSS
|
|
49
|
+
|
|
50
|
+
#### SCSS Variables
|
|
48
51
|
|
|
49
52
|
SCSS variables can be utilized in your project's SCSS files or in-component style blocks (this assumes your app is already configured to compile Sass).
|
|
50
53
|
|
|
51
54
|
To use the SCSS variables, you need to import them into your component or app stylesheet so they are available throughout your project utilizing one of the methods below:
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
##### Import into your app or component's stylesheet or style block
|
|
54
57
|
|
|
55
58
|
```scss
|
|
56
59
|
@import '@kong/design-tokens/tokens/scss/variables';
|
|
57
60
|
```
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
##### Globally import with Vite
|
|
60
63
|
|
|
61
64
|
If your component or application utilizes [Vite](https://vitejs.dev/) to build and compile, you may add the following configuration to your `vite.config.ts` to import the SCSS variables into all components within your project
|
|
62
65
|
|
|
@@ -76,7 +79,28 @@ export default defineConfig({
|
|
|
76
79
|
})
|
|
77
80
|
```
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
#### SCSS Map
|
|
83
|
+
|
|
84
|
+
The package also exports a SCSS map of the tokens from the `@kong/design-tokens/tokens/scss/map` file
|
|
85
|
+
|
|
86
|
+
```scss
|
|
87
|
+
$tokens-map: (
|
|
88
|
+
'kui-color-background': #ffffff,
|
|
89
|
+
// ... etc.
|
|
90
|
+
);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### LESS
|
|
94
|
+
|
|
95
|
+
#### LESS Variables
|
|
96
|
+
|
|
97
|
+
LESS variables can be utilized in your project's LESS files or in-component style blocks (this assumes your app is already configured to compile LESS).
|
|
98
|
+
|
|
99
|
+
To use the LESS variables, you need to import them into your component or app stylesheet so they are available throughout your project via the export from `@kong/design-tokens/tokens/less/variables.less`.
|
|
100
|
+
|
|
101
|
+
### JavaScript
|
|
102
|
+
|
|
103
|
+
#### JavaScript Variables
|
|
80
104
|
|
|
81
105
|
JavaScript variables can be utilized in your project's component files, or other JavaScript/TypeScript files.
|
|
82
106
|
|
|
@@ -87,17 +111,31 @@ To use the JavaScript variables, simply import the variables you need into your
|
|
|
87
111
|
import { KUI_COLOR_BACKGROUND_PRIMARY_STRONG } from '@kong/design-tokens'
|
|
88
112
|
```
|
|
89
113
|
|
|
90
|
-
|
|
114
|
+
#### JSON
|
|
91
115
|
|
|
92
|
-
|
|
116
|
+
The package also exports a JSON file of all tokens from `@kong/design-tokens/tokens/js/tokens.json`
|
|
93
117
|
|
|
94
|
-
|
|
118
|
+
### CSS Custom Properties
|
|
95
119
|
|
|
96
|
-
|
|
120
|
+
You may scope your CSS variable overrides inside the `:root` selector as shown here, or inside any other valid CSS selector.
|
|
97
121
|
|
|
98
|
-
|
|
122
|
+
Two versions of the [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) are exported from the package.
|
|
99
123
|
|
|
100
|
-
|
|
124
|
+
#### `@kong/design-tokens/tokens/css/custom-properties.css`
|
|
125
|
+
|
|
126
|
+
This file exports all available custom properties with the values set to their actual raw value.
|
|
127
|
+
|
|
128
|
+
#### `@kong/design-tokens/tokens/css/custom-properties-list.css`
|
|
129
|
+
|
|
130
|
+
This file exports the custom properties with a value of `initial`; mainly used for IDE auto-completion where you do not actually need the token values.
|
|
131
|
+
|
|
132
|
+
> **IMPORTANT**: You should **never** import the `@kong/design-tokens/tokens/css/custom-properties-list.css` file in your host project.
|
|
133
|
+
>
|
|
134
|
+
> While CSS variables are _utilized_ in Kong's repositories to allow for CSS customization, the variables themselves are never actually provided values or imported from this package.
|
|
135
|
+
>
|
|
136
|
+
> The purpose of the `@kong/design-tokens/tokens/css/custom-properties-list.css` file is to provide a list of all available CSS variables, to utilize alongside auto-complete extensions in your IDE, etc.
|
|
137
|
+
>
|
|
138
|
+
> If you want to customize default token values, provided the element(s) in question utilize CSS variable fallbacks, simply set the variables from this list to your desired value within your host application, scoped inside your desired CSS selector, and it will override the default value.
|
|
101
139
|
|
|
102
140
|
```html
|
|
103
141
|
<style>
|
|
@@ -164,14 +202,14 @@ As an example, in Kong's [Kongponents](https://kongponents.konghq.com) Vue compo
|
|
|
164
202
|
|
|
165
203
|
.my-component-class {
|
|
166
204
|
/**
|
|
167
|
-
* When setting a CSS variable value to a SCSS variable, you need to
|
|
168
|
-
* interpolate the SCSS variable. Interpolation can be used
|
|
169
|
-
* almost anywhere in a Sass stylesheet to embed the result of a
|
|
170
|
-
* SassScript expression into a chunk of CSS.
|
|
205
|
+
* When setting a CSS variable value to a SCSS variable, you need to
|
|
206
|
+
* interpolate the SCSS variable. Interpolation can be used
|
|
207
|
+
* almost anywhere in a Sass stylesheet to embed the result of a
|
|
208
|
+
* SassScript expression into a chunk of CSS.
|
|
171
209
|
* Just wrap the expression in `#{}`
|
|
172
210
|
*/
|
|
173
211
|
--my-custom-scoped-css-variable: var(--kui-space-20, #{$kui-space-20});
|
|
174
|
-
|
|
212
|
+
|
|
175
213
|
margin: var(--my-custom-scoped-css-variable, #{$kui-space-10});
|
|
176
214
|
color: var(--kui-color-text-primary, $kui-color-text-primary);
|
|
177
215
|
font-weight: var(--kui-font-weight-semibold, $kui-font-weight-semibold);
|