-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_css2.cjs
More file actions
29 lines (26 loc) · 1.32 KB
/
Copy pathpatch_css2.cjs
File metadata and controls
29 lines (26 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
let content = fs.readFileSync('src/index.css', 'utf8');
const regexRoot = /:root\s*\{([^}]*)\}/;
let rootMatch = content.match(regexRoot);
if (rootMatch) {
let rootContent = rootMatch[1]
.replace(/--theme-bg: #[0-9A-Fa-f]+;/g, '--theme-bg: #000000;')
.replace(/--theme-surface: #[0-9A-Fa-f]+;/g, '--theme-surface: #09090b;')
.replace(/--theme-card: #[0-9A-Fa-f]+;/g, '--theme-card: #09090b;')
.replace(/--theme-card-hover: #[0-9A-Fa-f]+;/g, '--theme-card-hover: #18181b;')
.replace(/--theme-border: #[0-9A-Fa-f]+;/g, '--theme-border: #27272a;');
content = content.replace(rootMatch[0], `:root {${rootContent}}`);
}
const regexBlue = /\[data-theme="blue"\]\s*\{([^}]*)\}/;
let blueMatch = content.match(regexBlue);
if (blueMatch) {
let blueContent = blueMatch[1]
.replace(/--theme-bg: #[0-9A-Fa-f]+;/g, '--theme-bg: #000000;')
.replace(/--theme-surface: #[0-9A-Fa-f]+;/g, '--theme-surface: #09090b;')
.replace(/--theme-card: #[0-9A-Fa-f]+;/g, '--theme-card: #09090b;')
.replace(/--theme-card-hover: #[0-9A-Fa-f]+;/g, '--theme-card-hover: #18181b;')
.replace(/--theme-border: #[0-9A-Fa-f]+;/g, '--theme-border: #27272a;');
content = content.replace(blueMatch[0], `[data-theme="blue"] {${blueContent}}`);
}
fs.writeFileSync('src/index.css', content);
console.log("Patched CSS");