@adobe/spectrum-tokens 12.0.0-beta.9 → 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/CHANGELOG.md +47 -2
- package/README.md +73 -4
- package/{config.js → commitlint.config.cjs} +5 -22
- package/dist/json/drover.json +1748 -0
- package/dist/json/variables.json +12398 -2482
- package/jest.config.cjs +22 -0
- package/manifest.json +9 -0
- package/package.json +28 -12
- package/src/color-aliases.json +1197 -0
- package/src/color-component.json +108 -0
- package/{tokens/color.json → src/color-palette.json} +280 -240
- package/src/layout-component.json +3141 -0
- package/src/layout.json +1414 -0
- package/{tokens/color-semantic.json → src/semantic-color-palette.json} +85 -15
- package/src/typography.json +1140 -0
- package/tasks/buildManifest.js +8 -0
- package/tasks/buildSpectrumTokens.js +58 -0
- package/tasks/deprecateExpress.js +11 -0
- package/tasks/diff.js +106 -0
- package/tasks/lib/augmentExpressTokens.js +40 -0
- package/commitlint.config.js +0 -3
- package/tokens/color-alias.json +0 -132
- package/tokens/component-layout.json +0 -738
- package/tokens/layout.json +0 -908
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import glob from "glob-promise";
|
|
2
|
+
import { writeFile } from "fs/promises";
|
|
3
|
+
|
|
4
|
+
const manifestFileName = "manifest.json";
|
|
5
|
+
const files = await glob("src/**/*.json");
|
|
6
|
+
|
|
7
|
+
await writeFile(manifestFileName, JSON.stringify(files, null, 2));
|
|
8
|
+
console.log(`Wrote ${manifestFileName} with ${files.length} files.`);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import StyleDictionary from "style-dictionary";
|
|
14
|
+
import {
|
|
15
|
+
JsonSetsFormatter,
|
|
16
|
+
NameKebabTransfom,
|
|
17
|
+
DroverJsonFormatter,
|
|
18
|
+
AttributeSetsTransform,
|
|
19
|
+
} from "style-dictionary-sets";
|
|
20
|
+
|
|
21
|
+
StyleDictionary.registerTransform(AttributeSetsTransform);
|
|
22
|
+
StyleDictionary.registerTransform(NameKebabTransfom);
|
|
23
|
+
StyleDictionary.registerFormat(JsonSetsFormatter);
|
|
24
|
+
StyleDictionary.registerFormat(DroverJsonFormatter);
|
|
25
|
+
|
|
26
|
+
StyleDictionary.extend({
|
|
27
|
+
source: ["src/**/*.json"],
|
|
28
|
+
platforms: {
|
|
29
|
+
JSON: {
|
|
30
|
+
buildPath: "dist/json/",
|
|
31
|
+
transforms: [NameKebabTransfom.name],
|
|
32
|
+
files: [
|
|
33
|
+
{
|
|
34
|
+
destination: "variables.json",
|
|
35
|
+
format: JsonSetsFormatter.name,
|
|
36
|
+
options: {
|
|
37
|
+
showFileHeader: false,
|
|
38
|
+
outputReferences: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
Drover: {
|
|
44
|
+
buildPath: "dist/json/",
|
|
45
|
+
transforms: [AttributeSetsTransform.name, NameKebabTransfom.name],
|
|
46
|
+
files: [
|
|
47
|
+
{
|
|
48
|
+
destination: "drover.json",
|
|
49
|
+
format: "drover/json/sets",
|
|
50
|
+
options: {
|
|
51
|
+
showFileHeader: false,
|
|
52
|
+
outputReferences: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}).buildAllPlatforms();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import glob from "glob-promise";
|
|
2
|
+
import { readFile, writeFile } from "fs/promises";
|
|
3
|
+
import augmentExpressTokens from "./lib/augmentExpressTokens.js";
|
|
4
|
+
|
|
5
|
+
const files = await glob("src/**/*.json");
|
|
6
|
+
files.forEach(async (fileName) => {
|
|
7
|
+
const fileTokens = JSON.parse(await readFile(fileName, "utf8"));
|
|
8
|
+
const result = augmentExpressTokens(fileTokens);
|
|
9
|
+
await writeFile(fileName, JSON.stringify(result, null, 2));
|
|
10
|
+
console.log(`Updated ${fileName}.`);
|
|
11
|
+
});
|
package/tasks/diff.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { access, readFile, writeFile } from "fs/promises";
|
|
2
|
+
import fetch from "node-fetch";
|
|
3
|
+
import { detailedDiff, diff } from "deep-object-diff";
|
|
4
|
+
|
|
5
|
+
const tag = "beta";
|
|
6
|
+
const tokenPath = "dist/json/variables.json";
|
|
7
|
+
|
|
8
|
+
run()
|
|
9
|
+
.then(() => {
|
|
10
|
+
process.exit();
|
|
11
|
+
})
|
|
12
|
+
.catch((err) => {
|
|
13
|
+
console.error(err);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
async function run() {
|
|
18
|
+
const [newTokens, oldTokens] = await Promise.all([
|
|
19
|
+
getNewTokens(),
|
|
20
|
+
getOldTokens(),
|
|
21
|
+
]);
|
|
22
|
+
const diffResult = detailedDiff(oldTokens, newTokens);
|
|
23
|
+
|
|
24
|
+
calculatePossibleRenames(diffResult, oldTokens, newTokens);
|
|
25
|
+
|
|
26
|
+
logResultCategory(diffResult, "added");
|
|
27
|
+
logResultCategory(diffResult, "deleted");
|
|
28
|
+
logResultCategory(diffResult, "updated", "Token values updated");
|
|
29
|
+
logResultCategory(diffResult, "possiblyRenamed", "Tokens possibly renamed");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function getNewTokens() {
|
|
33
|
+
try {
|
|
34
|
+
await access(tokenPath);
|
|
35
|
+
return JSON.parse(await readFile(tokenPath, { encoding: "utf8" }));
|
|
36
|
+
} catch {
|
|
37
|
+
console.error("cannot access");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function getOldTokens() {
|
|
42
|
+
try {
|
|
43
|
+
const response = await fetch(
|
|
44
|
+
`https://unpkg.com/@adobe/spectrum-tokens@${tag}/${tokenPath}`
|
|
45
|
+
);
|
|
46
|
+
console.log(`Fetched ${response.url}`);
|
|
47
|
+
return await response.json();
|
|
48
|
+
} catch {
|
|
49
|
+
console.error("cannot access");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function calculatePossibleRenames(diffResult, oldTokens, newTokens) {
|
|
54
|
+
diffResult.possiblyRenamed = {};
|
|
55
|
+
Object.keys(diffResult.deleted).forEach((deletedTokenName) => {
|
|
56
|
+
const oldTokenValue = oldTokens[deletedTokenName];
|
|
57
|
+
const allValueMatches = [];
|
|
58
|
+
Object.keys(diffResult.added).forEach((addedTokenName, i) => {
|
|
59
|
+
const newTokenValue = newTokens[addedTokenName];
|
|
60
|
+
if (Object.keys(diff(oldTokenValue, newTokenValue)).length === 0) {
|
|
61
|
+
allValueMatches.push(addedTokenName);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (allValueMatches.length > 0) {
|
|
65
|
+
diffResult.possiblyRenamed[deletedTokenName] = allValueMatches;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function logResultCategory(diffResult, categoryKey, msg) {
|
|
71
|
+
const results = diffResult[categoryKey];
|
|
72
|
+
const resultCount = Object.keys(results).length;
|
|
73
|
+
if (!msg) {
|
|
74
|
+
msg = `Tokens ${categoryKey}`;
|
|
75
|
+
}
|
|
76
|
+
if (resultCount > 0) {
|
|
77
|
+
console.log(`\n*${msg} (${resultCount}):*`);
|
|
78
|
+
switch (categoryKey) {
|
|
79
|
+
case "possiblyRenamed":
|
|
80
|
+
Object.keys(results)
|
|
81
|
+
.sort()
|
|
82
|
+
.forEach((oldTokenName, i) => {
|
|
83
|
+
if (
|
|
84
|
+
Array.isArray(results[oldTokenName]) &&
|
|
85
|
+
results[oldTokenName].length > 1
|
|
86
|
+
) {
|
|
87
|
+
console.log(
|
|
88
|
+
` - Old name: \`${oldTokenName}\`, new name options:`
|
|
89
|
+
);
|
|
90
|
+
results[oldTokenName].forEach((newTokenName) =>
|
|
91
|
+
console.log(` - \`${newTokenName}\``)
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
console.log(
|
|
95
|
+
` - \`${oldTokenName}\` -> \`${results[oldTokenName][0]}\``
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
Object.keys(results)
|
|
102
|
+
.sort()
|
|
103
|
+
.forEach((tokenName, i) => console.log(` - \`${tokenName}\``));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const deprecationObj = {
|
|
2
|
+
deprecated: true,
|
|
3
|
+
deprecated_comment:
|
|
4
|
+
"Express will merge with Spectrum with the release of Spectrum 2.",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const findExpressValue = (tokenObj) => {
|
|
8
|
+
if (typeof tokenObj === "object" && tokenObj !== null) {
|
|
9
|
+
if (tokenObj.hasOwnProperty("value")) {
|
|
10
|
+
return {
|
|
11
|
+
...tokenObj,
|
|
12
|
+
...deprecationObj,
|
|
13
|
+
};
|
|
14
|
+
} else {
|
|
15
|
+
const result = {};
|
|
16
|
+
Object.keys(tokenObj).forEach((tokenName) => {
|
|
17
|
+
result[tokenName] = findExpressValue(tokenObj[tokenName]);
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const augmentExpressTokens = (tokenObj) => {
|
|
25
|
+
if (typeof tokenObj === "object" && tokenObj !== null) {
|
|
26
|
+
const result = {};
|
|
27
|
+
Object.keys(tokenObj).forEach((tokenName) => {
|
|
28
|
+
if (tokenName === "express") {
|
|
29
|
+
result[tokenName] = findExpressValue(tokenObj[tokenName]);
|
|
30
|
+
} else {
|
|
31
|
+
result[tokenName] = augmentExpressTokens(tokenObj[tokenName]);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
} else {
|
|
36
|
+
return tokenObj;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default augmentExpressTokens;
|
package/commitlint.config.js
DELETED
package/tokens/color-alias.json
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"transparent-white-200": {
|
|
3
|
-
"value": "rgba(255, 255, 255, 0.10)"
|
|
4
|
-
},
|
|
5
|
-
"transparent-white-300": {
|
|
6
|
-
"value": "rgba(255, 255, 255, 0.25)"
|
|
7
|
-
},
|
|
8
|
-
"transparent-white-400": {
|
|
9
|
-
"value": "rgba(255, 255, 255, 0.40)"
|
|
10
|
-
},
|
|
11
|
-
"transparent-white-500": {
|
|
12
|
-
"value": "rgba(255, 255, 255, 0.55)"
|
|
13
|
-
},
|
|
14
|
-
"transparent-white-600": {
|
|
15
|
-
"value": "rgba(255, 255, 255, 0.70)"
|
|
16
|
-
},
|
|
17
|
-
"transparent-white-700": {
|
|
18
|
-
"value": "rgba(255, 255, 255, 0.80)"
|
|
19
|
-
},
|
|
20
|
-
"transparent-white-800": {
|
|
21
|
-
"value": "rgba(255, 255, 255, 0.90)"
|
|
22
|
-
},
|
|
23
|
-
"transparent-white-900": {
|
|
24
|
-
"value": "rgb(255, 255, 255)"
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
"transparent-black-200": {
|
|
28
|
-
"value": "rgba(0, 0, 0, 0.10)"
|
|
29
|
-
},
|
|
30
|
-
"transparent-black-300": {
|
|
31
|
-
"value": "rgba(0, 0, 0, 0.25)"
|
|
32
|
-
},
|
|
33
|
-
"transparent-black-400": {
|
|
34
|
-
"value": "rgba(0, 0, 0, 0.40)"
|
|
35
|
-
},
|
|
36
|
-
"transparent-black-500": {
|
|
37
|
-
"value": "rgba(0, 0, 0, 0.55)"
|
|
38
|
-
},
|
|
39
|
-
"transparent-black-600": {
|
|
40
|
-
"value": "rgba(0, 0, 0, 0.70)"
|
|
41
|
-
},
|
|
42
|
-
"transparent-black-700": {
|
|
43
|
-
"value": "rgba(0, 0, 0, 0.80)"
|
|
44
|
-
},
|
|
45
|
-
"transparent-black-800": {
|
|
46
|
-
"value": "rgba(0, 0, 0, 0.90)"
|
|
47
|
-
},
|
|
48
|
-
"transparent-black-900": {
|
|
49
|
-
"value": "rgb(0, 0, 0)"
|
|
50
|
-
},
|
|
51
|
-
"focus-ring-color": {
|
|
52
|
-
"value": "{blue-800}"
|
|
53
|
-
},
|
|
54
|
-
"focus-ring-static-white-color": {
|
|
55
|
-
"value": "{black}"
|
|
56
|
-
},
|
|
57
|
-
"focus-ring-static-black-color": {
|
|
58
|
-
"value": "{white}"
|
|
59
|
-
},
|
|
60
|
-
"neutral-content-color": {
|
|
61
|
-
"value": "{gray-800}"
|
|
62
|
-
},
|
|
63
|
-
"neutral-content-color-hover": {
|
|
64
|
-
"value": "{gray-900}"
|
|
65
|
-
},
|
|
66
|
-
"neutral-content-color-down": {
|
|
67
|
-
"value": "{gray-900}"
|
|
68
|
-
},
|
|
69
|
-
"neutral-content-color-key-focus": {
|
|
70
|
-
"value": "{gray-900}"
|
|
71
|
-
},
|
|
72
|
-
"neutral-subdued-content-color": {
|
|
73
|
-
"default": {
|
|
74
|
-
"value": "{gray-700}"
|
|
75
|
-
},
|
|
76
|
-
"hover": {
|
|
77
|
-
"value": "{gray-800}"
|
|
78
|
-
},
|
|
79
|
-
"down": {
|
|
80
|
-
"value": "{gray-900}"
|
|
81
|
-
},
|
|
82
|
-
"key-focus": {
|
|
83
|
-
"value": "{gray-800}"
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"accent-content-color": {
|
|
87
|
-
"value": "{accent-color-900}"
|
|
88
|
-
},
|
|
89
|
-
"accent-content-color-hover": {
|
|
90
|
-
"value": "{accent-color-1000}"
|
|
91
|
-
},
|
|
92
|
-
"accent-content-color-down": {
|
|
93
|
-
"value": "{accent-color-1100}"
|
|
94
|
-
},
|
|
95
|
-
"accent-content-color-key-focus": {
|
|
96
|
-
"value": "{accent-color-1000}"
|
|
97
|
-
},
|
|
98
|
-
"negative-content-color": {
|
|
99
|
-
"value": "{negative-color-900}"
|
|
100
|
-
},
|
|
101
|
-
"negative-content-color-hover": {
|
|
102
|
-
"value": "{negative-color-1000}"
|
|
103
|
-
},
|
|
104
|
-
"negative-content-color-down": {
|
|
105
|
-
"value": "{negative-color-1100}"
|
|
106
|
-
},
|
|
107
|
-
"negative-content-color-key-focus": {
|
|
108
|
-
"value": "{negative-color-1000}"
|
|
109
|
-
},
|
|
110
|
-
"disabled-content-color": {
|
|
111
|
-
"value": "{gray-400}"
|
|
112
|
-
},
|
|
113
|
-
"disabled-content-static-white-color": {
|
|
114
|
-
"value": "{transparent-white-500}"
|
|
115
|
-
},
|
|
116
|
-
"disabled-content-static-black-color": {
|
|
117
|
-
"value": "{transparent-black-500}"
|
|
118
|
-
},
|
|
119
|
-
"drop-shadow-color": {
|
|
120
|
-
"sets": {
|
|
121
|
-
"light": {
|
|
122
|
-
"value": "rgba(0, 0, 0, 0.15)"
|
|
123
|
-
},
|
|
124
|
-
"dark": {
|
|
125
|
-
"value": "rgba(0, 0, 0, 0.50)"
|
|
126
|
-
},
|
|
127
|
-
"darkest": {
|
|
128
|
-
"value": "rgba(0, 0, 0, 0.80)"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|