@workday/canvas-kit-react
Version:
The parent module that contains all Workday Canvas Kit React components
106 lines (105 loc) • 6.66 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemIcon = exports.systemIconStencil = exports.systemIconStyles = void 0;
const React = __importStar(require("react"));
const tokens_1 = require("@workday/canvas-kit-react/tokens");
const design_assets_types_1 = require("@workday/design-assets-types");
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");
const Svg_1 = require("./Svg");
/**
* @deprecated This style utility function is deprecated and will be removed in a future version. We'll track usage over time to prevent unnecessary burden on upgrading. Most of the time, this function is used in conjunction with styling `SystemIcon`. There are a few ways to override the colors used in `SystemIcon`.
* - Pass props directly to the `SystemIcon` component: `<SystemIcon color={color} {...etc} />
* - Style overrides using the `systemIconStencil`:
* ```tsx
* // styling container
*
* ```
*/
const systemIconStyles = ({ accent, accentHover, background = 'transparent', backgroundHover = 'transparent', color = tokens_1.iconColors.standard, colorHover = tokens_1.iconColors.hover, fill, fillHover, }) => ({
'& .wd-icon-fill': {
fill: (0, common_1.getColor)(fill) || (0, common_1.getColor)(color),
},
':hover .wd-icon-fill': {
fill: (0, common_1.getColor)(fillHover) || (0, common_1.getColor)(colorHover),
},
'& .wd-icon-accent, & .wd-icon-accent2': {
fill: (0, common_1.getColor)(accent) || (0, common_1.getColor)(color),
},
':hover .wd-icon-accent, :hover .wd-icon-accent2': {
fill: (0, common_1.getColor)(accentHover) || (0, common_1.getColor)(colorHover),
},
'& .wd-icon-background': {
fill: (0, common_1.getColor)(background),
},
':hover .wd-icon-background': {
fill: (0, common_1.getColor)(backgroundHover),
},
});
exports.systemIconStyles = systemIconStyles;
/**
* @deprecated These variables are being used for backward compatibility with existing hover props. Please use the following instead:
* ```tsx
* '&:hover': {
* [systemIconStencil.vars.color]: desiredHoverColor
* }
* ```
*/
const deprecatedSystemIconVars = (0, canvas_kit_styling_1.createVars)({ id: "a571ba", args: ["colorHover", "fillHover", "accentHover", "backgroundHover"] });
exports.systemIconStencil = (0, canvas_kit_styling_1.createStencil)({
extends: Svg_1.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: '',
accentColor: '',
backgroundColor: '',
},
base: { name: "ojxa15", styles: "box-sizing:border-box;& svg{width:var(--width-svg-a30d66, var(--size-svg-a30d66, var(--cnvs-sys-space-x6)));height:var(--height-svg-a30d66, var(--size-svg-a30d66, var(--cnvs-sys-space-x6)));}& .wd-icon-fill{fill:var(--color-system-icon-212f69, var(--cnvs-base-palette-licorice-200));}& .wd-icon-accent, & .wd-icon-accent2{fill:var(--accentColor-system-icon-212f69, var(--color-system-icon-212f69, var(--cnvs-base-palette-licorice-200)));}& .wd-icon-background{fill:var(--backgroundColor-system-icon-212f69, transparent);}&:where(:hover, .hover) .wd-icon-fill{fill:var(--fillHover-a571ba, var(--colorHover-a571ba, var(--color-system-icon-212f69, var(--cnvs-base-palette-licorice-200))));}&:where(:hover, .hover) .wd-icon-accent, & .wd-icon-accent2{fill:var(--accentHover-a571ba, var(--colorHover-a571ba, var(--accentColor-system-icon-212f69, var(--color-system-icon-212f69, var(--cnvs-base-palette-licorice-200)))));}&:where(:hover, .hover) .wd-icon-background{fill:var(--backgroundHover-a571ba, var(--backgroundColor-system-icon-212f69, transparent));}@media (prefers-contrast: more){.wd-icon-fill, .wd-icon-accent{color:currentColor;fill:currentColor;}}" }
}, "system-icon-212f69");
exports.SystemIcon = (0, common_1.createComponent)('span')({
displayName: 'SystemIcon',
Component: ({ size, background, backgroundHover, color, colorHover, icon, accent, accentHover, fill, fillHover, ...elemProps }, ref, Element) => {
return (React.createElement(Svg_1.Svg, { as: Element, src: icon, type: design_assets_types_1.CanvasIconTypes.System, ref: ref, ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, [
(0, exports.systemIconStencil)({
size: typeof size === 'number' ? (0, canvas_kit_styling_1.px2rem)(size) : size,
color: (0, Svg_1.transformColorNameToToken)(fill || color),
accentColor: (0, Svg_1.transformColorNameToToken)(accent || color),
backgroundColor: (0, Svg_1.transformColorNameToToken)(background),
}),
{
[deprecatedSystemIconVars.colorHover]: colorHover && (0, Svg_1.transformColorNameToToken)(colorHover),
[deprecatedSystemIconVars.fillHover]: fillHover && (0, Svg_1.transformColorNameToToken)(fillHover),
[deprecatedSystemIconVars.accentHover]: accentHover && (0, Svg_1.transformColorNameToToken)(accentHover),
[deprecatedSystemIconVars.backgroundHover]: backgroundHover && (0, Svg_1.transformColorNameToToken)(backgroundHover),
},
]) }));
},
});
;