|
1 | 1 | import type { CSSProperties } from 'vue' |
2 | | -import { colors } from '@unocss/preset-mini' |
| 2 | +// import { colors } from '@unocss/preset-mini' |
3 | 3 |
|
4 | | -export function resolveColor(colorName: string, defaultColor: string = '#000000'): string { |
5 | | - // If the input is already a hex code, return it |
6 | | - if (/^#([0-9A-F]{3}){1,2}$/i.test(colorName)) { |
7 | | - return colorName |
8 | | - } |
| 4 | +// export function resolveColor(colorName: string, defaultColor: string = '#000000'): string { |
| 5 | +// // If the input is already a hex code, return it |
| 6 | +// if (/^#([0-9A-F]{3}){1,2}$/i.test(colorName)) { |
| 7 | +// return colorName |
| 8 | +// } |
9 | 9 |
|
10 | | - // Split the color name into base and shade |
11 | | - const [baseColor, shade] = colorName.toLowerCase().split('-') |
| 10 | +// // Split the color name into base and shade |
| 11 | +// const [baseColor, shade] = colorName.toLowerCase().split('-') |
12 | 12 |
|
13 | | - // Function to find the color in the colors object |
14 | | - function findColor(obj: any, base: string, shade?: string): string | null { |
15 | | - if (base in obj) { |
16 | | - if (shade && typeof obj[base] === 'object' && shade in obj[base]) { |
17 | | - return obj[base][shade] |
18 | | - } else if (!shade && typeof obj[base] === 'string') { |
19 | | - return obj[base] |
20 | | - } |
21 | | - } |
| 13 | +// // Function to find the color in the colors object |
| 14 | +// function findColor(obj: any, base: string, shade?: string): string | null { |
| 15 | +// if (base in obj) { |
| 16 | +// if (shade && typeof obj[base] === 'object' && shade in obj[base]) { |
| 17 | +// return obj[base][shade] |
| 18 | +// } else if (!shade && typeof obj[base] === 'string') { |
| 19 | +// return obj[base] |
| 20 | +// } |
| 21 | +// } |
22 | 22 |
|
23 | | - for (const value of Object.values(obj)) { |
24 | | - if (typeof value === 'object' && value !== null) { |
25 | | - const result = findColor(value, base, shade) |
26 | | - if (result) return result |
27 | | - } |
28 | | - } |
| 23 | +// for (const value of Object.values(obj)) { |
| 24 | +// if (typeof value === 'object' && value !== null) { |
| 25 | +// const result = findColor(value, base, shade) |
| 26 | +// if (result) return result |
| 27 | +// } |
| 28 | +// } |
29 | 29 |
|
30 | | - return null |
31 | | - } |
| 30 | +// return null |
| 31 | +// } |
32 | 32 |
|
33 | | - // Search for the color in the UnoCSS colors object |
34 | | - const hexCode = findColor(colors, baseColor, shade) |
| 33 | +// // Search for the color in the UnoCSS colors object |
| 34 | +// const hexCode = findColor(colors, baseColor, shade) |
35 | 35 |
|
36 | | - // If a valid color is found, return its hex code; otherwise, return the default color |
37 | | - return hexCode || defaultColor |
38 | | -} |
| 36 | +// // If a valid color is found, return its hex code; otherwise, return the default color |
| 37 | +// return hexCode || defaultColor |
| 38 | +// } |
39 | 39 |
|
40 | 40 | /** |
41 | 41 | * Resolve urls from frontmatter and append with the base url |
|
0 commit comments