How to use the @microsoft/fast-colors.parseColorWebRGB function in @microsoft/fast-colors

To help you get started, we’ve selected a few @microsoft/fast-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / color / common.ts View on Github external
(color: string): ColorRGBA64 => {
        let parsed: ColorRGBA64 | null = parseColorHexRGB(color);

        if (parsed !== null) {
            return parsed;
        }

        parsed = parseColorWebRGB(color);

        if (parsed !== null) {
            return parsed;
        }

        throw new Error(
            `${color} cannot be converted to a ColorRGBA64. Color strings must be one of the following formats: "#RGB", "#RRGGBB", or "rgb(r, g, b)"`
        );
    }
);