* Generate a Tailwind color shades from a variable.
(varName: string, filter: ColorCategory[] = [])
| 14 | * Generate a Tailwind color shades from a variable. |
| 15 | */ |
| 16 | function generateVarShades(varName: string, filter: ColorCategory[] = []) { |
| 17 | const result: { [key: string]: string } = {}; |
| 18 | |
| 19 | for (const [categoryName, category] of Object.entries(scale)) { |
| 20 | if (filter.length === 0 || filter.includes(categoryName as ColorCategory)) { |
| 21 | for (const [key, value] of Object.entries(category)) { |
| 22 | if (filter.length > 0) { |
| 23 | result[key] = `rgb(var(--${varName}-${value}))`; |
| 24 | } else { |
| 25 | result[value] = `rgb(var(--${varName}-${value}))`; |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return result; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Generate a Tailwind color shades from a HEX color. |