UNPKG

@fluentui/react

Version:

Reusable React components for building web experiences.

21 lines 867 B
import { __assign } from "tslib"; import { getDocument } from '@fluentui/utilities'; import { cssColor } from './cssColor'; import { getColorFromRGBA } from './getColorFromRGBA'; /** * Converts a CSS color string to a color object. * Note that hex colors *must* be prefixed with # to be considered valid. * * `inputColor` will be used unmodified as the `str` property of the returned object. * Alpha defaults to 100 if not specified in `inputColor`. * Returns undefined if the color string is invalid/not recognized. */ export function getColorFromString(inputColor, doc) { var theDoc = doc !== null && doc !== void 0 ? doc : getDocument(); var color = cssColor(inputColor, theDoc); if (!color) { return; } return __assign(__assign({}, getColorFromRGBA(color)), { str: inputColor }); } //# sourceMappingURL=getColorFromString.js.map