@carbon/themes 10.36.0 → 10.38.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.
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {
9
+ // Blue
10
+ blue40,
11
+ blue60,
12
+ blue70,
13
+
14
+ // Gray
15
+ gray10,
16
+ gray30,
17
+ gray40,
18
+ gray50,
19
+ gray50Hover,
20
+ gray60,
21
+ gray60Hover,
22
+ gray70,
23
+ gray70Hover,
24
+ gray80,
25
+ gray90,
26
+ gray100,
27
+
28
+ // Support
29
+ blue30,
30
+ blue50,
31
+ green40,
32
+ green50,
33
+ yellow30,
34
+ orange40,
35
+ red30,
36
+ red40,
37
+ red60,
38
+ purple40,
39
+ purple50,
40
+
41
+ // Constants
42
+ white,
43
+ } from '@carbon/colors';
44
+ import { adjustLightness } from '../tools';
45
+
46
+ // Background
47
+ export const background = gray90;
48
+ export const backgroundInverse = gray10;
49
+ export const backgroundBrand = blue60;
50
+ export const backgroundActive = gray80;
51
+ export const backgroundHover = adjustLightness(background, 5);
52
+ export const backgroundInverseHover = adjustLightness(backgroundInverse, -5);
53
+ export const backgroundSelected = gray80;
54
+ export const backgroundSelectedHover = adjustLightness(backgroundSelected, 6);
55
+
56
+ // Layer
57
+ // layer-01
58
+ export const layer01 = gray80;
59
+ export const layerActive01 = gray60;
60
+ export const layerHover01 = adjustLightness(layer01, 6);
61
+ export const layerSelected01 = gray70;
62
+ export const layerSelectedHover01 = gray70Hover;
63
+
64
+ // layer-02
65
+ export const layer02 = gray70;
66
+ export const layerActive02 = gray50;
67
+ export const layerHover02 = gray70Hover;
68
+ export const layerSelected02 = gray60;
69
+ export const layerSelectedHover02 = gray60Hover;
70
+
71
+ // layer-03
72
+ export const layer03 = gray60;
73
+ export const layerActive03 = gray80;
74
+ export const layerHover03 = gray60Hover;
75
+ export const layerSelected03 = gray50;
76
+ export const layerSelectedHover03 = gray50Hover;
77
+
78
+ // layer
79
+ export const layerDisabled = gray80;
80
+ export const layerSelectedInverse = gray10;
81
+ export const layerSelectedDisabled = gray40;
82
+
83
+ // layer-accent-01
84
+ export const layerAccent01 = gray70;
85
+ export const layerAccentActive01 = gray50;
86
+ export const layerAccentHover01 = adjustLightness(layerAccent01, 7);
87
+
88
+ // layer-accent-02
89
+ export const layerAccent02 = gray60;
90
+ export const layerAccentActive02 = gray80;
91
+ export const layerAccentHover02 = adjustLightness(layerAccent01, -7);
92
+
93
+ // layer-accent-03
94
+ export const layerAccent03 = gray50;
95
+ export const layerAccentActive03 = gray70;
96
+ export const layerAccentHover03 = gray50Hover;
97
+
98
+ // Field
99
+ // field-01
100
+ export const field01 = gray80;
101
+ export const fieldHover01 = adjustLightness(field01, 6);
102
+
103
+ // field-02
104
+ export const field02 = gray70;
105
+ export const fieldHover02 = gray70Hover;
106
+
107
+ // field-03
108
+ export const field03 = gray60;
109
+ export const fieldHover03 = gray60Hover;
110
+
111
+ // field
112
+ export const fieldDisabled = gray80;
113
+
114
+ // Border
115
+ // border-subtle-00
116
+ export const borderSubtle00 = gray70;
117
+
118
+ // border-subtle-01
119
+ export const borderSubtle01 = gray70;
120
+ export const borderSubtleSelected01 = gray60;
121
+
122
+ // border-subtle-02
123
+ export const borderSubtle02 = gray60;
124
+ export const borderSubtleSelected02 = gray50;
125
+
126
+ // border-subtle-03
127
+ export const borderSubtle03 = gray50;
128
+ export const borderSubtleSelected03 = gray40;
129
+
130
+ // border-strong
131
+ export const borderStrong01 = gray50;
132
+ export const borderStrong02 = gray40;
133
+ export const borderStrong03 = gray30;
134
+
135
+ // border-inverse
136
+ export const borderInverse = gray10;
137
+
138
+ // border-interactive
139
+ export const borderInteractive = blue50;
140
+
141
+ // border
142
+ export const borderDisabled = gray80;
143
+
144
+ // Text
145
+ export const textPrimary = gray10;
146
+ export const textSecondary = gray30;
147
+ export const textPlaceholder = gray60;
148
+ export const textHelper = gray50;
149
+ export const textError = red30;
150
+ export const textInverse = gray100;
151
+ export const textOnColor = white;
152
+ export const textOnColorDisabled = gray40;
153
+ export const textDisabled = gray60;
154
+
155
+ // Link
156
+ export const linkPrimary = blue40;
157
+ export const linkPrimaryHover = blue30;
158
+ export const linkSecondary = blue30;
159
+ export const linkInverse = blue60;
160
+ export const linkVisited = purple40;
161
+
162
+ // Icon
163
+ export const iconPrimary = gray10;
164
+ export const iconSecondary = gray30;
165
+ export const iconInverse = gray100;
166
+ export const iconOnColor = white;
167
+ export const iconOnColorDisabled = gray40;
168
+ export const iconDisabled = gray60;
169
+
170
+ // Support
171
+ export const supportError = red40;
172
+ export const supportSuccess = green40;
173
+ export const supportWarning = yellow30;
174
+ export const supportInfo = blue50;
175
+ export const supportErrorInverse = red60;
176
+ export const supportSuccessInverse = green50;
177
+ export const supportWarningInverse = yellow30;
178
+ export const supportInfoInverse = blue60;
179
+ export const supportCautionMinor = yellow30;
180
+ export const supportCautionMajor = orange40;
181
+ export const supportCautionUndefined = purple50;
182
+
183
+ // Focus
184
+ export const focus = white;
185
+ export const focusInset = gray100;
186
+ export const focusInverse = blue60;
187
+
188
+ // Skeleton
189
+ export const skeletonBackground = adjustLightness(background, 5);
190
+ export const skeletonElement = gray70;
191
+
192
+ // Misc
193
+ export const interactive = blue50;
194
+ export const highlight = blue70;
195
+ export const overlay = 'rgba(22, 22, 22, 0.7)';
196
+ export const toggleOff = gray50;
197
+
198
+ export {
199
+ // Type
200
+ caption01,
201
+ caption02,
202
+ label01,
203
+ label02,
204
+ helperText01,
205
+ helperText02,
206
+ bodyShort01,
207
+ bodyLong01,
208
+ bodyShort02,
209
+ bodyLong02,
210
+ code01,
211
+ code02,
212
+ heading01,
213
+ productiveHeading01,
214
+ heading02,
215
+ productiveHeading02,
216
+ productiveHeading03,
217
+ productiveHeading04,
218
+ productiveHeading05,
219
+ productiveHeading06,
220
+ productiveHeading07,
221
+ expressiveHeading01,
222
+ expressiveHeading02,
223
+ expressiveHeading03,
224
+ expressiveHeading04,
225
+ expressiveHeading05,
226
+ expressiveHeading06,
227
+ expressiveParagraph01,
228
+ quotation01,
229
+ quotation02,
230
+ display01,
231
+ display02,
232
+ display03,
233
+ display04,
234
+ // Layout
235
+ // Spacing
236
+ spacing01,
237
+ spacing02,
238
+ spacing03,
239
+ spacing04,
240
+ spacing05,
241
+ spacing06,
242
+ spacing07,
243
+ spacing08,
244
+ spacing09,
245
+ spacing10,
246
+ spacing11,
247
+ spacing12,
248
+ spacing13,
249
+ // Fluid spacing
250
+ fluidSpacing01,
251
+ fluidSpacing02,
252
+ fluidSpacing03,
253
+ fluidSpacing04,
254
+ // Containers
255
+ container01,
256
+ container02,
257
+ container03,
258
+ container04,
259
+ container05,
260
+ sizeXSmall,
261
+ sizeSmall,
262
+ sizeMedium,
263
+ sizeLarge,
264
+ sizeXLarge,
265
+ size2XLarge,
266
+ // Icon sizes
267
+ iconSize01,
268
+ iconSize02,
269
+ } from './white';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import * as white from './white';
9
+ import * as g10 from './g10';
10
+ import * as g90 from './g90';
11
+ import * as g100 from './g100';
12
+ import { TokenFormat, group, set } from './tokens';
13
+
14
+ export const themes = {
15
+ white,
16
+ g10,
17
+ g90,
18
+ g100,
19
+ };
20
+
21
+ export { TokenFormat, group, set };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /**
9
+ * A Token is the simplest unit in our theme. It can have a name, properties
10
+ * that it applies to like border or background, along with a state if the
11
+ * token should only be used for specific states like hover or focus.
12
+ */
13
+ export class Token {
14
+ static create(token) {
15
+ if (typeof token === 'string') {
16
+ return new Token(token);
17
+ }
18
+
19
+ return new Token(token.name, token.properties, token.state);
20
+ }
21
+
22
+ constructor(name, properties, state) {
23
+ this.kind = 'Token';
24
+ this.name = name;
25
+
26
+ if (properties) {
27
+ this.properties = properties;
28
+ }
29
+
30
+ if (state) {
31
+ this.state = state;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const formats = {
9
+ js: 'javascript',
10
+ scss: 'scss',
11
+ };
12
+
13
+ export const TokenFormat = {
14
+ formats,
15
+
16
+ convert({ name, format }) {
17
+ if (format === formats.js) {
18
+ const keywords = new Set(['ui']);
19
+
20
+ return name
21
+ .split('-')
22
+ .map((part, index) => {
23
+ if (index === 0) {
24
+ return part;
25
+ }
26
+
27
+ if (keywords.has(part)) {
28
+ return part.toUpperCase();
29
+ }
30
+
31
+ return part[0].toUpperCase() + part.slice(1);
32
+ })
33
+ .join('');
34
+ }
35
+
36
+ if (format === formats.scss) {
37
+ return formatNameToScss(name);
38
+ }
39
+
40
+ return name;
41
+ },
42
+ };
43
+
44
+ const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
45
+
46
+ /**
47
+ * Format a given token into the format expected in CSS/SCSS-based projects.
48
+ * @param {string} token
49
+ * @returns {string}
50
+ */
51
+ function formatNameToScss(token) {
52
+ let string = '';
53
+
54
+ for (let i = 0; i < token.length; i++) {
55
+ if (token[i] === '-') {
56
+ continue;
57
+ }
58
+
59
+ // If we run into a number, we hit the scale step at the end of a token name
60
+ // and can safely truncate the rest of the token
61
+ if (numbers.indexOf(token[i]) !== -1) {
62
+ string += '-' + token.slice(i);
63
+ break;
64
+ }
65
+
66
+ // When encountering an uppercase name, we will want to start adding `-`
67
+ // between words
68
+ if (token[i] === token[i].toUpperCase()) {
69
+ // Check backwards to see if previous letter was also capitalized, if so
70
+ // we are in a special case like UI where each piece should be connected
71
+ if (token[i - 1] && token[i - 1] === token[i - 1].toUpperCase()) {
72
+ string += token[i].toLowerCase();
73
+ continue;
74
+ }
75
+
76
+ if (token[i - 1] !== '-') {
77
+ // Otherwise, just concatenate this new part on to the existing string
78
+ string += '-' + token[i].toLowerCase();
79
+ }
80
+ continue;
81
+ }
82
+
83
+ // By default, we add the current character to the output string
84
+ string += token[i];
85
+ }
86
+
87
+ return string;
88
+ }
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { Token } from './Token';
9
+
10
+ /**
11
+ * A TokenGroup allows us to group up a collection of tokens and nested token
12
+ * groups. A group allows us to colocate related tokens and write information
13
+ * once that applies to the entire collection of tokens. For example, if all the
14
+ * tokens apply to the `border` color property then we can specify this property
15
+ * at the group level
16
+ *
17
+ * A TokenGroup allows us to colocate all this information while also providing
18
+ * ways to get information about the entire group, including properties and
19
+ * states
20
+ */
21
+ export class TokenGroup {
22
+ static create({ name, properties, tokens = [] }) {
23
+ return new TokenGroup(name, tokens, properties);
24
+ }
25
+
26
+ constructor(name, tokens, properties) {
27
+ this.kind = 'TokenGroup';
28
+ this.name = name;
29
+
30
+ if (properties) {
31
+ this.properties = properties;
32
+ }
33
+
34
+ this.children = tokens.map((child) => {
35
+ if (child.kind === 'TokenGroup') {
36
+ return child;
37
+ }
38
+
39
+ return Token.create(child);
40
+ });
41
+ }
42
+
43
+ *[Symbol.iterator]() {
44
+ yield this;
45
+
46
+ for (const child of this.children) {
47
+ yield child;
48
+
49
+ if (child.kind === 'TokenGroup') {
50
+ yield* child;
51
+ }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Get all the tokens available in every Token Group in this TokenGroup,
57
+ * including itself.
58
+ * @returns {Array<Token>}
59
+ */
60
+ getTokens(parentContext = {}) {
61
+ const context = {
62
+ ...parentContext,
63
+ groups: parentContext.groups ? parentContext.groups.concat(this) : [this],
64
+ properties: this.properties || parentContext.properties,
65
+ };
66
+
67
+ return this.children.flatMap((child) => {
68
+ if (child.kind === 'TokenGroup') {
69
+ return child.getTokens(context);
70
+ }
71
+
72
+ const token = {
73
+ ...context,
74
+ name: child.name,
75
+ properties: child.properties || context.properties,
76
+ };
77
+
78
+ if (child.state) {
79
+ token.state = child.state;
80
+ }
81
+
82
+ return token;
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Get a specific token from the TokenGroup, or form one of its nested
88
+ * TokenGroups
89
+ * @returns {Token}
90
+ */
91
+ getToken(tokenOrName) {
92
+ const name =
93
+ typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
94
+ for (const child of this) {
95
+ if (child.kind === 'TokenGroup') {
96
+ continue;
97
+ }
98
+
99
+ if (child.name === name) {
100
+ return child;
101
+ }
102
+ }
103
+ return null;
104
+ }
105
+
106
+ /**
107
+ * Get all the unique groups in the token group, including this group
108
+ * @returns {Array<TokenGroup>}
109
+ */
110
+ getTokenGroups() {
111
+ const set = new Set();
112
+
113
+ for (const child of this) {
114
+ if (child.kind !== 'TokenGroup') {
115
+ continue;
116
+ }
117
+ set.add(child);
118
+ }
119
+
120
+ return Array.from(set);
121
+ }
122
+
123
+ /**
124
+ * Get all the unique properties in the token group, including this group
125
+ * @returns {Array<string>}
126
+ */
127
+ getTokenProperties() {
128
+ const set = new Set();
129
+
130
+ for (const child of this) {
131
+ if (!Array.isArray(child.properties)) {
132
+ continue;
133
+ }
134
+
135
+ for (const property of child.properties) {
136
+ set.add(property);
137
+ }
138
+ }
139
+
140
+ return Array.from(set);
141
+ }
142
+
143
+ /**
144
+ * Get all the unique states in the token group, including this group
145
+ * @returns {Array<string>}
146
+ */
147
+ getTokenStates() {
148
+ const set = new Set();
149
+
150
+ for (const child of this) {
151
+ if (child.kind !== 'Token') {
152
+ continue;
153
+ }
154
+ if (child.state) {
155
+ set.add(child.state);
156
+ }
157
+ }
158
+
159
+ return Array.from(set);
160
+ }
161
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /**
9
+ * A token set is a collection of tokens which should be along with each other.
10
+ * For example, we have tokens that correspond to a layer level in a UI. A
11
+ * token set allows us to group these tokens together in a way that's different
12
+ * than their token group.
13
+ */
14
+ export class TokenSet {
15
+ static create({ name, tokens }) {
16
+ return new TokenSet(name, tokens);
17
+ }
18
+
19
+ constructor(name, tokens = []) {
20
+ this.kind = 'TokenSet';
21
+ this.name = name;
22
+ this.children = tokens;
23
+ }
24
+
25
+ *[Symbol.iterator]() {
26
+ for (const child of this.children) {
27
+ yield child;
28
+
29
+ if (child.kind === 'TokenSet') {
30
+ yield* child;
31
+ }
32
+ }
33
+ }
34
+
35
+ getTokenSets() {
36
+ const children = this.children
37
+ .filter((child) => {
38
+ return child.kind === 'TokenSet';
39
+ })
40
+ .flatMap((child) => {
41
+ return child.getTokenSets();
42
+ });
43
+
44
+ return [this, ...children];
45
+ }
46
+
47
+ getTokenSet(name) {
48
+ for (const child of this) {
49
+ if (!child.kind === 'TokenSet') {
50
+ continue;
51
+ }
52
+
53
+ if (child.name === name) {
54
+ return child;
55
+ }
56
+ }
57
+
58
+ return null;
59
+ }
60
+
61
+ hasToken(tokenOrName) {
62
+ const name =
63
+ typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
64
+
65
+ for (const child of this) {
66
+ if (child.kind === 'TokenSet') {
67
+ continue;
68
+ }
69
+
70
+ if (child.name === name) {
71
+ return true;
72
+ }
73
+ }
74
+
75
+ return false;
76
+ }
77
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright IBM Corp. 2018, 2018
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { Token } from './Token';
9
+ import { TokenFormat } from './TokenFormat';
10
+ import { TokenGroup } from './TokenGroup';
11
+ import { TokenSet } from './TokenSet';
12
+ import { group } from './v11TokenGroup';
13
+ import { set } from './v11TokenSet';
14
+
15
+ export { Token, TokenFormat, TokenGroup, TokenSet, group, set };