@primer/primitives 8.0.0-rc.473cfc21 → 8.0.0-rc.5b958f65
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 +28 -94
- package/package.json +1 -1
- package/src/formats/cssVariables.ts +2 -2
package/README.md
CHANGED
|
@@ -16,109 +16,43 @@ npm install --save @primer/primitives
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
[Storybook](https://primer.style/primitives/storybook) | [Docs](https://primer.style/primitives/)
|
|
19
|
+
[Storybook](https://primer.style/primitives/storybook) | [Docs](https://primer.style/foundations/primitives/getting-started)
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
See [Primitives documentation](https://primer.style/foundations/primitives/getting-started) for more information on theming and using CSS variables.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
- `dist/json` contains JSON files for each set of primitives
|
|
25
|
-
- `dist/js` contains CommonJS-style JavaScript modules for each set of primitives, as well as an index file that loads all of the primitives for all primitive types; you can access this via `require('@primer/primitives')`. The JavaScript modules also include TypeScript typings files for use in TypeScript projects.
|
|
23
|
+
Data is served from the `dist/` folder:
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
- `dist/css` contains CSS files with values available as CSS variables
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
All available imports:
|
|
30
28
|
|
|
31
|
-
```diff
|
|
32
|
-
data/
|
|
33
|
-
colors/
|
|
34
|
-
+ deprecated.json
|
|
35
|
-
spacing/
|
|
36
|
-
...
|
|
37
29
|
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
+ colors.json
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Removing variables
|
|
63
|
-
|
|
64
|
-
When you're ready to remove a variable, first remove it's definitions:
|
|
65
|
-
|
|
66
|
-
```diff
|
|
67
|
-
// data/colors/vars/global_light.ts
|
|
68
|
-
import {get} from '../../../src/utils-v1'
|
|
69
|
-
|
|
70
|
-
export default {
|
|
71
|
-
text: {
|
|
72
|
-
- primary: get('scale.gray.9'),
|
|
73
|
-
secondary: get('scale.gray.6')
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
```diff
|
|
79
|
-
// data/colors/vars/global_dark.ts
|
|
80
|
-
import {get} from '../../../src/utils-v1'
|
|
81
|
-
|
|
82
|
-
export default {
|
|
83
|
-
text: {
|
|
84
|
-
- primary: get('scale.gray.1'),
|
|
85
|
-
secondary: get('scale.gray.3')
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Then remove it from `deprecated.json` and add it to `removed.json`:
|
|
91
|
-
|
|
92
|
-
```diff
|
|
93
|
-
// data/colors/deprecated.json
|
|
94
|
-
{
|
|
95
|
-
- "text.primary": "fg.default"
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
```diff
|
|
100
|
-
// data/colors/removed.json
|
|
101
|
-
{
|
|
102
|
-
+ "text.primary": "fg.default"
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
During the build process, the `removed.json` files will be added to a `dist/removed` directory organized by variable category:
|
|
107
|
-
|
|
108
|
-
```diff
|
|
109
|
-
dist/
|
|
110
|
-
js/
|
|
111
|
-
ts/
|
|
112
|
-
json/
|
|
113
|
-
scss/
|
|
114
|
-
deprecated/
|
|
115
|
-
+ removed/
|
|
116
|
-
+ colors.json
|
|
30
|
+
/* size/typography */
|
|
31
|
+
@import '@primer/primitives/dist/css/base/size/size.css';
|
|
32
|
+
@import '@primer/primitives/dist/css/base/typography/typography.css';
|
|
33
|
+
@import '@primer/primitives/dist/css/functional/size/border.css';
|
|
34
|
+
@import '@primer/primitives/dist/css/functional/size/breakpoints.css';
|
|
35
|
+
@import '@primer/primitives/dist/css/functional/size/size-coarse.css';
|
|
36
|
+
@import '@primer/primitives/dist/css/functional/size/size-fine.css';
|
|
37
|
+
@import '@primer/primitives/dist/css/functional/size/size.css';
|
|
38
|
+
@import '@primer/primitives/dist/css/functional/size/viewport.css';
|
|
39
|
+
@import '@primer/primitives/dist/css/functional/typography/typography.css';
|
|
40
|
+
|
|
41
|
+
/* color */
|
|
42
|
+
@import '@primer/primitives/dist/css/functional/themes/light.css';
|
|
43
|
+
@import '@primer/primitives/dist/css/functional/themes/light-tritanopia.css';
|
|
44
|
+
@import '@primer/primitives/dist/css/functional/themes/light-high-contrast.css';
|
|
45
|
+
@import '@primer/primitives/dist/css/functional/themes/light-colorblind.css';
|
|
46
|
+
@import '@primer/primitives/dist/css/functional/themes/dark.css';
|
|
47
|
+
@import '@primer/primitives/dist/css/functional/themes/dark-colorblind.css';
|
|
48
|
+
@import '@primer/primitives/dist/css/functional/themes/dark-dimmed.css';
|
|
49
|
+
@import '@primer/primitives/dist/css/functional/themes/dark-high-contrast.css';
|
|
50
|
+
@import '@primer/primitives/dist/css/functional/themes/dark-tritanopia.css';
|
|
117
51
|
```
|
|
118
52
|
|
|
119
|
-
##
|
|
53
|
+
## Design token data
|
|
120
54
|
|
|
121
|
-
|
|
55
|
+
Design token data is stored in the [src/tokens](./src/tokens/) directory. These tokens are compiled with [style dictionary](https://amzn.github.io/style-dictionary/#/) in [scripts/buildTokens.ts](./scripts/buildTokens.ts).
|
|
122
56
|
|
|
123
57
|
To make working with tokens easier, we added some additional functionality on top of what style dictionary comes with:
|
|
124
58
|
|
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@ import type {LineFormatting} from 'style-dictionary/types/FormatHelpers'
|
|
|
4
4
|
const {fileHeader, formattedVariables} = StyleDictionary.formatHelpers
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @description Converts `StyleDictionary.dictionary.tokens` to
|
|
7
|
+
* @description Converts `StyleDictionary.dictionary.tokens` to csssection
|
|
8
8
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
9
|
-
* @param arguments.options outputReferences `boolean`, selector `string
|
|
9
|
+
* @param arguments.options outputReferences `boolean`, selector `string`
|
|
10
10
|
* @returns formatted `string`
|
|
11
11
|
*/
|
|
12
12
|
export const cssVariables: StyleDictionary.Formatter = ({dictionary, options = {}, file}: FormatterArguments) => {
|