UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

26 lines (25 loc) 1.79 kB
import * as React from 'react'; import { createComponent } from '@workday/canvas-kit-react/common'; import { handleCsProp, createStencil, px2rem, keyframes } from '@workday/canvas-kit-styling'; import { system } from '@workday/canvas-tokens-web'; const grow = keyframes({ name: "d5h43j", styles: "from{transform:scale(0.85);}to{transform:scale(1.0);}" }); // .cnvs-count-badge const countBadgeStencil = createStencil({ base: { name: "d5h43k", styles: "box-sizing:border-box;align-items:center;animation:animation-d5h43j 0.2s ease;background:var(--cnvs-sys-color-static-red-default);border-radius:var(--cnvs-sys-shape-round);color:var(--cnvs-sys-color-text-inverse);display:inline-flex;font-family:var(--cnvs-sys-font-family-default);font-size:var(--cnvs-sys-font-size-subtext-medium);font-weight:var(--cnvs-sys-font-weight-bold);height:1.25rem;justify-content:center;line-height:1.25rem;min-width:1.25rem;padding:0 0.40625rem;text-shadow:0 0 0.0625rem rgba(0,0,0, 0.35);" }, modifiers: { variant: { // .cnvs-count-badge--variant-inverse inverse: { name: "d5h43l", styles: "background:var(--cnvs-sys-color-bg-default);box-shadow:0 0.0625rem 0.125rem rgba(0,0,0, 0.25);color:var(--cnvs-sys-color-text-primary-default);text-shadow:none;" } } } }, "count-badge-183e28"); /** * `CountBadge` provides a quantity-based summary with dynamic values. */ export const CountBadge = createComponent('span')({ displayName: 'CountBadge', Component: ({ count = 0, limit = 1000, variant, ...elemProps }, ref, Element) => { const formattedCount = count < limit ? `${count}` : `${limit - 1}+`; return (React.createElement(Element, { ref: ref, ...handleCsProp(elemProps, [countBadgeStencil({ variant })]) }, formattedCount)); }, });