How to use the @microsoft/fast-colors.parseColor 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-react-msft / app / app.tsx View on Github external
private getNeutralPallete(colorSource: string): string[] {
        const color: ColorRGBA64 = parseColor(colorSource);
        const hslColor: ColorHSL = rgbToHSL(color);
        const augmentedHSLColor: ColorHSL = ColorHSL.fromObject({
            h: hslColor.h,
            s: hslColor.s,
            l: 0.5,
        });
        return createColorPalette(hslToRGB(augmentedHSLColor));
    }
github microsoft / fast-dna / packages / fast-component-explorer / app / explorer-region.tsx View on Github external
import React from "react";
import { DesignSystemProvider } from "@microsoft/fast-jss-manager-react";
import { ColorRGBA64, parseColor } from "@microsoft/fast-colors";
import {
    createColorPalette,
    DesignSystem,
    DesignSystemDefaults,
} from "@microsoft/fast-components-styles-msft";
import Explorer from "./explorer";
import { StandardLuminance } from "@microsoft/fast-components-styles-msft";

const accent: string = "#FB356D";
const accentPaletteSource: ColorRGBA64 | null = parseColor(accent);
let creatorDesignSystem: DesignSystem = DesignSystemDefaults;

if (accentPaletteSource !== null) {
    const palette: string[] = createColorPalette(accentPaletteSource);
    creatorDesignSystem = Object.assign({}, DesignSystemDefaults, {
        density: -2,
        accentBaseColor: accent,
        accentPalette: palette,
        baseLayerLuminance: StandardLuminance.DarkMode,
    });
}

class ExplorerRegion extends React.Component<{}, {}> {
    public render(): React.ReactNode {
        return (
github microsoft / fast-dna / packages / fast-components-react-msft / app / app.tsx View on Github external
const updates: Partial = { ...config };

        if (config.backgroundColor !== this.state.backgroundColor) {
            if (this.state.theme !== ThemeName.custom) {
                updates.theme = ThemeName.custom;
            }

            updates.designSystem = Object.assign({}, this.state.designSystem, {
                neutralPalette: this.getNeutralPallete(config.backgroundColor),
            });
            updates.designSystem.backgroundColor = config.backgroundColor;
        }

        if (config.accentColor !== this.state.accentColor) {
            updates.designSystem = Object.assign({}, this.state.designSystem, {
                accentPalette: createColorPalette(parseColor(config.accentColor)),
                accentBaseColor: config.accentColor,
            });
        }

        this.setState(updates as AppState);
    };
github microsoft / fast-dna / packages / fast-components-react-msft / app / app.tsx View on Github external
constructor(props: {}) {
        super(props);

        this.state = {
            accentColor: accent,
            designSystem: Object.assign({}, DesignSystemDefaults, {
                accentPalette: createColorPalette(parseColor(accent)),
                accentBaseColor: accent,
                neutralPalette: createColorPalette(parseColor("#808080")),
                direction: Direction.ltr,
            }),
            backgroundColor: DesignSystemDefaults.backgroundColor,
            theme: ThemeName.light,
        };
    }
github microsoft / fast-dna / packages / fast-storybook-design-system-addon / src / panel.tsx View on Github external
private handleAccentBaseChange(
        e: React.ChangeEvent
    ): Partial {
        const value: string = e.target.value;
        const parsed: ColorRGBA64 | null = parseColor(value);

        return parsed !== null
            ? {
                  accentBaseColor: value,
                  accentPalette: createColorPalette(parsed),
              }
            : {};
    }
}
github microsoft / fast-dna / packages / fast-components-react-msft / app / app.tsx View on Github external
constructor(props: {}) {
        super(props);

        this.state = {
            accentColor: accent,
            designSystem: Object.assign({}, DesignSystemDefaults, {
                accentPalette: createColorPalette(parseColor(accent)),
                accentBaseColor: accent,
                neutralPalette: createColorPalette(parseColor("#808080")),
                direction: Direction.ltr,
            }),
            backgroundColor: DesignSystemDefaults.backgroundColor,
            theme: ThemeName.light,
        };
    }