Skip to content

Commit 58c8a10

Browse files
authored
Feat: color placeholder text only (#208)
feat: added color placeholders for interactive text
1 parent be865bb commit 58c8a10

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

scripts/color-placeholders-generator.js

+21-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*/
55

66
const prefix = 'db';
7+
const fileHeader = `
8+
@use "variables" as *;
9+
// Do not edit directly
10+
// Generated on
11+
// ${new Date().toString()}
12+
`;
713

814
const generateInteractiveVariants = (currentColorObject, cssProp) => {
915
return `
@@ -39,6 +45,7 @@ const generateBGVariants = (
3945
%${placeholderName}-ia-states {
4046
${generateInteractiveVariants(currentColorObject, 'background-color')}
4147
}
48+
4249
%${placeholderName} {
4350
background-color: $${prefix}-${currentColorObject.enabled.name};
4451
color: $${prefix}-${baseColorObject.enabled.name};
@@ -60,7 +67,6 @@ const generateBGVariants = (
6067
a {
6168
${generateInteractiveVariants(baseColorObject, 'color')}
6269
}
63-
6470
`;
6571
if (baseColorObject.weak) {
6672
result += `
@@ -74,7 +80,8 @@ const generateBGVariants = (
7480
`;
7581
}
7682

77-
result += `}`;
83+
result += `}
84+
`;
7885
return result;
7986
};
8087

@@ -86,15 +93,25 @@ const generateBGVariants = (
8693
* @returns scss string
8794
*/
8895
exports.generateColorUtilitityPlaceholder = (colorToken) => {
89-
let output = '@use "variables" as *;\n';
96+
let output = fileHeader;
9097

9198
for (const [, value] of Object.keys(colorToken).entries()) {
92-
output += `/**
99+
output += `
100+
/**
93101
* ${value.toUpperCase()} - Placeholder Utilities
94102
**/
95103
`;
96104
// Text colors with interactive variant, e.g. primary
97105
if (colorToken[value].enabled) {
106+
// Only text
107+
output += `
108+
%${prefix}-${value}-text-ia {
109+
color: $${prefix}-${colorToken[value].enabled.name};
110+
${generateInteractiveVariants(colorToken[value], 'color')}
111+
}
112+
113+
`;
114+
98115
// Text and background colors
99116
output += generateBGVariants(
100117
value,

0 commit comments

Comments
 (0)