UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

40 lines (39 loc) 2.67 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { createComponent } from '@workday/canvas-kit-react/common'; import { createStencil, cssVar, handleCsProp } from '@workday/canvas-kit-styling'; import { CanvasIconTypes } from '@workday/canvas-system-icons-web'; import { component } from '@workday/canvas-tokens-web'; import { Svg, resolveSize, svgStencil } from './Svg'; export const systemIconStencil = createStencil({ extends: svgStencil, vars: { /** * This will set the icon's color (both `.wd-icon-fill` and `.wd-icon-accent` SVG layers). Most * of the time, this is the only color you need to change. Icons also have an accent layer. If you * wish to change the accent layer independently, also set the `accentColor` variable */ color: '', /** * This will set the icon's accent color for the `.wd-icon-accent` SVG layer. */ accentColor: '', /** * This will set the icon's background color for the `.wd-icon-background` SVG layer. */ backgroundColor: '', }, base: { name: "2eh3qd", styles: "box-sizing:border-box;& svg{width:var(--size-svg-bca693, var(--cnvs-component-system-icon-size-lg, var(--cnvs-sys-space-x6, 1.5rem)));height:var(--size-svg-bca693, var(--cnvs-component-system-icon-size-lg, var(--cnvs-sys-space-x6, 1.5rem)));}.wd-icon .wd-icon-fill{fill:var(--color-system-icon-c9acc3, var(--cnvs-component-system-icon-color-fill, var(--cnvs-sys-color-fg-default, oklch(0.3523 0 0 / 1))));}.wd-icon .wd-icon-accent, & .wd-icon-accent2{fill:var(--accentColor-system-icon-c9acc3, var(--color-system-icon-c9acc3, var(--cnvs-component-system-icon-color-accent, var(--cnvs-sys-color-fg-default, oklch(0.3523 0 0 / 1)))));}.wd-icon .wd-icon-background{fill:var(--backgroundColor-system-icon-c9acc3, transparent);}@media (prefers-contrast: more){.wd-icon .wd-icon-fill, .wd-icon .wd-icon-accent{color:currentColor;fill:currentColor;}}" }, // Keeps parent stencil `ME` inferred as `{}` so extending stencils keep correct boolean modifier typings. modifiers: {} }, "system-icon-c9acc3"); export const SystemIcon = createComponent('span')({ displayName: 'SystemIcon', Component: ({ accent, background, color, icon, size, ...elemProps }, ref, Element) => { return (_jsx(Svg, { as: Element, src: icon, type: CanvasIconTypes.System, ref: ref, ...handleCsProp(elemProps, systemIconStencil({ size: resolveSize(size, component.legacy.systemIcon.size), color, accentColor: accent, backgroundColor: background, })) })); }, });