@carbon/themes 11.74.0 → 11.75.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/es/index.js +68 -101
- package/lib/component-tokens/button/index.d.ts +7 -0
- package/lib/component-tokens/button/tokens.d.ts +98 -0
- package/{src/component-tokens/content-switcher/index.js → lib/component-tokens/content-switcher/index.d.ts} +1 -1
- package/lib/component-tokens/content-switcher/tokens.d.ts +24 -0
- package/lib/component-tokens/notification/index.d.ts +7 -0
- package/lib/component-tokens/notification/tokens.d.ts +64 -0
- package/lib/component-tokens/status/index.d.ts +7 -0
- package/lib/component-tokens/status/tokens.d.ts +62 -0
- package/lib/component-tokens/tag/index.d.ts +7 -0
- package/lib/component-tokens/tag/tokens.d.ts +246 -0
- package/lib/g10.d.ts +242 -0
- package/lib/g100.d.ts +242 -0
- package/lib/g90.d.ts +242 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +68 -101
- package/lib/tokens/Token.d.ts +20 -0
- package/lib/tokens/TokenFormat.d.ts +15 -0
- package/lib/tokens/TokenGroup.d.ts +57 -0
- package/lib/tokens/TokenSet.d.ts +30 -0
- package/lib/tokens/components.d.ts +12 -0
- package/lib/tokens/index.d.ts +21 -0
- package/lib/tokens/layout.d.ts +8 -0
- package/lib/tokens/type.d.ts +8 -0
- package/lib/tokens/types.d.ts +23 -0
- package/lib/tokens/v10.d.ts +10 -0
- package/lib/tokens/v11TokenGroup.d.ts +21 -0
- package/lib/tokens/v11TokenSet.d.ts +8 -0
- package/lib/tools.d.ts +17 -0
- package/lib/v10/g10.d.ts +154 -0
- package/lib/v10/g100.d.ts +154 -0
- package/lib/v10/g90.d.ts +154 -0
- package/lib/v10/index.d.ts +19 -0
- package/lib/v10/tokens.d.ts +18 -0
- package/lib/v10/white.d.ts +155 -0
- package/lib/white.d.ts +243 -0
- package/package.json +10 -5
- package/src/component-tokens/button/{index.js → index.ts} +1 -1
- package/src/component-tokens/button/{tokens.js → tokens.ts} +1 -1
- package/src/component-tokens/content-switcher/index.ts +7 -0
- package/src/component-tokens/content-switcher/{tokens.js → tokens.ts} +1 -1
- package/src/component-tokens/notification/{index.js → index.ts} +1 -1
- package/src/component-tokens/notification/{tokens.js → tokens.ts} +1 -1
- package/src/component-tokens/status/{index.js → index.ts} +1 -1
- package/src/component-tokens/status/{tokens.js → tokens.ts} +1 -1
- package/src/component-tokens/tag/{index.js → index.ts} +1 -1
- package/src/component-tokens/tag/{tokens.js → tokens.ts} +1 -1
- package/src/{g10.js → g10.ts} +1 -1
- package/src/{g100.js → g100.ts} +1 -1
- package/src/{g90.js → g90.ts} +1 -1
- package/src/{index.js → index.ts} +1 -1
- package/src/tokens/{Token.js → Token.ts} +10 -4
- package/src/tokens/{TokenFormat.js → TokenFormat.ts} +12 -7
- package/src/tokens/{TokenGroup.js → TokenGroup.ts} +38 -16
- package/src/tokens/{TokenSet.js → TokenSet.ts} +22 -8
- package/src/tokens/{components.js → components.ts} +1 -1
- package/src/tokens/{index.js → index.ts} +13 -22
- package/src/tokens/{layout.js → layout.ts} +1 -1
- package/src/tokens/{type.js → type.ts} +1 -1
- package/src/tokens/types.ts +28 -0
- package/src/tokens/{v10.js → v10.ts} +1 -1
- package/src/tokens/{v11TokenGroup.js → v11TokenGroup.ts} +1 -1
- package/src/tokens/v11TokenSet.ts +93 -0
- package/src/{tools.js → tools.ts} +7 -15
- package/src/v10/{g10.js → g10.ts} +1 -1
- package/src/v10/{g100.js → g100.ts} +1 -1
- package/src/v10/{g90.js → g90.ts} +1 -1
- package/src/v10/{index.js → index.ts} +1 -1
- package/src/v10/{tokens.js → tokens.ts} +1 -1
- package/src/v10/{white.js → white.ts} +1 -1
- package/src/{white.js → white.ts} +1 -1
- package/tsconfig.json +8 -0
- package/tsconfig.types.json +9 -0
- package/umd/index.js +68 -101
- package/src/tokens/v11TokenSet.js +0 -94
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2018,
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Token } from './Token';
|
|
9
|
+
import type {
|
|
10
|
+
ResolvedToken,
|
|
11
|
+
TokenContext,
|
|
12
|
+
TokenDefinition,
|
|
13
|
+
TokenProperties,
|
|
14
|
+
} from './types';
|
|
15
|
+
|
|
16
|
+
type TokenGroupChild = Token | TokenGroup;
|
|
17
|
+
|
|
18
|
+
type TokenGroupDefinition = {
|
|
19
|
+
name: string;
|
|
20
|
+
properties?: TokenProperties;
|
|
21
|
+
tokens?: Array<Token | TokenDefinition | TokenGroup | string>;
|
|
22
|
+
};
|
|
9
23
|
|
|
10
24
|
/**
|
|
11
25
|
* A TokenGroup allows us to group up a collection of tokens and nested token
|
|
@@ -19,11 +33,20 @@ import { Token } from './Token';
|
|
|
19
33
|
* states
|
|
20
34
|
*/
|
|
21
35
|
export class TokenGroup {
|
|
22
|
-
|
|
36
|
+
kind: 'TokenGroup';
|
|
37
|
+
name: string;
|
|
38
|
+
properties?: TokenProperties;
|
|
39
|
+
children: TokenGroupChild[];
|
|
40
|
+
|
|
41
|
+
static create({ name, properties, tokens = [] }: TokenGroupDefinition) {
|
|
23
42
|
return new TokenGroup(name, tokens, properties);
|
|
24
43
|
}
|
|
25
44
|
|
|
26
|
-
constructor(
|
|
45
|
+
constructor(
|
|
46
|
+
name: string,
|
|
47
|
+
tokens: Array<Token | TokenDefinition | TokenGroup | string>,
|
|
48
|
+
properties?: TokenProperties
|
|
49
|
+
) {
|
|
27
50
|
this.kind = 'TokenGroup';
|
|
28
51
|
this.name = name;
|
|
29
52
|
|
|
@@ -32,7 +55,11 @@ export class TokenGroup {
|
|
|
32
55
|
}
|
|
33
56
|
|
|
34
57
|
this.children = tokens.map((child) => {
|
|
35
|
-
if (
|
|
58
|
+
if (
|
|
59
|
+
typeof child !== 'string' &&
|
|
60
|
+
'kind' in child &&
|
|
61
|
+
child.kind === 'TokenGroup'
|
|
62
|
+
) {
|
|
36
63
|
return child;
|
|
37
64
|
}
|
|
38
65
|
|
|
@@ -40,7 +67,7 @@ export class TokenGroup {
|
|
|
40
67
|
});
|
|
41
68
|
}
|
|
42
69
|
|
|
43
|
-
*[Symbol.iterator]() {
|
|
70
|
+
*[Symbol.iterator](): Generator<TokenGroupChild, void, unknown> {
|
|
44
71
|
yield this;
|
|
45
72
|
|
|
46
73
|
for (const child of this.children) {
|
|
@@ -55,9 +82,8 @@ export class TokenGroup {
|
|
|
55
82
|
/**
|
|
56
83
|
* Get all the tokens available in every Token Group in this TokenGroup,
|
|
57
84
|
* including itself.
|
|
58
|
-
* @returns {Array<Token>}
|
|
59
85
|
*/
|
|
60
|
-
getTokens(parentContext = {}) {
|
|
86
|
+
getTokens(parentContext: TokenContext = {}): ResolvedToken[] {
|
|
61
87
|
const context = {
|
|
62
88
|
...parentContext,
|
|
63
89
|
groups: parentContext.groups
|
|
@@ -71,7 +97,7 @@ export class TokenGroup {
|
|
|
71
97
|
return child.getTokens(context);
|
|
72
98
|
}
|
|
73
99
|
|
|
74
|
-
const token = {
|
|
100
|
+
const token: ResolvedToken = {
|
|
75
101
|
...context,
|
|
76
102
|
name: child.name,
|
|
77
103
|
properties: child.properties || context.properties,
|
|
@@ -88,9 +114,8 @@ export class TokenGroup {
|
|
|
88
114
|
/**
|
|
89
115
|
* Get a specific token from the TokenGroup, or form one of its nested
|
|
90
116
|
* TokenGroups
|
|
91
|
-
* @returns {Token}
|
|
92
117
|
*/
|
|
93
|
-
getToken(tokenOrName) {
|
|
118
|
+
getToken(tokenOrName: Token | string): Token | null {
|
|
94
119
|
const name =
|
|
95
120
|
typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
|
|
96
121
|
for (const child of this) {
|
|
@@ -107,10 +132,9 @@ export class TokenGroup {
|
|
|
107
132
|
|
|
108
133
|
/**
|
|
109
134
|
* Get all the unique groups in the token group, including this group
|
|
110
|
-
* @returns {Array<TokenGroup>}
|
|
111
135
|
*/
|
|
112
136
|
getTokenGroups() {
|
|
113
|
-
const set = new Set();
|
|
137
|
+
const set = new Set<TokenGroup>();
|
|
114
138
|
|
|
115
139
|
for (const child of this) {
|
|
116
140
|
if (child.kind !== 'TokenGroup') {
|
|
@@ -124,10 +148,9 @@ export class TokenGroup {
|
|
|
124
148
|
|
|
125
149
|
/**
|
|
126
150
|
* Get all the unique properties in the token group, including this group
|
|
127
|
-
* @returns {Array<string>}
|
|
128
151
|
*/
|
|
129
152
|
getTokenProperties() {
|
|
130
|
-
const set = new Set();
|
|
153
|
+
const set = new Set<string>();
|
|
131
154
|
|
|
132
155
|
for (const child of this) {
|
|
133
156
|
if (!Array.isArray(child.properties)) {
|
|
@@ -144,10 +167,9 @@ export class TokenGroup {
|
|
|
144
167
|
|
|
145
168
|
/**
|
|
146
169
|
* Get all the unique states in the token group, including this group
|
|
147
|
-
* @returns {Array<string>}
|
|
148
170
|
*/
|
|
149
171
|
getTokenStates() {
|
|
150
|
-
const set = new Set();
|
|
172
|
+
const set = new Set<string>();
|
|
151
173
|
|
|
152
174
|
for (const child of this) {
|
|
153
175
|
if (child.kind !== 'Token') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2018,
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,18 +11,31 @@
|
|
|
11
11
|
* token set allows us to group these tokens together in a way that's different
|
|
12
12
|
* than their token group.
|
|
13
13
|
*/
|
|
14
|
+
import { Token } from './Token';
|
|
15
|
+
|
|
16
|
+
type TokenSetChild = Token | TokenSet;
|
|
17
|
+
|
|
18
|
+
type TokenSetDefinition = {
|
|
19
|
+
name: string;
|
|
20
|
+
tokens?: TokenSetChild[];
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
export class TokenSet {
|
|
15
|
-
|
|
24
|
+
kind: 'TokenSet';
|
|
25
|
+
name: string;
|
|
26
|
+
children: TokenSetChild[];
|
|
27
|
+
|
|
28
|
+
static create({ name, tokens = [] }: TokenSetDefinition) {
|
|
16
29
|
return new TokenSet(name, tokens);
|
|
17
30
|
}
|
|
18
31
|
|
|
19
|
-
constructor(name, tokens
|
|
32
|
+
constructor(name: string, tokens: TokenSetChild[]) {
|
|
20
33
|
this.kind = 'TokenSet';
|
|
21
34
|
this.name = name;
|
|
22
35
|
this.children = tokens;
|
|
23
36
|
}
|
|
24
37
|
|
|
25
|
-
*[Symbol.iterator]() {
|
|
38
|
+
*[Symbol.iterator](): Generator<TokenSetChild, void, unknown> {
|
|
26
39
|
for (const child of this.children) {
|
|
27
40
|
yield child;
|
|
28
41
|
|
|
@@ -32,7 +45,7 @@ export class TokenSet {
|
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
getTokenSets() {
|
|
48
|
+
getTokenSets(): TokenSet[] {
|
|
36
49
|
const children = this.children
|
|
37
50
|
.filter((child) => {
|
|
38
51
|
return child.kind === 'TokenSet';
|
|
@@ -44,9 +57,10 @@ export class TokenSet {
|
|
|
44
57
|
return [this, ...children];
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
getTokenSet(name) {
|
|
60
|
+
getTokenSet(name: string) {
|
|
48
61
|
for (const child of this) {
|
|
49
|
-
|
|
62
|
+
// TODO: Is this code necessary given the old code was invalid?
|
|
63
|
+
if (child.kind !== 'TokenSet') {
|
|
50
64
|
continue;
|
|
51
65
|
}
|
|
52
66
|
|
|
@@ -58,7 +72,7 @@ export class TokenSet {
|
|
|
58
72
|
return null;
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
hasToken(tokenOrName) {
|
|
75
|
+
hasToken(tokenOrName: Token | string) {
|
|
62
76
|
const name =
|
|
63
77
|
typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
|
|
64
78
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2018,
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -15,50 +15,41 @@ import * as components from './components';
|
|
|
15
15
|
import { type } from './type';
|
|
16
16
|
import { layout } from './layout';
|
|
17
17
|
import { v10 } from './v10';
|
|
18
|
+
import type { TokenMetadata } from './types';
|
|
18
19
|
|
|
19
20
|
export { Token, TokenFormat, TokenGroup, TokenSet, group, set };
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
+
const formatMetadata = (name: string, type: TokenMetadata['type']) => ({
|
|
23
|
+
name,
|
|
24
|
+
type,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const v11: TokenMetadata[] = [
|
|
22
28
|
// Base color tokens
|
|
23
29
|
...group.getTokens().map((token) => {
|
|
24
|
-
return
|
|
25
|
-
name: token.name,
|
|
26
|
-
type: 'color',
|
|
27
|
-
};
|
|
30
|
+
return formatMetadata(token.name, 'color');
|
|
28
31
|
}),
|
|
29
32
|
|
|
30
33
|
// Contextual tokens
|
|
31
34
|
...contextual.getTokens().map((token) => {
|
|
32
|
-
return
|
|
33
|
-
name: token.name,
|
|
34
|
-
type: 'color',
|
|
35
|
-
};
|
|
35
|
+
return formatMetadata(token.name, 'color');
|
|
36
36
|
}),
|
|
37
37
|
|
|
38
38
|
// Component tokens
|
|
39
39
|
...Object.values(components).flatMap((group) => {
|
|
40
40
|
return group.getTokens().map((token) => {
|
|
41
|
-
return
|
|
42
|
-
name: token.name,
|
|
43
|
-
type: 'color',
|
|
44
|
-
};
|
|
41
|
+
return formatMetadata(token.name, 'color');
|
|
45
42
|
});
|
|
46
43
|
}),
|
|
47
44
|
|
|
48
45
|
// Typography
|
|
49
46
|
...type.getTokens().map((token) => {
|
|
50
|
-
return
|
|
51
|
-
name: token.name,
|
|
52
|
-
type: 'type',
|
|
53
|
-
};
|
|
47
|
+
return formatMetadata(token.name, 'type');
|
|
54
48
|
}),
|
|
55
49
|
|
|
56
50
|
// Layout (spacing)
|
|
57
51
|
...layout.getTokens().map((token) => {
|
|
58
|
-
return
|
|
59
|
-
name: token.name,
|
|
60
|
-
type: 'layout',
|
|
61
|
-
};
|
|
52
|
+
return formatMetadata(token.name, 'layout');
|
|
62
53
|
}),
|
|
63
54
|
];
|
|
64
55
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
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
|
+
export type TokenProperties = string[];
|
|
9
|
+
|
|
10
|
+
export type TokenDefinition = {
|
|
11
|
+
name: string;
|
|
12
|
+
properties?: TokenProperties;
|
|
13
|
+
state?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TokenContext = {
|
|
17
|
+
groups?: string[];
|
|
18
|
+
properties?: TokenProperties;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ResolvedToken = TokenDefinition & {
|
|
22
|
+
groups: string[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type TokenMetadata = {
|
|
26
|
+
name: string;
|
|
27
|
+
type: 'color' | 'layout' | 'type';
|
|
28
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2018, 2026
|
|
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 { TokenSet } from './TokenSet';
|
|
9
|
+
import { TokenGroup } from './TokenGroup';
|
|
10
|
+
import { background, border, field, layer } from './v11TokenGroup';
|
|
11
|
+
|
|
12
|
+
const getTokenOrThrow = (group: TokenGroup, name: string) => {
|
|
13
|
+
const token = group.getToken(name);
|
|
14
|
+
|
|
15
|
+
if (token === null) {
|
|
16
|
+
throw new Error(`Unable to find token \`${name}\` in v11 token set.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return token;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const set = TokenSet.create({
|
|
23
|
+
name: 'All',
|
|
24
|
+
tokens: [
|
|
25
|
+
TokenSet.create({
|
|
26
|
+
name: 'Base set',
|
|
27
|
+
tokens: [
|
|
28
|
+
getTokenOrThrow(background, 'background'),
|
|
29
|
+
getTokenOrThrow(background, 'background-hover'),
|
|
30
|
+
getTokenOrThrow(background, 'background-selected'),
|
|
31
|
+
getTokenOrThrow(background, 'background-selected-hover'),
|
|
32
|
+
getTokenOrThrow(border, 'border-subtle-00'),
|
|
33
|
+
],
|
|
34
|
+
}),
|
|
35
|
+
TokenSet.create({
|
|
36
|
+
name: '01 Layer set',
|
|
37
|
+
tokens: [
|
|
38
|
+
getTokenOrThrow(layer, 'layer-01'),
|
|
39
|
+
getTokenOrThrow(layer, 'layer-active-01'),
|
|
40
|
+
getTokenOrThrow(layer, 'layer-background-01'),
|
|
41
|
+
getTokenOrThrow(layer, 'layer-hover-01'),
|
|
42
|
+
getTokenOrThrow(layer, 'layer-selected-hover-01'),
|
|
43
|
+
getTokenOrThrow(layer, 'layer-accent-01'),
|
|
44
|
+
getTokenOrThrow(layer, 'layer-accent-active-01'),
|
|
45
|
+
getTokenOrThrow(layer, 'layer-accent-hover-01'),
|
|
46
|
+
getTokenOrThrow(field, 'field-01'),
|
|
47
|
+
getTokenOrThrow(field, 'field-hover-01'),
|
|
48
|
+
getTokenOrThrow(border, 'border-subtle-01'),
|
|
49
|
+
getTokenOrThrow(border, 'border-subtle-selected-01'),
|
|
50
|
+
getTokenOrThrow(border, 'border-strong-01'),
|
|
51
|
+
getTokenOrThrow(border, 'border-tile-01'),
|
|
52
|
+
],
|
|
53
|
+
}),
|
|
54
|
+
TokenSet.create({
|
|
55
|
+
name: '02 Layer set',
|
|
56
|
+
tokens: [
|
|
57
|
+
getTokenOrThrow(layer, 'layer-02'),
|
|
58
|
+
getTokenOrThrow(layer, 'layer-active-02'),
|
|
59
|
+
getTokenOrThrow(layer, 'layer-background-02'),
|
|
60
|
+
getTokenOrThrow(layer, 'layer-hover-02'),
|
|
61
|
+
getTokenOrThrow(layer, 'layer-selected-hover-02'),
|
|
62
|
+
getTokenOrThrow(layer, 'layer-accent-02'),
|
|
63
|
+
getTokenOrThrow(layer, 'layer-accent-active-02'),
|
|
64
|
+
getTokenOrThrow(layer, 'layer-accent-hover-02'),
|
|
65
|
+
getTokenOrThrow(field, 'field-02'),
|
|
66
|
+
getTokenOrThrow(field, 'field-hover-02'),
|
|
67
|
+
getTokenOrThrow(border, 'border-subtle-02'),
|
|
68
|
+
getTokenOrThrow(border, 'border-subtle-selected-02'),
|
|
69
|
+
getTokenOrThrow(border, 'border-strong-02'),
|
|
70
|
+
getTokenOrThrow(border, 'border-tile-02'),
|
|
71
|
+
],
|
|
72
|
+
}),
|
|
73
|
+
TokenSet.create({
|
|
74
|
+
name: '03 Layer set',
|
|
75
|
+
tokens: [
|
|
76
|
+
getTokenOrThrow(layer, 'layer-03'),
|
|
77
|
+
getTokenOrThrow(layer, 'layer-active-03'),
|
|
78
|
+
getTokenOrThrow(layer, 'layer-background-03'),
|
|
79
|
+
getTokenOrThrow(layer, 'layer-hover-03'),
|
|
80
|
+
getTokenOrThrow(layer, 'layer-selected-hover-03'),
|
|
81
|
+
getTokenOrThrow(layer, 'layer-accent-03'),
|
|
82
|
+
getTokenOrThrow(layer, 'layer-accent-active-03'),
|
|
83
|
+
getTokenOrThrow(layer, 'layer-accent-hover-03'),
|
|
84
|
+
getTokenOrThrow(field, 'field-03'),
|
|
85
|
+
getTokenOrThrow(field, 'field-hover-03'),
|
|
86
|
+
getTokenOrThrow(border, 'border-subtle-03'),
|
|
87
|
+
getTokenOrThrow(border, 'border-subtle-selected-03'),
|
|
88
|
+
getTokenOrThrow(border, 'border-strong-03'),
|
|
89
|
+
getTokenOrThrow(border, 'border-tile-03'),
|
|
90
|
+
],
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,39 +11,31 @@ import Color from 'color';
|
|
|
11
11
|
* Example: token = hsl(10, 10, 10);
|
|
12
12
|
* adjustLightness(token, 5) === hsl(10, 10, 15);
|
|
13
13
|
* adjustLightness(token, -5) === hsl(10, 10, 5);
|
|
14
|
-
* @param {string} token
|
|
15
|
-
* @param {integer} shift The number of percentage points (positive or negative) by which to shift the lightness of a token.
|
|
16
|
-
* @returns {string}
|
|
17
14
|
*/
|
|
18
|
-
export
|
|
15
|
+
export const adjustLightness = (token: string, shift: number) => {
|
|
19
16
|
const original = Color(token).hsl().object();
|
|
20
17
|
|
|
21
18
|
return Color({ ...original, l: (original.l += shift) })
|
|
22
19
|
.round()
|
|
23
20
|
.hex()
|
|
24
21
|
.toLowerCase();
|
|
25
|
-
}
|
|
22
|
+
};
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* Adjust a given token's alpha by a specified amount
|
|
29
26
|
* Example: token = rgba(10, 10, 10, 1.0);
|
|
30
27
|
* adjustAlpha(token, 0.3) === rgba(10, 10, 10, 0.3);
|
|
31
|
-
* @param {string} token
|
|
32
|
-
* @param {float} alpha
|
|
33
|
-
* @returns {string}
|
|
34
28
|
*/
|
|
35
|
-
export
|
|
29
|
+
export const adjustAlpha = (token: string, alpha: number) => {
|
|
36
30
|
return Color(token).rgb().alpha(alpha).string();
|
|
37
|
-
}
|
|
31
|
+
};
|
|
38
32
|
|
|
39
33
|
const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
40
34
|
|
|
41
35
|
/**
|
|
42
36
|
* Format a given token into the format expected in CSS/SCSS-based projects.
|
|
43
|
-
* @param {string} token
|
|
44
|
-
* @returns {string}
|
|
45
37
|
*/
|
|
46
|
-
export
|
|
38
|
+
export const formatTokenName = (token: string) => {
|
|
47
39
|
let string = '';
|
|
48
40
|
|
|
49
41
|
for (let i = 0; i < token.length; i++) {
|
|
@@ -74,4 +66,4 @@ export function formatTokenName(token) {
|
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
return string;
|
|
77
|
-
}
|
|
69
|
+
};
|
package/tsconfig.json
ADDED