UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

49 lines (48 loc) 1.86 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { validateIconType } from './utils'; import { createComponent } from '@workday/canvas-kit-react/common'; import { mergeStyles } from '@workday/canvas-kit-react/layout'; import { createStencil, cssVar } from '@workday/canvas-kit-styling'; import { base } from '@workday/canvas-tokens-web'; export const svgStencil = createStencil({ vars: { /** sets width of svg element */ width: '', /** sets height of svg element */ height: '', /** sets width and height of svg element */ size: '', }, base: { name: "48jfep", styles: "box-sizing:border-box;display:inline-block;> svg{display:block;width:var(--width-svg-8fcab8, var(--size-svg-8fcab8));height:var(--height-svg-8fcab8, var(--size-svg-8fcab8));}" }, modifiers: { shouldMirror: { true: { name: "1f7igi", styles: "transform:scaleX(-1);" } }, shouldMirrorInRTL: { true: { name: "463u39", styles: "&:dir(rtl){transform:scaleX(-1);}" } } } }, "svg-8fcab8"); /** @deprecated */ export const transformColorNameToToken = (color) => { if (color && color in base) { return cssVar(base[color]); } if (color === null || color === void 0 ? void 0 : color.startsWith('--')) { return cssVar(color); } return color; }; export const Svg = createComponent('span')({ displayName: 'Svg', Component: ({ shouldMirror, shouldMirrorInRTL, src, type, ...elemProps }, ref, Element) => { try { validateIconType(src, type); } catch (e) { console.error(e); return null; } return (_jsx(Element, { ref: ref, dangerouslySetInnerHTML: { __html: src.svg }, ...mergeStyles(elemProps, svgStencil({ shouldMirror, shouldMirrorInRTL })) })); }, });