UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

39 lines (38 loc) 2.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CountBadge = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); 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 grow = (0, canvas_kit_styling_1.keyframes)({ name: "3ujitz", styles: "from{transform:scale(0.85);}to{transform:scale(1.0);}" }); // .cnvs-count-badge const countBadgeStencil = (0, canvas_kit_styling_1.createStencil)({ base: { name: "cogmg", styles: "box-sizing:border-box;align-items:center;animation:animation-3ujitz 0.2s ease;border-radius:var(--cnvs-sys-shape-full, var(--cnvs-sys-shape-round, 65rem));display:inline-flex;font-family:var(--cnvs-sys-font-family-default, \"Roboto\");font-weight:var(--cnvs-sys-font-weight-medium);line-height:var(--cnvs-sys-line-height-subtext-md, 1rem);font-size:var(--cnvs-sys-font-size-subtext-md, 0.75rem);letter-spacing:var(--cnvs-sys-letter-spacing-subtext-md, 0.02rem);height:1.25rem;justify-content:center;min-width:var(--cnvs-sys-size-xxs, var(--cnvs-sys-space-x5, 1.25rem));padding:0 var(--cnvs-sys-padding-xxs, var(--cnvs-sys-space-x1, 0.25rem));background:var(--cnvs-sys-color-brand-accent-primary, var(--cnvs-brand-primary-base, oklch(0.5198 0.1782 256.11 / 1)));color:var(--cnvs-sys-color-fg-inverse);" }, modifiers: { variant: { // .cnvs-count-badge--variant-inverse inverse: { name: "41a8kn", styles: "background:var(--cnvs-sys-color-surface-inverse, var(--cnvs-sys-color-bg-default, oklch(1 0 0 / 1)));color:var(--cnvs-sys-color-fg-strong);" } }, emphasis: { high: { name: "37bw5s", styles: "" }, low: { name: "xe8p", styles: "background:var(--cnvs-sys-color-surface-info-strong, var(--cnvs-sys-color-bg-info-softer, oklch(0.6152 0.2108 256.1 / 0.11)));color:var(--cnvs-sys-color-fg-info-strong, var(--cnvs-sys-color-fg-primary-strong, oklch(0.4658 0.1562 255.5 / 1)));" } } }, compound: [ { modifiers: { variant: 'inverse', emphasis: 'low' }, styles: { name: "1z4z7e", styles: "background:var(--cnvs-sys-color-surface-overlay-hover-inverse, oklch(1 0 0 / 0.16));color:var(--cnvs-sys-color-fg-inverse);" } } ] }, "count-badge-524876"); /** * `CountBadge` provides a quantity-based summary with dynamic values. */ exports.CountBadge = (0, common_1.createComponent)('span')({ displayName: 'CountBadge', Component: ({ count = 0, limit = 1000, variant, emphasis = 'high', ...elemProps }, ref, Element) => { const formattedCount = count < limit ? `${count}` : `${limit - 1}+`; return ((0, jsx_runtime_1.jsx)(Element, { ref: ref, ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, [countBadgeStencil({ variant, emphasis })]), children: formattedCount })); }, });