@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.
47 lines (46 loc) • 2.34 kB
JavaScript
import * as React from 'react';
import { system } from '@workday/canvas-tokens-web';
import { createComponent } from '@workday/canvas-kit-react/common';
import { SystemIcon } from '@workday/canvas-kit-react/icon';
import { createStyles, cssVar, handleCsProp, px2rem, keyframes, } from '@workday/canvas-kit-styling';
import { sparkleIcon } from './sparkleIcon';
/**
* Duration of the sparkle animation (in ms).
*/
const ANIMATION_DURATION_MS = 1230;
// TODO: Replace with the actual color tokens when they are available.
/**
* Dragon Fruit colors.
*/
const AI_COLORS = {
dragonFruit100: '#FBF1FF',
dragonFruit200: '#EFD3FF',
dragonFruit300: '#BE61F6',
dragonFruit400: '#8C17D2',
dragonFruit500: '#6B11A3',
dragonFruit600: '#4A0D71',
};
/**
* The animation for the sparkle.
*/
const LOADING_ANIMATION = keyframes({ name: "xrlq3", 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);}" });
const loadingSparklesIconStyles = createStyles({ name: "xrlq4", styles: "animation-duration:1230ms;animation-fill-mode:both;animation-iteration-count:infinite;animation-name:animation-xrlq3;animation-timing-function:ease-in-out;.wd-sparkle-fill{fill:#8C17D2;}&:nth-child(1){animation-delay:0ms;}&:nth-child(2){animation-delay:calc(1230ms * (1/3));}&:nth-child(3){animation-delay:calc(1230ms * (2/3));}@media (prefers-contrast: more){.wd-sparkle-fill{color:currentColor;fill:currentColor;}}" });
/**
* An individual loading sparkle. ✨
*/
const Sparkle = () => {
return (React.createElement(SystemIcon, { icon: sparkleIcon, cs: [loadingSparklesIconStyles], size: cssVar(system.space.x3) }));
};
const loadingSparklesStyles = createStyles({ name: "xrlq5", styles: "display:inline-flex;gap:0.0625rem;" });
/**
* 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 (React.createElement(Element, { ref: ref, role: "status", ...handleCsProp(elemProps, loadingSparklesStyles) },
React.createElement(Sparkle, null),
React.createElement(Sparkle, null),
React.createElement(Sparkle, null)));
},
});