Skip to content

Commit c61f716

Browse files
committed
✨ app: feat: use colors from firefox
1 parent 4c33206 commit c61f716

18 files changed

+1540
-129
lines changed

app/scripts/gen-files.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const optionsList: GenFilesOptions[] = [
4545
},
4646
];
4747

48-
Promise.all(optionsList.map(genFiles)).catch((e: Error) => {
48+
Promise.all([genVariables(), ...optionsList.map(genFiles)]).catch((e: Error) => {
4949
/* eslint-disable no-console */
5050
console.error(e.message);
5151
console.error(e.stack);

app/scripts/gen-variables.ts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint-disable no-console */
2+
import * as io from '@rimtrans/io';
3+
4+
async function genColors(): Promise<void> {
5+
const colorsJson: Record<string, Record<string, string>> = await io.load(
6+
io.join(__dirname, 'variables', 'colors.json'),
7+
);
8+
9+
const blocks: [string, string][][] = [];
10+
11+
Object.entries(colorsJson).forEach(([name, map]) => {
12+
const block: [string, string][] = [];
13+
blocks.push(block);
14+
15+
Object.keys(map)
16+
.sort()
17+
.forEach(level => {
18+
const color = map[level];
19+
block.push([`--color-${name}-${level}`, color]);
20+
});
21+
22+
Object.keys(map)
23+
.sort()
24+
.forEach(level => {
25+
const color = map[level];
26+
const hex = color.replace('#', '');
27+
const [r, g, b] = [[0, 2], [2, 4], [4, 6]].map(([start, end]) =>
28+
Number.parseInt(hex.substring(start, end), 16),
29+
);
30+
const alphaBlock: [string, string][] = [];
31+
blocks.push(alphaBlock);
32+
for (let index = 1; index <= 9; index++) {
33+
alphaBlock.push([
34+
`--color-${name}-${level}-a${index * 10}`,
35+
`rgba(${r}, ${g}, ${b}, ${index / 10})`,
36+
]);
37+
}
38+
});
39+
});
40+
41+
const content = blocks
42+
.map(block => block.map(([name, value]) => ` ${name}: ${value};`).join('\n'))
43+
.join('\n\n');
44+
45+
const wrap = `%variables-color-palette {\n${content}\n}\n`;
46+
47+
await io.save(
48+
io.join(
49+
__dirname,
50+
'..',
51+
'src',
52+
'renderer',
53+
'components',
54+
'base',
55+
'variables-color-palette.scss',
56+
),
57+
wrap,
58+
);
59+
}
60+
61+
export async function genVariables(): Promise<void> {
62+
await Promise.all([genColors()]);
63+
}

app/scripts/variables/colors.json

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"green": {
3+
"05": "#e3fff3",
4+
"10": "#d0ffed",
5+
"20": "#b3ffe3",
6+
"30": "#87ffd1",
7+
"40": "#53ffbc",
8+
"50": "#3fe1b0",
9+
"60": "#2ac4a2",
10+
"70": "#018788",
11+
"80": "#005e5e",
12+
"90": "#084036"
13+
},
14+
"blue": {
15+
"05": "#abf1fe",
16+
"10": "#80ebff",
17+
"20": "#01ddff",
18+
"30": "#00b3f5",
19+
"40": "#0090ed",
20+
"50": "#0160e0",
21+
"60": "#0250bc",
22+
"70": "#063f96",
23+
"80": "#073072",
24+
"90": "#09204c"
25+
},
26+
"purple": {
27+
"05": "#e6dfff",
28+
"10": "#d9bfff",
29+
"20": "#cb9dff",
30+
"30": "#c588ff",
31+
"40": "#ac71ff",
32+
"50": "#9059ff",
33+
"60": "#7543e4",
34+
"70": "#582acb",
35+
"80": "#46278e",
36+
"90": "#321c64"
37+
},
38+
"violet": {
39+
"05": "#f7e3ff",
40+
"10": "#f6b9ff",
41+
"20": "#f690ff",
42+
"30": "#f564ff",
43+
"40": "#d74cf0",
44+
"50": "#b933e0",
45+
"60": "#952bb9",
46+
"70": "#722291",
47+
"80": "#4f1a6a",
48+
"90": "#2b1141"
49+
},
50+
"magenta": {
51+
"05": "#ffdff0",
52+
"10": "#ffb4db",
53+
"20": "#ff8ac6",
54+
"30": "#ff6aba",
55+
"40": "#fe4aa2",
56+
"50": "#ff2a8a",
57+
"60": "#e11586",
58+
"70": "#c60184",
59+
"80": "#7f165b",
60+
"90": "#50134c"
61+
},
62+
"red": {
63+
"05": "#fedfe7",
64+
"10": "#ffbec6",
65+
"20": "#ff9aa2",
66+
"30": "#ff848c",
67+
"40": "#ff6a75",
68+
"50": "#ff4f5f",
69+
"60": "#e12851",
70+
"70": "#c40042",
71+
"80": "#810220",
72+
"90": "#440307"
73+
},
74+
"orange": {
75+
"05": "#fff4de",
76+
"10": "#ffd5b2",
77+
"20": "#ffb587",
78+
"30": "#ffa265",
79+
"40": "#fe8a4f",
80+
"50": "#ff7139",
81+
"60": "#e25821",
82+
"70": "#cd3d00",
83+
"80": "#9e280c",
84+
"90": "#7b1604"
85+
},
86+
"yellow": {
87+
"05": "#ffffcc",
88+
"10": "#feff98",
89+
"20": "#ffea80",
90+
"30": "#ffd567",
91+
"40": "#ffbd4f",
92+
"50": "#ffa537",
93+
"60": "#e27f2e",
94+
"70": "#c45a28",
95+
"80": "#a7341f",
96+
"90": "#960e18"
97+
},
98+
"grey": {
99+
"10": "#f9f9fa",
100+
"20": "#ededf0",
101+
"30": "#d7d7db",
102+
"40": "#b1b1b3",
103+
"50": "#737373",
104+
"60": "#4a4a4f",
105+
"70": "#38383d",
106+
"80": "#2a2a2e",
107+
"90": "#0c0c0d"
108+
}
109+
}

app/src/renderer/components/atom/theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Component: Theme
33
*/
4-
@each $theme in $type-themes {
4+
@each $theme in $type-color-themes {
55
@include comp('theme-#{$theme}') {
66
@extend %variables-theme-#{$theme};
77
}

0 commit comments

Comments
 (0)