UNPKG

@workday/canvas-kit-preview-react

Version:

Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.

140 lines (139 loc) 6.76 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { createComponent } from '@workday/canvas-kit-react/common'; import { createStencil, px2rem } from '@workday/canvas-kit-styling'; import { system } from '@workday/canvas-tokens-web'; import { mergeStyles } from '@workday/canvas-kit-react/layout'; import { systemIconStencil } from '@workday/canvas-kit-react/icon'; import { StatusIndicatorIcon } from './StatusIndicatorIcon'; import { StatusIndicatorLabel } from './StatusIndicatorLabel'; // TODO: Remove this in a future release const deprecatedVariantsMap = { blue: 'info', green: 'positive', orange: 'caution', red: 'critical', gray: 'neutral', }; const statusIndicatorStencil = createStencil({ base: { name: "3wungi", styles: "box-sizing:border-box;display:inline-flex;gap:var(--cnvs-sys-space-x1);max-width:12.5rem;align-items:center;border-radius:var(--cnvs-sys-shape-round);height:1.25rem;padding:var(--cnvs-sys-space-zero) var(--cnvs-sys-space-x2);outline:0.0625rem solid transparent;--color-system-icon-3a4847:currentColor;" }, modifiers: { /** * Defines the color of the `StatusIndicator`. * * `info` | `blue` - Uses the info system color and is used for informational status indications * * `positive` | `green` - Uses the positive system color and is used for positive status indications * * `caution` | `orange` - Uses the caution system color and is used for warnings or required actions * * `critical` | `red` - Uses the error system color and is used for critical or negative status indications * * `neutral` | `gray` - Uses the neutral system color and generally doesn't have positive or negative connotations * * `illuminate` - Uses the AI system color and is used for AI generated content * * `transparent` - Uses the transparent system color and is used for overlays on top of images or videos * * @default 'neutral' */ variant: { info: { name: "329ge3", styles: "color:var(--cnvs-sys-color-fg-info-strong);background-color:var(--cnvs-sys-color-bg-info-softer);" }, positive: { name: "l52n8", styles: "color:var(--cnvs-sys-color-fg-positive-strong);background-color:var(--cnvs-sys-color-fg-positive-softer);" }, caution: { name: "2q6rfz", styles: "color:var(--cnvs-sys-color-fg-caution-soft);background-color:var(--cnvs-sys-color-bg-caution-softer);" }, critical: { name: "mwhe4", styles: "color:var(--cnvs-sys-color-fg-critical-strong);background-color:var(--cnvs-sys-color-bg-critical-softer);" }, neutral: { name: "22p9xb", styles: "color:var(--cnvs-sys-color-fg-muted-strong);background-color:var(--cnvs-sys-color-bg-alt-default);" }, ai: { name: "3w3fj8", styles: "color:var(--cnvs-sys-color-fg-ai);background-color:var(--cnvs-sys-color-bg-ai-default);" }, transparent: { name: "2spt6b", styles: "color:var(--cnvs-sys-color-fg-inverse);background-color:var(--cnvs-sys-color-bg-translucent);" } }, /** * Defines the emphasis of the `StatusIndicator`. `low` should be used in almost all cases. * `high` is being deprecated and will be removed in a future release. * * `low` - Normal emphasis and will visually fit in with other components. * * `high` - High emphasis has been used to make the `StatusIndicator` stand out more, but * tends to overpower other components. It will be removed and should not be used. * * @default 'low' * */ emphasis: { low: { name: "3j92ja", styles: "" }, high: { name: "1kkkl6", styles: "" } } }, compound: [ { modifiers: { variant: 'info', emphasis: 'high', }, styles: { name: "knspq", styles: "background-color:var(--cnvs-sys-color-bg-info-default);color:var(--cnvs-sys-color-fg-inverse);" } }, { modifiers: { variant: 'positive', emphasis: 'high', }, styles: { name: "2o3p8l", styles: "background-color:var(--cnvs-sys-color-bg-positive-default);color:var(--cnvs-sys-color-fg-inverse);" } }, { modifiers: { variant: 'caution', emphasis: 'high', }, styles: { name: "2ti80q", styles: "background-color:var(--cnvs-sys-color-bg-caution-default);color:var(--cnvs-sys-color-fg-caution-strong);" } }, { modifiers: { variant: 'critical', emphasis: 'high', }, styles: { name: "3fouy9", styles: "background-color:var(--cnvs-sys-color-bg-critical-default);color:var(--cnvs-sys-color-fg-inverse);" } }, { modifiers: { variant: 'neutral', emphasis: 'high', }, styles: { name: "2o68cc", styles: "background-color:var(--cnvs-sys-color-bg-muted-default);color:var(--cnvs-sys-color-fg-inverse);" } } ], defaultModifiers: { variant: 'neutral', emphasis: 'low', } }, "status-indicator-c55f02"); /** * `StatusIndicator` is a container component has a default maximum width of `200px`. * * ```tsx * <StatusIndicator variant="info"> * {Child components} * </StatusIndicator> * ``` */ export const StatusIndicator = createComponent('div')({ displayName: 'StatusIndicator', subComponents: { /** * `StatusIndicator.Label` will apply an ellipsis if its contents exceed the component's maximum * width. * * ```tsx * <StatusIndicator.Label>{The text to be rendered}</StatusIndicator.Label> * ``` */ Label: StatusIndicatorLabel, /** * `StatusIndicator.Icon` renders {@link SystemIcon} under the hood. It's used as a decorative * element to visually support the {@link StatusIndicatorLabel StatusIndicator.Label} text. * * ```tsx * <StatusIndicator.Icon icon={uploadCloudIcon} /> * ``` */ Icon: StatusIndicatorIcon, }, Component: ({ variant, emphasis, children, ...elemProps }, ref, Element) => { return (_jsx(Element, { ref: ref, ...mergeStyles(elemProps, statusIndicatorStencil({ variant: // collapse the type to only the allowed modifiers. Look them up in the map, then // fallback to the passed variant. deprecatedVariantsMap[variant] || variant, emphasis, })), children: children })); }, });