-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from sima-land/472-gradients-and-colors-upd
- Loading branch information
Showing
10 changed files
with
217 additions
and
63 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,70 +1,46 @@ | ||
import { readFile, writeFile } from 'fs/promises'; | ||
import Handlebars from 'handlebars'; | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import handlebars from 'handlebars'; | ||
import { colorGroups, gradients } from './data.mjs'; | ||
|
||
const colorsByGroups = { | ||
basic: { | ||
blue: '#1f84db', | ||
gray87: '#212121', | ||
gray76: '#3a3a3b', | ||
gray66: '#545455', | ||
gray54: '#757575', | ||
gray38: '#9e9e9e', | ||
gray24: '#c2c2c2', | ||
gray12: '#e0e0e0', | ||
gray8: '#ebebeb', | ||
gray4: '#f5f5f5', | ||
gray2: '#fafafa', | ||
white: '#fff', | ||
const items = [ | ||
{ | ||
templatePath: 'colors.ts.handlebars', | ||
templateData: { colorGroups }, | ||
outputPath: '../src/colors/index.ts', | ||
}, | ||
additional: { | ||
'deep-red': '#d50000', | ||
red: '#fb3a2f', | ||
'light-red': '#feebea', | ||
'dark-teal': '#089176', | ||
teal: '#09ab8b', | ||
green: '#00c853', | ||
'light-green': '#64dd17', | ||
lime: '#aeea00', | ||
'faded-green': '#eff9ea', | ||
pink: '#e82e5c', | ||
purple: '#b52ea8', | ||
violet: '#902bd0', | ||
'deep-purple': '#634bdf', | ||
'electric-blue': '#2962ff', | ||
'light-blue': '#0091ea', | ||
cyan: '#00b8d4', | ||
sky: '#e4f1f9', | ||
'deep-orange': '#ff7200', | ||
amber: '#ffab00', | ||
yellow: '#ffd600', | ||
gold: '#d5a43b', | ||
brown: '#795548', | ||
'blue-gray': '#607d8b', | ||
'deep-blue': '#00599d', | ||
'dark-blue': '#002b41', | ||
'unlit-blue': '#1b75c2', | ||
crimson: '#f4446b', | ||
{ | ||
templatePath: 'colors.scss.handlebars', | ||
templateData: { colorGroups }, | ||
outputPath: '../src/colors.scss', | ||
}, | ||
}; | ||
{ | ||
templatePath: 'gradients.ts.handlebars', | ||
templateData: { gradients }, | ||
outputPath: '../src/gradients/index.ts', | ||
}, | ||
{ | ||
templatePath: 'gradients.scss.handlebars', | ||
templateData: { gradients }, | ||
outputPath: '../src/gradients.scss', | ||
}, | ||
]; | ||
|
||
async function main() { | ||
const styleTemplateSource = await readFile( | ||
new URL('./colors.scss.handlebars', import.meta.url), | ||
'utf-8', | ||
); | ||
const scriptTemplateSource = await readFile( | ||
new URL('./colors.ts.handlebars', import.meta.url), | ||
'utf-8', | ||
); | ||
function relative(pathname) { | ||
return path.resolve(import.meta.dirname, pathname); | ||
} | ||
|
||
const styleTemplate = Handlebars.compile(styleTemplateSource); | ||
const scriptTemplate = Handlebars.compile(scriptTemplateSource); | ||
async function outputFile(filename, content) { | ||
await fs.mkdir(path.dirname(relative(filename)), { recursive: true }); | ||
await fs.writeFile(relative(filename), content); | ||
} | ||
|
||
const stylePath = new URL('../src/colors.scss', import.meta.url); | ||
const scriptPath = new URL('../src/colors/index.ts', import.meta.url); | ||
async function buildSource({ templatePath, templateData, outputPath }) { | ||
const templateSrc = await fs.readFile(relative(templatePath), 'utf-8'); | ||
const template = handlebars.compile(templateSrc); | ||
|
||
await writeFile(stylePath, styleTemplate({ colorsByGroups })); | ||
await writeFile(scriptPath, scriptTemplate({ colorsByGroups })); | ||
await outputFile(relative(outputPath), template(templateData)); | ||
} | ||
|
||
main(); | ||
await Promise.all(items.map(buildSource)); |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export const colorGroups = { | ||
basic: { | ||
blue: '#1f84db', | ||
black: '#000', | ||
gray87: '#212121', | ||
gray76: '#3a3a3b', | ||
gray66: '#545455', | ||
gray54: '#757575', | ||
gray38: '#9e9e9e', | ||
gray24: '#c2c2c2', | ||
gray12: '#e0e0e0', | ||
gray8: '#ebebeb', | ||
gray4: '#f5f5f5', | ||
gray2: '#fafafa', | ||
white: '#fff', | ||
}, | ||
additional: { | ||
'deep-red': '#d50000', | ||
red: '#fb3a2f', | ||
'light-red': '#feebea', | ||
'dark-teal': '#089176', | ||
teal: '#09ab8b', | ||
green: '#00c853', | ||
'light-green': '#64dd17', | ||
lime: '#aeea00', | ||
'faded-green': '#eff9ea', | ||
pink: '#e82e5c', | ||
purple: '#b52ea8', | ||
violet: '#902bd0', | ||
'deep-purple': '#634bdf', | ||
'electric-blue': '#2962ff', | ||
'light-blue': '#0091ea', | ||
cyan: '#00b8d4', | ||
sky: '#e4f1f9', | ||
'deep-orange': '#ff7200', | ||
amber: '#ffab00', | ||
yellow: '#ffd600', | ||
gold: '#d5a43b', | ||
brown: '#795548', | ||
'blue-gray': '#607d8b', | ||
'deep-blue': '#00599d', | ||
'dark-blue': '#002b41', | ||
'unlit-blue': '#1b75c2', | ||
crimson: '#f4446b', | ||
}, | ||
}; | ||
|
||
export const gradients = { | ||
sunrise: 'linear-gradient(135deg, #bf16af 0%, #ff9b8d 100%)', | ||
twilight: 'linear-gradient(135deg, #4d74ff 0%, #e546ff 100%)', | ||
sunset: 'linear-gradient(315deg, #ffb571 0%, #f2000f 100%)', | ||
sunshine: 'linear-gradient(135deg, #ff7200 0%, #f5d00b 100%)', | ||
gold: 'linear-gradient(315deg, #f1d18c 0%, #da9c3b 100%)', | ||
foliage: 'linear-gradient(135deg, #09ab8b 0%, #a9e007 100%)', | ||
sky: 'linear-gradient(135deg, #3777fe 0%, #21e3e4 100%)', | ||
'polar-light': 'linear-gradient(135deg, #46007c 0%, #008dc9 100%)', | ||
night: 'linear-gradient(135deg, #0f0f0f 0%, #757575 100%)', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// GENERATED FILE - DO NOT CHANGE IT MANUALLY | ||
|
||
{{#each gradients}} | ||
${{@key}}: {{this}}; | ||
{{/each}} | ||
|
||
@mixin properties() { | ||
{{#each gradients}} | ||
--gradient-{{@key}}: {{this}}; | ||
{{/each}} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// GENERATED FILE - DO NOT CHANGE IT MANUALLY | ||
|
||
/** Градиенты дизайн-системы. */ | ||
export const GRADIENT = { | ||
{{#each gradients}} | ||
'{{@key}}': '{{this}}', | ||
{{/each}} | ||
} as const; | ||
|
||
export const GRADIENTS = new Map(Object.entries(GRADIENT)) as Map<keyof typeof GRADIENT, string>; |
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// GENERATED FILE - DO NOT CHANGE IT MANUALLY | ||
|
||
$sunrise: linear-gradient(135deg, #bf16af 0%, #ff9b8d 100%); | ||
$twilight: linear-gradient(135deg, #4d74ff 0%, #e546ff 100%); | ||
$sunset: linear-gradient(315deg, #ffb571 0%, #f2000f 100%); | ||
$sunshine: linear-gradient(135deg, #ff7200 0%, #f5d00b 100%); | ||
$gold: linear-gradient(315deg, #f1d18c 0%, #da9c3b 100%); | ||
$foliage: linear-gradient(135deg, #09ab8b 0%, #a9e007 100%); | ||
$sky: linear-gradient(135deg, #3777fe 0%, #21e3e4 100%); | ||
$polar-light: linear-gradient(135deg, #46007c 0%, #008dc9 100%); | ||
$night: linear-gradient(135deg, #0f0f0f 0%, #757575 100%); | ||
|
||
@mixin properties() { | ||
--gradient-sunrise: linear-gradient(135deg, #bf16af 0%, #ff9b8d 100%); | ||
--gradient-twilight: linear-gradient(135deg, #4d74ff 0%, #e546ff 100%); | ||
--gradient-sunset: linear-gradient(315deg, #ffb571 0%, #f2000f 100%); | ||
--gradient-sunshine: linear-gradient(135deg, #ff7200 0%, #f5d00b 100%); | ||
--gradient-gold: linear-gradient(315deg, #f1d18c 0%, #da9c3b 100%); | ||
--gradient-foliage: linear-gradient(135deg, #09ab8b 0%, #a9e007 100%); | ||
--gradient-sky: linear-gradient(135deg, #3777fe 0%, #21e3e4 100%); | ||
--gradient-polar-light: linear-gradient(135deg, #46007c 0%, #008dc9 100%); | ||
--gradient-night: linear-gradient(135deg, #0f0f0f 0%, #757575 100%); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// GENERATED FILE - DO NOT CHANGE IT MANUALLY | ||
|
||
/** Градиенты дизайн-системы. */ | ||
export const GRADIENT = { | ||
sunrise: 'linear-gradient(135deg, #bf16af 0%, #ff9b8d 100%)', | ||
twilight: 'linear-gradient(135deg, #4d74ff 0%, #e546ff 100%)', | ||
sunset: 'linear-gradient(315deg, #ffb571 0%, #f2000f 100%)', | ||
sunshine: 'linear-gradient(135deg, #ff7200 0%, #f5d00b 100%)', | ||
gold: 'linear-gradient(315deg, #f1d18c 0%, #da9c3b 100%)', | ||
foliage: 'linear-gradient(135deg, #09ab8b 0%, #a9e007 100%)', | ||
sky: 'linear-gradient(135deg, #3777fe 0%, #21e3e4 100%)', | ||
'polar-light': 'linear-gradient(135deg, #46007c 0%, #008dc9 100%)', | ||
night: 'linear-gradient(135deg, #0f0f0f 0%, #757575 100%)', | ||
} as const; | ||
|
||
export const GRADIENTS = new Map(Object.entries(GRADIENT)) as Map<keyof typeof GRADIENT, string>; |