@fluentui/react
Version:
Reusable React components for building web experiences.
22 lines • 1.14 kB
JavaScript
define(["require", "exports", "tslib", "@fluentui/utilities", "./cssColor", "./getColorFromRGBA"], function (require, exports, tslib_1, utilities_1, cssColor_1, getColorFromRGBA_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getColorFromString = getColorFromString;
/**
* 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.
*/
function getColorFromString(inputColor, doc) {
var theDoc = doc !== null && doc !== void 0 ? doc : (0, utilities_1.getDocument)();
var color = (0, cssColor_1.cssColor)(inputColor, theDoc);
if (!color) {
return;
}
return tslib_1.__assign(tslib_1.__assign({}, (0, getColorFromRGBA_1.getColorFromRGBA)(color)), { str: inputColor });
}
});
//# sourceMappingURL=getColorFromString.js.map