UNPKG

934 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getColorFromString = void 0;
4var tslib_1 = require("tslib");
5var cssColor_1 = require("./cssColor");
6var getColorFromRGBA_1 = require("./getColorFromRGBA");
7/**
8 * Converts a CSS color string to a color object.
9 * Note that hex colors *must* be prefixed with # to be considered valid.
10 *
11 * `inputColor` will be used unmodified as the `str` property of the returned object.
12 * Alpha defaults to 100 if not specified in `inputColor`.
13 * Returns undefined if the color string is invalid/not recognized.
14 */
15function getColorFromString(inputColor) {
16 var color = cssColor_1.cssColor(inputColor);
17 if (!color) {
18 return;
19 }
20 return tslib_1.__assign(tslib_1.__assign({}, getColorFromRGBA_1.getColorFromRGBA(color)), { str: inputColor });
21}
22exports.getColorFromString = getColorFromString;
23//# sourceMappingURL=getColorFromString.js.map
\No newline at end of file