@atb-as/theme 11.1.1 → 12.0.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 +81 -79
- package/lib/generated/themes/atb-theme/dark.d.ts +697 -374
- package/lib/generated/themes/atb-theme/dark.js +692 -369
- package/lib/generated/themes/atb-theme/dark.js.map +1 -1
- package/lib/generated/themes/atb-theme/light.d.ts +697 -374
- package/lib/generated/themes/atb-theme/light.js +692 -369
- package/lib/generated/themes/atb-theme/light.js.map +1 -1
- package/lib/generated/themes/atb-theme/theme.css +10 -790
- package/lib/generated/themes/atb-theme/theme.d.ts +1394 -748
- package/lib/generated/themes/farte-theme/dark.d.ts +697 -374
- package/lib/generated/themes/farte-theme/dark.js +692 -369
- package/lib/generated/themes/farte-theme/dark.js.map +1 -1
- package/lib/generated/themes/farte-theme/light.d.ts +697 -374
- package/lib/generated/themes/farte-theme/light.js +692 -369
- package/lib/generated/themes/farte-theme/light.js.map +1 -1
- package/lib/generated/themes/farte-theme/theme.css +10 -790
- package/lib/generated/themes/farte-theme/theme.d.ts +1394 -748
- package/lib/generated/themes/fram-theme/dark.d.ts +697 -374
- package/lib/generated/themes/fram-theme/dark.js +691 -368
- package/lib/generated/themes/fram-theme/dark.js.map +1 -1
- package/lib/generated/themes/fram-theme/light.d.ts +697 -374
- package/lib/generated/themes/fram-theme/light.js +692 -369
- package/lib/generated/themes/fram-theme/light.js.map +1 -1
- package/lib/generated/themes/fram-theme/theme.css +10 -790
- package/lib/generated/themes/fram-theme/theme.d.ts +1394 -748
- package/lib/generated/themes/innlandet-theme/dark.d.ts +697 -374
- package/lib/generated/themes/innlandet-theme/dark.js +692 -369
- package/lib/generated/themes/innlandet-theme/dark.js.map +1 -1
- package/lib/generated/themes/innlandet-theme/light.d.ts +697 -374
- package/lib/generated/themes/innlandet-theme/light.js +692 -369
- package/lib/generated/themes/innlandet-theme/light.js.map +1 -1
- package/lib/generated/themes/innlandet-theme/theme.css +10 -790
- package/lib/generated/themes/innlandet-theme/theme.d.ts +1394 -748
- package/lib/generated/themes/nfk-theme/dark.d.ts +697 -374
- package/lib/generated/themes/nfk-theme/dark.js +693 -370
- package/lib/generated/themes/nfk-theme/dark.js.map +1 -1
- package/lib/generated/themes/nfk-theme/light.d.ts +697 -374
- package/lib/generated/themes/nfk-theme/light.js +693 -370
- package/lib/generated/themes/nfk-theme/light.js.map +1 -1
- package/lib/generated/themes/nfk-theme/theme.css +10 -790
- package/lib/generated/themes/nfk-theme/theme.d.ts +1394 -748
- package/lib/generated/themes/troms-theme/dark.d.ts +697 -374
- package/lib/generated/themes/troms-theme/dark.js +694 -371
- package/lib/generated/themes/troms-theme/dark.js.map +1 -1
- package/lib/generated/themes/troms-theme/light.d.ts +697 -374
- package/lib/generated/themes/troms-theme/light.js +694 -371
- package/lib/generated/themes/troms-theme/light.js.map +1 -1
- package/lib/generated/themes/troms-theme/theme.css +10 -790
- package/lib/generated/themes/troms-theme/theme.d.ts +1394 -748
- package/lib/generated/{themes-fs → themes}/vkt-theme/dark.css +113 -113
- package/lib/generated/themes/vkt-theme/dark.d.ts +697 -374
- package/lib/generated/themes/vkt-theme/dark.js +694 -371
- package/lib/generated/themes/vkt-theme/dark.js.map +1 -1
- package/lib/generated/{themes-fs → themes}/vkt-theme/light.css +103 -103
- package/lib/generated/themes/vkt-theme/light.d.ts +697 -374
- package/lib/generated/themes/vkt-theme/light.js +694 -371
- package/lib/generated/themes/vkt-theme/light.js.map +1 -1
- package/lib/generated/themes/vkt-theme/theme.css +10 -790
- package/lib/generated/themes/vkt-theme/theme.d.ts +1394 -748
- package/lib/theme.d.ts +56 -134
- package/lib/theme.js +8 -46
- package/lib/theme.js.map +1 -1
- package/package.json +4 -4
- package/lib/generated/themes/atb-theme/theme.module.css +0 -790
- package/lib/generated/themes/farte-theme/theme.module.css +0 -790
- package/lib/generated/themes/fram-theme/theme.module.css +0 -790
- package/lib/generated/themes/innlandet-theme/theme.module.css +0 -790
- package/lib/generated/themes/nfk-theme/theme.module.css +0 -790
- package/lib/generated/themes/troms-theme/theme.module.css +0 -790
- package/lib/generated/themes/vkt-theme/theme.module.css +0 -790
- package/lib/generated/themes-fs/atb-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/atb-theme/dark.js +0 -764
- package/lib/generated/themes-fs/atb-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/atb-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/atb-theme/light.js +0 -764
- package/lib/generated/themes-fs/atb-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/atb-theme/theme.css +0 -10
- package/lib/generated/themes-fs/atb-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/atb-theme/theme.js +0 -16
- package/lib/generated/themes-fs/atb-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/farte-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/farte-theme/dark.js +0 -764
- package/lib/generated/themes-fs/farte-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/farte-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/farte-theme/light.js +0 -764
- package/lib/generated/themes-fs/farte-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/farte-theme/theme.css +0 -10
- package/lib/generated/themes-fs/farte-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/farte-theme/theme.js +0 -16
- package/lib/generated/themes-fs/farte-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/fram-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/fram-theme/dark.js +0 -764
- package/lib/generated/themes-fs/fram-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/fram-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/fram-theme/light.js +0 -764
- package/lib/generated/themes-fs/fram-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/fram-theme/theme.css +0 -10
- package/lib/generated/themes-fs/fram-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/fram-theme/theme.js +0 -16
- package/lib/generated/themes-fs/fram-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/index.d.ts +0 -10
- package/lib/generated/themes-fs/index.js +0 -24
- package/lib/generated/themes-fs/index.js.map +0 -1
- package/lib/generated/themes-fs/innlandet-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/innlandet-theme/dark.js +0 -764
- package/lib/generated/themes-fs/innlandet-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/innlandet-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/innlandet-theme/light.js +0 -764
- package/lib/generated/themes-fs/innlandet-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/innlandet-theme/theme.css +0 -10
- package/lib/generated/themes-fs/innlandet-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/innlandet-theme/theme.js +0 -16
- package/lib/generated/themes-fs/innlandet-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/nfk-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/nfk-theme/dark.js +0 -764
- package/lib/generated/themes-fs/nfk-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/nfk-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/nfk-theme/light.js +0 -764
- package/lib/generated/themes-fs/nfk-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/nfk-theme/theme.css +0 -10
- package/lib/generated/themes-fs/nfk-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/nfk-theme/theme.js +0 -16
- package/lib/generated/themes-fs/nfk-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/troms-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/troms-theme/dark.js +0 -764
- package/lib/generated/themes-fs/troms-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/troms-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/troms-theme/light.js +0 -764
- package/lib/generated/themes-fs/troms-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/troms-theme/theme.css +0 -10
- package/lib/generated/themes-fs/troms-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/troms-theme/theme.js +0 -16
- package/lib/generated/themes-fs/troms-theme/theme.js.map +0 -1
- package/lib/generated/themes-fs/vkt-theme/dark.d.ts +0 -762
- package/lib/generated/themes-fs/vkt-theme/dark.js +0 -764
- package/lib/generated/themes-fs/vkt-theme/dark.js.map +0 -1
- package/lib/generated/themes-fs/vkt-theme/light.d.ts +0 -762
- package/lib/generated/themes-fs/vkt-theme/light.js +0 -764
- package/lib/generated/themes-fs/vkt-theme/light.js.map +0 -1
- package/lib/generated/themes-fs/vkt-theme/theme.css +0 -10
- package/lib/generated/themes-fs/vkt-theme/theme.d.ts +0 -1522
- package/lib/generated/themes-fs/vkt-theme/theme.js +0 -16
- package/lib/generated/themes-fs/vkt-theme/theme.js.map +0 -1
- /package/lib/generated/{themes-fs → themes}/atb-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/atb-theme/light.css +0 -0
- /package/lib/generated/{themes-fs → themes}/farte-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/farte-theme/light.css +0 -0
- /package/lib/generated/{themes-fs → themes}/fram-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/fram-theme/light.css +0 -0
- /package/lib/generated/{themes-fs → themes}/innlandet-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/innlandet-theme/light.css +0 -0
- /package/lib/generated/{themes-fs → themes}/nfk-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/nfk-theme/light.css +0 -0
- /package/lib/generated/{themes-fs → themes}/troms-theme/dark.css +0 -0
- /package/lib/generated/{themes-fs → themes}/troms-theme/light.css +0 -0
package/README.md
CHANGED
|
@@ -6,117 +6,100 @@
|
|
|
6
6
|
yarn add @atb-as/theme
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## Recommended usage
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
### `TS`/`JS` import
|
|
11
12
|
|
|
12
13
|
Import through `ts`/`js`:
|
|
13
14
|
|
|
14
|
-
|
|
15
15
|
```ts
|
|
16
|
-
import {createThemesFor,ThemeVariant} from '@atb-as/theme';
|
|
17
|
-
const
|
|
18
|
-
console.log(
|
|
16
|
+
import {createThemesFor, ThemeVariant} from '@atb-as/theme';
|
|
17
|
+
const { light, dark } = createThemesFor(ThemeVariant.AtB)
|
|
18
|
+
console.log(light.color.background.neutral[0].background);
|
|
19
|
+
// #000000
|
|
19
20
|
```
|
|
20
21
|
|
|
22
|
+
### CSS import
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
Colors can be imported as CSS files. Typography styles can be imported as CSS Modules.
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
> Importing CSS from `../theme-fs/..` applies variables to `data-theme["auto"]`.
|
|
26
|
-
> The theme follows the device preference.
|
|
27
|
-
>
|
|
28
|
-
> This behaviour can be overwritten by explicitly setting `data-theme["light"]` or `data-theme["dark"]`
|
|
29
|
-
> on an element. All children will follow that specific theme.
|
|
26
|
+
To retrieve CSS files depending on your organization, we recommend setting up aliasing in your bundler. An example is provided for Webpack. This process is similar for other bundlers
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
```ts
|
|
29
|
+
const orgID = process.env.ORG_ID
|
|
30
|
+
|
|
31
|
+
webpack(config) {
|
|
32
|
+
config.resolve.alias = {
|
|
33
|
+
...config.resolve.alias,
|
|
34
|
+
'@atb/theme/theme.css': `@atb-as/theme/lib/generated/themes/${orgId}-theme/theme.css`,
|
|
35
|
+
'@atb/theme/typography.css': '@atb-as/theme/lib/generated/typography.css',
|
|
36
|
+
'@atb/theme/typography.module.css':
|
|
37
|
+
'@atb-as/theme/lib/generated/typography.module.css',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
```
|
|
32
41
|
|
|
42
|
+
Then import CSS files using the alias above.
|
|
33
43
|
|
|
34
44
|
```ts
|
|
35
45
|
// When using imports from bundlers
|
|
36
46
|
|
|
37
47
|
// With CSS Modules for atb-theme
|
|
38
|
-
import * as
|
|
39
|
-
import * as classNamesTypo from '@atb-as/theme/lib/typography.module.css';
|
|
40
|
-
|
|
48
|
+
import * as classNamesTypo from '@atb/theme/typography.module.css';
|
|
41
49
|
|
|
42
50
|
// Without CSS Modules for atb-theme
|
|
43
|
-
import '@atb
|
|
44
|
-
import '@atb
|
|
51
|
+
import '@atb/theme/theme.css';
|
|
52
|
+
import '@atb/theme/typography.css';
|
|
45
53
|
```
|
|
46
54
|
|
|
47
55
|
```css
|
|
48
56
|
/* Using css/postcss/bundlers */
|
|
49
|
-
@import '@atb
|
|
50
|
-
@import '@atb-as/theme/lib/typography.module.css';
|
|
57
|
+
@import '@atb/theme/typography.module.css';
|
|
51
58
|
|
|
52
59
|
/* or without modules */
|
|
53
|
-
@import '@atb
|
|
54
|
-
@import '@atb
|
|
55
|
-
|
|
60
|
+
@import '@atb/theme/themes/theme.css';
|
|
61
|
+
@import '@atb/theme/typography.css';
|
|
56
62
|
|
|
57
|
-
/*
|
|
63
|
+
/* You can also import from an organization directly */
|
|
58
64
|
@value myClassname from "@atb-as/theme/lib/themes/atb-theme/theme.css";
|
|
59
65
|
```
|
|
60
66
|
|
|
61
67
|
_(note: This all depends on how you setup bundlers and consumes styles.)_
|
|
62
68
|
|
|
69
|
+
#### Using tokens
|
|
70
|
+
|
|
71
|
+
For CSS, we recommend [our token plugin](https://github.com/AtB-AS/design-system/tree/main/packages/token), which provides typesafety and an easy interfacing for accessing CSS variables (design tokens).
|
|
63
72
|
|
|
64
73
|
#### Theming with CSS
|
|
65
74
|
|
|
66
75
|
Uses CSS Custom Properties to do theming. This means by default it only support newer browsers. This needs to be compansated for by the consumer if wanted.
|
|
67
|
-
By setting
|
|
76
|
+
By setting the attribute `data-theme` to `light`, `dark` or `auto` on a parent component the cascading of custom props will change the theme. This means we can set what level we want the theming to operate on.
|
|
68
77
|
|
|
69
78
|
```html
|
|
70
|
-
<body
|
|
79
|
+
<body data-theme="light">
|
|
71
80
|
<!-- My content -->
|
|
72
81
|
</body>
|
|
73
82
|
|
|
74
|
-
<body
|
|
83
|
+
<body data-theme="dark">
|
|
75
84
|
<!-- My content -->
|
|
76
85
|
</body>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**You must set either `light` or `dark` for themes to work.**
|
|
80
|
-
|
|
81
|
-
#### Regular CSS
|
|
82
|
-
|
|
83
|
-
With regular CSS.
|
|
84
|
-
|
|
85
|
-
```html
|
|
86
|
-
<!-- Named same as theme objects -->
|
|
87
|
-
|
|
88
|
-
<div class="colors-primary_2">
|
|
89
|
-
<!-- background color and text color set -->
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
<div class="colors-transport_city" />
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
#### CSS Modules
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
87
|
+
<body data-theme="auto">
|
|
88
|
+
<!-- My content -->
|
|
89
|
+
</body>
|
|
101
90
|
```
|
|
102
91
|
|
|
103
|
-
|
|
104
|
-
@import 'theme.modules.css';
|
|
92
|
+
`data-theme="auto"` follows the device preferences.
|
|
105
93
|
|
|
106
|
-
|
|
107
|
-
composes: colors-transport_train;
|
|
108
|
-
}
|
|
109
|
-
```
|
|
94
|
+
## Theme API
|
|
110
95
|
|
|
111
|
-
### Theme
|
|
96
|
+
### `createThemes(themes: Themes, overrides?: ConfigurationOverride<Theme>): Themes`
|
|
112
97
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Create new themes (light/dark) with optinally overriden defaults
|
|
98
|
+
Create new themes (light/dark) with optionally overriden defaults
|
|
116
99
|
|
|
117
100
|
```ts
|
|
118
101
|
const themesVariant = createThemesFor(ThemeVariant.AtB)
|
|
119
|
-
const
|
|
102
|
+
const { light, dark } = createThemes(
|
|
120
103
|
themesVariant,
|
|
121
104
|
{
|
|
122
105
|
light: {
|
|
@@ -125,12 +108,11 @@ const themes = createThemes(
|
|
|
125
108
|
},
|
|
126
109
|
},
|
|
127
110
|
});
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
console.log(light.spacing.medium);
|
|
112
|
+
// 20
|
|
130
113
|
```
|
|
131
114
|
|
|
132
|
-
|
|
133
|
-
#### `createExtendedThemes<T>(themes: Themes,extension: T)`
|
|
115
|
+
### `createExtendedThemes<T>(themes: Themes, extension: T)`
|
|
134
116
|
|
|
135
117
|
Use Theme as base and extend with new properties. Properties can be nested and will be deep merged.
|
|
136
118
|
|
|
@@ -140,19 +122,19 @@ type FooExtension = {
|
|
|
140
122
|
}
|
|
141
123
|
const themesVariant = createThemesFor(ThemeVariant.AtB)
|
|
142
124
|
|
|
143
|
-
const
|
|
125
|
+
const { light, dark } = createExtendedThemes<FooExtension>(
|
|
144
126
|
themesVariant,
|
|
145
127
|
{
|
|
146
128
|
light: {statusBarStyle: 'dark'},
|
|
147
129
|
dark: {statusBarStyle: 'light'}
|
|
148
130
|
});
|
|
149
|
-
|
|
150
|
-
|
|
131
|
+
console.log(light.statusBarStyle);
|
|
132
|
+
// dark
|
|
151
133
|
```
|
|
152
134
|
|
|
153
|
-
|
|
135
|
+
## Typography API
|
|
154
136
|
|
|
155
|
-
|
|
137
|
+
### `createTextTypeStyles(PlatformTypes, ConfigurationOverride<TextTypeStyles>)`
|
|
156
138
|
|
|
157
139
|
Create new text type style with optinally overriden defaults.
|
|
158
140
|
|
|
@@ -167,7 +149,7 @@ createTextTypeStyles({
|
|
|
167
149
|
})
|
|
168
150
|
```
|
|
169
151
|
|
|
170
|
-
|
|
152
|
+
### `extendTextTypeStyles<T>(type: PlatformTypes, extension: T)`
|
|
171
153
|
|
|
172
154
|
Use text type style as base and extend with new properties. Properties can be nested and will be deep merged.
|
|
173
155
|
|
|
@@ -184,22 +166,42 @@ const foo = extendTextTypeStyles<Foo>({
|
|
|
184
166
|
});
|
|
185
167
|
|
|
186
168
|
console.log(foo.paragraphHeadline.additional);
|
|
187
|
-
|
|
169
|
+
// true
|
|
188
170
|
```
|
|
189
171
|
|
|
172
|
+
## Updating the design system
|
|
190
173
|
|
|
174
|
+
Figma is the source of truth of variables. **Changes should therefore be made in Figma only** and imported into code afterwards through a GitHub Action.
|
|
191
175
|
|
|
176
|
+
1. Make changes to Figma Variables in Figma
|
|
177
|
+
2. Go to [GitHub Actions](https://github.com/AtB-AS/design-system/actions/workflows/design-tokens.yml), click **Run workflow**
|
|
178
|
+
```
|
|
179
|
+
`Use workflow from`: `main`
|
|
180
|
+
`Which org did you make changes for?`: `orgId` // or `all`
|
|
181
|
+
```
|
|
182
|
+
3. A PR is created with the changes you made in step 1 and selected in step 2. If the expected changes are included, approve and merge the PR
|
|
192
183
|
|
|
193
|
-
|
|
184
|
+
## Building locally
|
|
194
185
|
|
|
195
|
-
|
|
186
|
+
> If you want to make changes to variables, we recommend making changes in Figma and import them into code using the steps above.
|
|
196
187
|
|
|
188
|
+
If you want to fetch new variables from Figma, you need to set environment variables.
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
$ Replace [id_of_figma_file] with the actual ID of the file
|
|
192
|
+
export FIGMA_VARIABLES_URL=https://api.figma.com/v1/files/[id_of_figma_file]/variables/local
|
|
193
|
+
|
|
194
|
+
$ Create access token with Figma Variables read access
|
|
195
|
+
$ https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens
|
|
196
|
+
export FIGMA_REST_API_KEY=personal_access_token
|
|
197
197
|
```
|
|
198
|
-
yarn workspace @atb-as/theme create-css
|
|
199
|
-
```
|
|
200
198
|
|
|
201
|
-
|
|
199
|
+
```sh
|
|
200
|
+
yarn
|
|
201
|
+
|
|
202
|
+
$ Only if you want to fetch new variables
|
|
203
|
+
$ Not need when just building the design system from source
|
|
204
|
+
yarn workspace @atb-as/theme fetch-variables
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
yarn create-css
|
|
206
|
+
yarn workspace @atb-as/theme build
|
|
205
207
|
```
|