UNPKG

@thi.ng/color

Version:

Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets

58 lines 2.13 kB
import type { Fn } from "@thi.ng/api"; import type { ColorMode, IParsedColor, MaybeColor } from "../api.js"; export type CSSConversions = Partial<Record<ColorMode, Fn<any, string>>>; /** * CSS Color Module Level 3 compatible color conversion rules. * * @remarks * Initial default setting for {@link css}. Also see * {@link setDefaultCSSConversions} to change default. * * Reference: * https://www.w3.org/TR/css-color-3/ */ export declare const CSS_LEVEL3: CSSConversions; /** * Extended set of direct CSS conversions for use with CSS Color Module Level 4. * Based on {@link CSS_LEVEL3} and used for {@link css}. * * @remarks * Use {@link setDefaultCSSConversions} to use as default. * * Reference: * https://www.w3.org/TR/css-color-4/ */ export declare const CSS_LEVEL4: CSSConversions; /** * Sets the default set of {@link CSSConversions} functions used by {@link css}. * The default is {@link CSS_LEVEL3}, but {@link CSS_LEVEL4} is also available * and will provide better (direct) support for newer color spaces like * {@link lch}, {@link oklab} or {@link oklch}. * * @param fns */ export declare const setDefaultCSSConversions: (fns: CSSConversions) => Partial<Record<ColorMode, Fn<any, string>>>; /** * Takes a color in one of the following formats and tries to convert it to a * CSS string. * * @remarks * The following input formats are supported: * * - any {@link TypedColor} instance * - raw sRGB(A) vector * - number (packed 0xaarrggbb int, MUST provide alpha channel) * - string (passthrough) * * If CSS Color Module Level 4 support is desired, pass {@link CSS_LEVEL4} as * 2nd argument or call {@link setDefaultCSSConversions}. If no `cssTarget` is * given, uses current configured default (initially {@link CSS_LEVEL3}). * * If no direct conversion route for a given source color mode exists, the color * will be first converted to sRGB and serialized as such. * * @param col - source color * @param cssTarget - CSS conversions */ export declare const css: (src: Exclude<MaybeColor, IParsedColor>, cssTarget?: CSSConversions) => string; //# sourceMappingURL=css.d.ts.map