UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

33 lines (32 loc) 2.63 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { system } from '@workday/canvas-tokens-web'; import { createComponent } from '@workday/canvas-kit-react/common'; import { handleCsProp, keyframes, createStencil, calc, px2rem, cssVar, } from '@workday/canvas-kit-styling'; /** * Keyframe for the dots loading animation. */ const keyframesLoading = keyframes({ name: "4c7rte", styles: "0%, 80%, 100%{transform:scale(0);}40%{transform:scale(1);}0%, 79%, 100%{opacity:0.6;}27%{opacity:1;}53%{opacity:0.8;}" }); export const loadingDotsStencil = createStencil({ vars: { animationDurationMs: '40ms', loadingDotColor: system.color.bg.muted.strong, }, parts: { loadingAnimationDot: 'loading-animation-dot', }, base: { name: "48o3we", styles: "--animationDurationMs-loading-dots-89a0c0:40ms;--loadingDotColor-loading-dots-89a0c0:var(--cnvs-sys-color-bg-muted-strong);box-sizing:border-box;display:inline-flex;gap:var(--cnvs-sys-space-x2);[data-part=\"loading-animation-dot\"]{background-color:var(--loadingDotColor-loading-dots-89a0c0);width:var(--cnvs-sys-space-x4);height:var(--cnvs-sys-space-x4);font-size:var(--cnvs-sys-space-zero);border-radius:var(--cnvs-sys-shape-round);outline:0.125rem solid transparent;transform:scale(0);display:inline-block;animation-name:animation-4c7rte;animation-duration:calc(var(--animationDurationMs-loading-dots-89a0c0) * 35);animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-fill-mode:both;&:nth-child(1){animation-delay:0ms;}&:nth-child(2){animation-delay:calc(var(--animationDurationMs-loading-dots-89a0c0) * 4);}&:nth-child(3){animation-delay:calc(var(--animationDurationMs-loading-dots-89a0c0) * 8);}}" }, modifiers: { variant: { inverse: { name: "44yc01", styles: "[data-part=\"loading-animation-dot\"]{background-color:var(--cnvs-sys-color-bg-default, var(--loadingDotColor-loading-dots-89a0c0));}" } } } }, "loading-dots-89a0c0"); /** * A simple component that displays three horizontal dots, to be used when some data is loading. */ export const LoadingDots = createComponent('div')({ displayName: 'LoadingDots', Component: ({ loadingDotColor, animationDurationMs, variant, ...elemProps }, ref, Element) => { return (_jsxs(Element, { ref: ref, ...handleCsProp(elemProps, loadingDotsStencil({ loadingDotColor, animationDurationMs, variant })), children: [_jsx("div", { "data-part": "loading-animation-dot" }), _jsx("div", { "data-part": "loading-animation-dot" }), _jsx("div", { "data-part": "loading-animation-dot" })] })); }, });