|
| 1 | +import { TinyColor } from '@ctrl/tinycolor' |
| 2 | + |
| 3 | +export const getAlphaColor = (baseColor: string, alpha: number) => |
| 4 | + new TinyColor(baseColor).setAlpha(alpha).toRgbString() |
| 5 | + |
| 6 | +export const getSolidColor = (baseColor: string, brightness: number) => { |
| 7 | + const instance = new TinyColor(baseColor) |
| 8 | + return instance.darken(brightness).toHexString() |
| 9 | +} |
| 10 | + |
| 11 | +export const getTintColor = (baseColor: string, tintNumber: number) => { |
| 12 | + return new TinyColor(baseColor).tint(tintNumber).toString() |
| 13 | +} |
| 14 | + |
| 15 | +export const getShadeColor = (baseColor: string, shadeNumber: number) => { |
| 16 | + return new TinyColor(baseColor).shade(shadeNumber).toString() |
| 17 | +} |
| 18 | + |
| 19 | +export const getCssVarColor = (baseColor: string) => { |
| 20 | + return { |
| 21 | + '--bg-color': baseColor, |
| 22 | + '--bg-color-hover': getTintColor(baseColor, 10), |
| 23 | + '--bg-color-active': getTintColor(baseColor, 20), |
| 24 | + '--bg-color-content': '#ffffff', |
| 25 | + '--border-color': baseColor, |
| 26 | + '--border-color-hover': getTintColor(baseColor, 10), |
| 27 | + '--border-color-active': getTintColor(baseColor, 20), |
| 28 | + '--border-color-tint-10': getTintColor(baseColor, 10), |
| 29 | + '--border-color-tint-20': getTintColor(baseColor, 20), |
| 30 | + '--border-color-tint-30': getTintColor(baseColor, 30), |
| 31 | + '--border-color-tint-40': getTintColor(baseColor, 40), |
| 32 | + '--border-color-tint-50': getTintColor(baseColor, 50), |
| 33 | + '--border-color-tint-60': getTintColor(baseColor, 60), |
| 34 | + '--border-color-tint-70': getTintColor(baseColor, 70), |
| 35 | + '--border-color-tint-80': getTintColor(baseColor, 80), |
| 36 | + '--border-color-tint-90': getTintColor(baseColor, 90), |
| 37 | + '--bg-color-tint-10': getTintColor(baseColor, 10), |
| 38 | + '--bg-color-tint-20': getTintColor(baseColor, 20), |
| 39 | + '--bg-color-tint-30': getTintColor(baseColor, 30), |
| 40 | + '--bg-color-tint-40': getTintColor(baseColor, 40), |
| 41 | + '--bg-color-tint-50': getTintColor(baseColor, 50), |
| 42 | + '--bg-color-tint-60': getTintColor(baseColor, 60), |
| 43 | + '--bg-color-tint-70': getTintColor(baseColor, 70), |
| 44 | + '--bg-color-tint-80': getTintColor(baseColor, 80), |
| 45 | + '--bg-color-tint-90': getTintColor(baseColor, 90), |
| 46 | + '--text-color': baseColor, |
| 47 | + '--text-color-hover': getTintColor(baseColor, 10), |
| 48 | + '--text-color-active': getTintColor(baseColor, 20), |
| 49 | + } |
| 50 | +} |
0 commit comments