-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-buttons.cjs
More file actions
57 lines (49 loc) · 2.22 KB
/
Copy pathupdate-buttons.cjs
File metadata and controls
57 lines (49 loc) · 2.22 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require('fs');
const path = require('path');
const cssPath = path.join(__dirname, 'src', 'index.css');
let css = fs.readFileSync(cssPath, 'utf8');
// The new gradients for buttons
const redBlackBtn = 'linear-gradient(90deg, #ff0000, #1a0000)';
const redBlackBtnHover = 'linear-gradient(90deg, #cc0000, #000000)';
// We want to replace backgrounds for specific button classes
const buttonSelectors = [
'.verify-btn',
'.resume-btn',
'button',
'.btn', // generic if any
'.project-link',
'.github-link'
];
// Actually, let's just do a string replacement for the exact blocks where buttons are defined.
// The easiest way is to search for `#ff0000, #ff4444` and `#cc0000, #dd3333` and replace them.
// But we want to avoid changing text gradients like in `h1` or `h2`.
// Usually, text gradients have `-webkit-background-clip: text;` right after or before.
// We can use a regex that matches background: linear-gradient(...) BUT ensure we aren't in a block with background-clip.
// Let's just find and replace by parsing line by line.
let lines = css.split('\n');
let insideButtonOrLink = false;
for (let i = 0; i < lines.length; i++) {
// Basic heuristic: if the line contains background: linear-gradient
if (lines[i].includes('background: linear-gradient')) {
// Look ahead in the next 3 lines to see if it's text-clipped
let isTextClipped = false;
for (let j = 0; j <= 5 && i + j < lines.length; j++) {
if (lines[i+j].includes('background-clip: text')) {
isTextClipped = true;
break;
}
}
if (!isTextClipped) {
// It's likely a button, progress bar, or background.
// Let's only replace the specific bright red/pink gradient.
if (lines[i].includes('#ff0000, #ff4444')) {
lines[i] = lines[i].replace('linear-gradient(90deg, #ff0000, #ff4444)', redBlackBtn);
}
if (lines[i].includes('#cc0000, #dd3333')) {
lines[i] = lines[i].replace('linear-gradient(90deg, #cc0000, #dd3333)', redBlackBtnHover);
}
}
}
}
fs.writeFileSync(cssPath, lines.join('\n'));
console.log('Button gradients updated to red and black.');