Skip to content

Commit 50087aa

Browse files
timhettlermikaelvesavuori
authored andcommitted
feat(css-variables-output)prefix css variables with frame name
1 parent cb82771 commit 50087aa

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

bin/frameworks/filesystem/getFileContentAndPath.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const getTokenString = (
119119
const constAssertion = format === 'ts' ? ' as const;' : '';
120120

121121
if (format === 'json') return getTokenStringJSON(file);
122-
if (format === 'css') return getTokenStringCSS(file);
122+
if (format === 'css') return getTokenStringCSS(file, name);
123123
if (dataType === 'enum') return getTokenStringEnum(file, name, exportString);
124124
return getTokenStringJS(file, name, exportString, constAssertion);
125125
};
@@ -134,13 +134,13 @@ function getTokenStringJSON(file: string | ProcessedToken) {
134134
/**
135135
* @description Return CSS variables token string
136136
*/
137-
function getTokenStringCSS(file: string | ProcessedToken) {
137+
function getTokenStringCSS(file: string | ProcessedToken, name: string) {
138138
const contents: any = file;
139139
let css = ':root {\n';
140140

141141
for (const key in contents) {
142142
const value = contents[key];
143-
css += ` --${key}: ${value};\n`;
143+
css += ` --${name}-${key}: ${value};\n`;
144144
}
145145

146146
css += '}\n';

testdata/getFileContentAndPathOperation.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,22 @@ enum colors {
283283
export default colors;`;
284284

285285
export const expectedCss = `:root {
286-
--green3: rgba(111, 207, 151, 1);
287-
--green2: rgba(39, 174, 96, 1);
288-
--green1: rgba(33, 150, 83, 1);
289-
--blue3: rgba(86, 204, 242, 1);
290-
--blue2: rgba(45, 156, 219, 1);
291-
--blue1: rgba(47, 128, 237, 1);
292-
--yellow: rgba(242, 201, 76, 1);
293-
--orange: rgba(242, 153, 74, 1);
294-
--red: rgba(235, 87, 87, 1);
295-
--neon: rgba(228, 255, 193, 1);
296-
--gray5: rgba(242, 242, 242, 1);
297-
--gray4: rgba(224, 224, 224, 1);
298-
--gray3: rgba(189, 189, 189, 1);
299-
--gray2: rgba(130, 130, 130, 1);
300-
--gray1: rgba(79, 79, 79, 1);
301-
--white: rgba(255, 255, 255, 1);
302-
--black: rgba(51, 51, 51, 1);
286+
--colors-green3: rgba(111, 207, 151, 1);
287+
--colors-green2: rgba(39, 174, 96, 1);
288+
--colors-green1: rgba(33, 150, 83, 1);
289+
--colors-blue3: rgba(86, 204, 242, 1);
290+
--colors-blue2: rgba(45, 156, 219, 1);
291+
--colors-blue1: rgba(47, 128, 237, 1);
292+
--colors-yellow: rgba(242, 201, 76, 1);
293+
--colors-orange: rgba(242, 153, 74, 1);
294+
--colors-red: rgba(235, 87, 87, 1);
295+
--colors-neon: rgba(228, 255, 193, 1);
296+
--colors-gray5: rgba(242, 242, 242, 1);
297+
--colors-gray4: rgba(224, 224, 224, 1);
298+
--colors-gray3: rgba(189, 189, 189, 1);
299+
--colors-gray2: rgba(130, 130, 130, 1);
300+
--colors-gray1: rgba(79, 79, 79, 1);
301+
--colors-white: rgba(255, 255, 255, 1);
302+
--colors-black: rgba(51, 51, 51, 1);
303303
}
304304
`;

0 commit comments

Comments
 (0)