UNPKG

lore-ui

Version:

Package used to perform Lore stylization.

52 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.icons = void 0; /* eslint-disable max-len */ const colors_1 = require("../colors"); const utils_1 = require("../utils"); const icon_base_1 = require("./icon-base"); // TODO: verificar como passar o parâmetro size de forma opcional assim como cor e tom const setSize = (icon, color) => new Proxy({}, { get(_, iconSize) { const size = Number(typeof iconSize === 'string' ? iconSize : undefined) || utils_1.ICON_SIZE_DEFAULT; return (0, utils_1.toBase64)(icon(color, size)); }, }); const setTone = (icon, color) => new Proxy(color, { get(toneTarget, toneName) { // TODO: verificar um forma de retornar somente a cor caso não tem um tom declarado ou o mesmo esteja vazio '' // if (!toneName) { // return toBase64(icon()) // } const tone = toneTarget[toneName] || toneTarget['900']; if (typeof tone === 'string' && (0, utils_1.isValidColor)(tone)) { return (0, utils_1.toBase64)(icon(tone)); // setSize(icon, tone) } return setSize(icon, color); }, }); const setColor = (icon) => new Proxy({}, { get(_, colorName) { if (!colorName) { return (0, utils_1.toBase64)(icon()); } const color = colors_1.colorBase[colorName]; if (!color) { throw new Error(`Color "${colorName}" not found`); } if (typeof color === 'string' && (0, utils_1.isValidColor)(color)) { return (0, utils_1.toBase64)(icon(color)); // setSize(icon, color) } return setTone(icon, color); }, }); exports.icons = new Proxy(icon_base_1.iconBase, { get(iconTarget, iconName) { const icon = iconTarget[iconName]; if (!icon) { throw new Error(`Icon "${iconName}" not found`); } return setColor(icon); }, }); //# sourceMappingURL=icon.js.map