|
1 | 1 | // lib/svg/themes.ts |
2 | 2 | import { BadgeTheme } from '../../types'; |
| 3 | +import { hexColor } from './sanitizer'; |
| 4 | + |
| 5 | +function makeTheme(bg: string, text: string, accent: string): BadgeTheme { |
| 6 | + return { |
| 7 | + bg: hexColor(bg), |
| 8 | + text: hexColor(text), |
| 9 | + accent: hexColor(accent), |
| 10 | + }; |
| 11 | +} |
3 | 12 |
|
4 | 13 | export const themes: Record<string, BadgeTheme> = { |
5 | | - dark: { |
6 | | - bg: '0d1117', |
7 | | - text: 'c9d1d9', |
8 | | - accent: '58a6ff', |
9 | | - }, |
10 | | - light: { |
11 | | - bg: 'ffffff', |
12 | | - text: '24292f', |
13 | | - accent: '0969da', |
14 | | - }, |
15 | | - neon: { |
16 | | - bg: '000000', |
17 | | - text: '00ffcc', |
18 | | - accent: 'ff00ff', |
19 | | - }, |
20 | | - github: { |
21 | | - bg: '0d1117', |
22 | | - text: 'ffffff', |
23 | | - accent: '238636', // The classic green |
24 | | - }, |
25 | | - dracula: { |
26 | | - bg: '282a36', |
27 | | - text: 'f8f8f2', |
28 | | - accent: 'bd93f9', |
29 | | - }, |
30 | | - ocean: { |
31 | | - bg: '0a192f', |
32 | | - text: 'ccd6f6', |
33 | | - accent: '64ffda', |
34 | | - }, |
35 | | - sunset: { |
36 | | - bg: '1a0a0a', |
37 | | - text: 'ffd6c0', |
38 | | - accent: 'ff6b35', |
39 | | - }, |
40 | | - forest: { |
41 | | - bg: '0d1f0d', |
42 | | - text: 'c8f0c8', |
43 | | - accent: '39d353', |
44 | | - }, |
45 | | - rose: { |
46 | | - bg: '1f0d14', |
47 | | - text: 'f0c8d4', |
48 | | - accent: 'ff6b9d', |
49 | | - }, |
50 | | - nord: { |
51 | | - bg: '2e3440', |
52 | | - text: 'd8dee9', |
53 | | - accent: '88c0d0', |
54 | | - }, |
55 | | - synthwave: { |
56 | | - bg: '0d0221', |
57 | | - text: 'f8f8f2', |
58 | | - accent: 'ff2d78', |
59 | | - }, |
60 | | - gruvbox: { |
61 | | - bg: '282828', |
62 | | - text: 'ebdbb2', |
63 | | - accent: 'fe8019', |
64 | | - }, |
65 | | - highcontrast: { |
66 | | - bg: '0a0a0a', // High-contrast theme: vivid red-orange accent on near-black background. |
67 | | - text: '888888', |
68 | | - accent: 'ff4500', |
69 | | - }, |
| 14 | + dark: makeTheme('0d1117', 'c9d1d9', '58a6ff'), |
| 15 | + light: makeTheme('ffffff', '24292f', '0969da'), |
| 16 | + neon: makeTheme('000000', '00ffcc', 'ff00ff'), |
| 17 | + github: makeTheme('0d1117', 'ffffff', '238636'), |
| 18 | + dracula: makeTheme('282a36', 'f8f8f2', 'bd93f9'), |
| 19 | + ocean: makeTheme('0a192f', 'ccd6f6', '64ffda'), |
| 20 | + sunset: makeTheme('1a0a0a', 'ffd6c0', 'ff6b35'), |
| 21 | + forest: makeTheme('0d1f0d', 'c8f0c8', '39d353'), |
| 22 | + rose: makeTheme('1f0d14', 'f0c8d4', 'ff6b9d'), |
| 23 | + nord: makeTheme('2e3440', 'd8dee9', '88c0d0'), |
| 24 | + synthwave: makeTheme('0d0221', 'f8f8f2', 'ff2d78'), |
| 25 | + gruvbox: makeTheme('282828', 'ebdbb2', 'fe8019'), |
| 26 | + highcontrast: makeTheme('0a0a0a', '888888', 'ff4500'), |
70 | 27 | }; |
71 | 28 |
|
72 | 29 | // Auto-theme pairs: the SVG switches between these two palettes |
|
0 commit comments