You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
993 B
39 lines
993 B
import { defaultIconProps } from '../icon/defaults.mjs';
|
|
import { getCommonCSSRules, generateItemCSSRules } from './common.mjs';
|
|
import { formatCSS } from './format.mjs';
|
|
import '../svg/html.mjs';
|
|
import '../svg/size.mjs';
|
|
import '../svg/url.mjs';
|
|
|
|
function getIconCSS(icon, options = {}) {
|
|
const mode = options.mode || (options.color || !icon.body.includes("currentColor") ? "background" : "mask");
|
|
let varName = options.varName;
|
|
if (varName === void 0 && mode === "mask") {
|
|
varName = "svg";
|
|
}
|
|
const newOptions = {
|
|
...options,
|
|
// Override mode and varName
|
|
mode,
|
|
varName
|
|
};
|
|
if (mode === "background") {
|
|
delete newOptions.varName;
|
|
}
|
|
const rules = {
|
|
...getCommonCSSRules(newOptions),
|
|
...generateItemCSSRules({ ...defaultIconProps, ...icon }, newOptions)
|
|
};
|
|
const selector = options.iconSelector || ".icon";
|
|
return formatCSS(
|
|
[
|
|
{
|
|
selector,
|
|
rules
|
|
}
|
|
],
|
|
newOptions.format
|
|
);
|
|
}
|
|
|
|
export { getIconCSS };
|
|
|