typestyle / typestyle

Making CSS Typesafe 🌹

Home Page:https://typestyle.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csx: color(str) doesn't work with named colors (like 'black', 'green', etc.)

ehahn9 opened this issue · comments

import { color } from 'csx';

const foo = color('#000')   // => GOOD: rgb(0, 0, 0)
const bar = color('black')  // => BAD: rgb(255, 0, 0)

The docs don't claim to support named colors, but the argument type implies it should:

export declare function color(value: ColorProperty): ColorHelper;
export type ColorProperty = Globals | Color;
type Color = NamedColor | DeprecatedSystemColor | "currentcolor" | string;
commented

Named colors were originally supported but removed sometime over a year ago. Providing the definitions for all named colors made CSX unnecessarily heavy. In general, it is pretty easy to look up the hex, rgb, and hsl for named colors, so this was a technical tradeoff.