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.

33 lines (32 loc) 1.91 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 { SystemIcon, systemIconStencil } from '@workday/canvas-kit-react/icon'; import { createStencil, handleCsProp, keyframes, px2rem } from '@workday/canvas-kit-styling'; import { sparkleIcon } from './sparkleIcon'; /** * Duration of the sparkle animation (in ms). */ const ANIMATION_DURATION_MS = 1230; /** * The animation for the sparkle. */ const LOADING_ANIMATION = keyframes({ name: "368twn", styles: "0%, 79%, 100%{opacity:0.2;transform:scale(0.55);}27%{opacity:1;transform:scale(1);}53%{opacity:0.6;transform:scale(0.7);}" }); /** * An individual loading sparkle. ✨ */ const Sparkle = () => { return _jsx(SystemIcon, { "data-part": "sparkle", icon: sparkleIcon, size: system.space.x3 }); }; export const loadingSparklesStencil = createStencil({ base: { name: "rjl8d", styles: "box-sizing:border-box;display:inline-flex;gap:0.0625rem;& [data-part=\"sparkle\"]{animation-duration:1230ms;animation-fill-mode:both;animation-iteration-count:infinite;animation-name:animation-368twn;animation-timing-function:ease-in-out;--color-system-icon-3a4847:var(--cnvs-sys-color-fg-ai);&:nth-child(1){animation-delay:0ms;}&:nth-child(2){animation-delay:calc(1230ms * (1/3));}&:nth-child(3){animation-delay:calc(1230ms * (2/3));}}" } }, "loading-sparkles-322f75"); /** * A simple component that displays three horizontal sparkles, to be used when an AI operation is in progress. */ export const LoadingSparkles = createComponent('div')({ displayName: 'LoadingSparkles', Component: (elemProps, ref, Element) => { return (_jsxs(Element, { ref: ref, role: "status", ...handleCsProp(elemProps, loadingSparklesStencil()), children: [_jsx(Sparkle, {}), _jsx(Sparkle, {}), _jsx(Sparkle, {})] })); }, });