Skip to content

Commit 93d35a9

Browse files
committed
feat(visual): revert palette resolve
1 parent 2310fbd commit 93d35a9

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

packages/tokens-builder/filters/css-variables.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ module.exports = (StyleDictionary) => {
1515

1616
StyleDictionary.registerFilter({
1717
name: 'css-variables-light',
18-
matcher: (prop) => prop.attributes.light
18+
matcher: (prop) => prop.attributes.light && !prop.attributes.palette
1919
});
2020

2121
StyleDictionary.registerFilter({
2222
name: 'css-variables-dark',
23-
matcher: (prop) => prop.attributes.dark
23+
matcher: (prop) => prop.attributes.dark && !prop.attributes.palette
2424
});
2525

2626
StyleDictionary.registerFilter({

packages/tokens-builder/formats/utils.js

-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const transform = require('style-dictionary/lib/common/transforms');
2-
const getPathFromName = require('style-dictionary/lib/utils/references/getPathFromName');
3-
const createReferenceRegex = require('style-dictionary/lib/utils/references/createReferenceRegex');
42

53
const unwrapObjectTransformer = (token) => {
64
return Object.keys(token.value).map((key) => {
@@ -17,18 +15,6 @@ const unwrapObjectTransformer = (token) => {
1715
}, {});
1816
};
1917

20-
const resolvePaletteRef = (token, dictionary) => {
21-
const regex = createReferenceRegex({});
22-
23-
const findPalette = (match, variable) => {
24-
const [category, item, ...pathName] = getPathFromName(variable);
25-
const pathToSemanticPalette = dictionary.tokens[category][item].palette.original.value.replace(/[{}]/g, '');
26-
return `{${pathToSemanticPalette}.${pathName[pathName.length - 1]}}`;
27-
};
28-
token.original.value = token.original.value.replace(regex, findPalette);
29-
return token;
30-
};
31-
3218
const getMapFromObj = (object) => {
3319
const result = Object.keys(object)
3420
.map((key) => {
@@ -49,9 +35,6 @@ const applyCustomTransformations = (dictionary) => {
4935
if (typeof token.value === 'object' && token.type === 'font') {
5036
return unwrapObjectTransformer(token);
5137
}
52-
if (typeof token.original.value === 'string' && token.original.value.includes('palette.value')) {
53-
return resolvePaletteRef(token, dictionary);
54-
}
5538
return token;
5639
})
5740
.filter((token) => !token.attributes.palette);
@@ -62,6 +45,5 @@ const applyCustomTransformations = (dictionary) => {
6245
module.exports = {
6346
unwrapObjectTransformer,
6447
getMapFromObj,
65-
resolvePaletteRef,
6648
applyCustomTransformations
6749
};

0 commit comments

Comments
 (0)