forked from Esri/calcite-colors
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
import { writeFile } from "fs"; | ||
import { colors, themes } from "../dist/colors.modern.js"; | ||
function generateThemeVars(theme) { | ||
let data = ""; | ||
for (const [key] of Object.entries(theme.variables)) { | ||
data += ` --calcite-ui-${key}: #{$ui-${key}-${theme.name}};\n`; | ||
} | ||
return data; | ||
return Object.entries(theme.variables).map(([key, value]) => `$ui-${key}-${theme.name}: ${value};\n`).join(""); | ||
} | ||
function generateTheme(theme) { | ||
return `${generateThemeVars(theme)}\n@mixin calcite-theme-${theme.name}() {\n${generateCSSThemeVars(theme)}}\n`; | ||
} | ||
function generateCSSThemeVars(theme) { | ||
return Object.entries(theme.variables).map(([key]) => ` --calcite-ui-${key}: #{$ui-${key}-${theme.name}};\n`).join(""); | ||
} | ||
function generateColors() { | ||
return Object.entries(colors).map(([key, value]) => `$${key}: ${value};\n`).join(""); | ||
} | ||
function generateThemes() { | ||
return themes.map((theme) => generateTheme(theme)).join(""); | ||
} | ||
function generateData() { | ||
let data = ""; | ||
for (const [key, value] of Object.entries(colors)) { | ||
data += `$${key}: ${value};\n`; | ||
} | ||
themes.forEach((theme) => { | ||
for (const [key, value] of Object.entries(theme.variables)) { | ||
data += `$ui-${key}-${theme.name}: ${value};\n`; | ||
} | ||
data += `\n@mixin calcite-theme-${theme.name}() {\n${generateThemeVars(theme)}}\n`; | ||
}); | ||
return data; | ||
return `${generateColors()}${generateThemes()}`; | ||
} | ||
writeFile("dist/colors.scss", generateData(), () => { }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters