UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

77 lines (76 loc) 3.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppletIcon = exports.appletIconStencil = exports.appletIconStyles = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const tokens_1 = require("@workday/canvas-kit-react/tokens"); const design_assets_types_1 = require("@workday/design-assets-types"); const Svg_1 = require("./Svg"); const common_1 = require("@workday/canvas-kit-react/common"); const canvas_kit_styling_1 = require("@workday/canvas-kit-styling"); const canvas_tokens_web_1 = require("@workday/canvas-tokens-web"); /** * @deprecated `appletIconStyles` will be removed in in a future version as a part of implementation of stencils and new tokens. Consider to use `appletIconStencil` instead. */ const appletIconStyles = ({ color = tokens_1.BrandingColor.Blueberry, }) => { // Check if valid color if (!Object.keys(tokens_1.BrandingColor) .map(color => tokens_1.BrandingColor[color]) .includes(color)) { throw Error(`Color "${color}" not found`); } const colorNames = { 100: `${color}100`, 200: `${color}200`, 300: `${color}300`, 400: `${color}400`, 500: `${color}500`, }; return { '& .color-100': { fill: canvas_tokens_web_1.system.color.fg.inverse, }, '& .color-200': { fill: tokens_1.colors[colorNames[200]], }, '& .color-300': { fill: tokens_1.colors[colorNames[300]], }, '& .color-400': { fill: tokens_1.colors[colorNames[400]], }, '& .color-400-alpha-20': { fill: tokens_1.colors[colorNames[400]], }, '& .color-500': { fill: tokens_1.colors[colorNames[500]], }, }; }; exports.appletIconStyles = appletIconStyles; exports.appletIconStencil = (0, canvas_kit_styling_1.createStencil)({ extends: Svg_1.svgStencil, vars: { color200: '', color300: '', color400: '', color500: '', }, base: { name: "18fu73", styles: "box-sizing:border-box;--size-svg-8fcab8:5.75rem;& .color-100{fill:var(--cnvs-sys-color-fg-inverse);}& .color-200{fill:var(--color200-applet-icon-c96fac, var(--cnvs-base-palette-blue-200));}& .color-300{fill:var(--color300-applet-icon-c96fac, var(--cnvs-base-palette-blue-400));}& .color-400{fill:var(--color400-applet-icon-c96fac, var(--cnvs-base-palette-blue-600));}& .color-400-alpha-20{fill:var(--color400-applet-icon-c96fac, var(--cnvs-base-palette-blue-600));}& .color-500{fill:var(--color500-applet-icon-c96fac, var(--cnvs-base-palette-blue-700));}" } }, "applet-icon-c96fac"); exports.AppletIcon = (0, common_1.createComponent)('span')({ displayName: 'AppletIcon', Component: ({ size, icon, color, ...elemProps }, ref, Element) => { const colors = color && { color200: canvas_tokens_web_1.base[`${color}200`], color300: canvas_tokens_web_1.base[`${color}300`], color400: canvas_tokens_web_1.base[`${color}400`], color500: canvas_tokens_web_1.base[`${color}500`], }; return ((0, jsx_runtime_1.jsx)(Svg_1.Svg, { src: icon, type: design_assets_types_1.CanvasIconTypes.Applet, as: Element, ref: ref, ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, [ (0, exports.appletIconStencil)({ ...colors, size: size ? (0, canvas_kit_styling_1.px2rem)(size) : undefined }), ]) })); }, subComponents: { Colors: tokens_1.BrandingColor, }, });