@atlaskit/icon
Version:
An icon is a symbol representing a command, device, directory, or common action.
66 lines (65 loc) • 4.06 kB
JavaScript
/* text-review.tsx generated by @compiled/babel-plugin v3.0.4 */
import _extends from "@babel/runtime/helpers/extends";
import "./text-review.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
/* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors -- Animated glyphs are injected HTML strings, so inner elements can only be styled via nested selectors on the wrapper. */
import { forwardRef, useMemo } from 'react';
import Icon from '../components/icon-new';
import { useAnimatedIconPlayback } from '../components/use-animated-icon-playback';
import { useSvgMaskId } from '../components/use-svg-mask-id';
// The ring and check erase (start), then each resets to empty in turn (intermediate, check-intermediate).
// Check will undraw itself from 0-250ms and hold till 900ms. It will redraw itself from 900-1150ms and hold for 50ms.
// Ring will undraw itself from 100-350ms and hold till 800ms. It will redraw itself from 800-1050ms and hold for 150ms.
// Sparke will scale (1 to 0.5) from 200-700ms and return to 1 from 700-1200ms.
// The direction of the check and ring is reversed on exit if the motion is interrupted after 700ms.
const TIMELINE = [{
phase: 'start',
durationMs: 700
}, {
phase: 'intermediate',
durationMs: 100
}, {
phase: 'check-intermediate',
durationMs: 100
}];
const animatedStyles = {
base: "_ejdbzlwc _12lu1ytf _1xcju5a2 _1n18idpf _1awx1doz _cj1tu5a2 _1n5gidpf _1t6o1doz _14vt1h7a _btks1bs3",
start: "_1xcj1syk _1n181dee _1awx1doz _12kb1yx9 _cj1t1syk _1n5g1dee _1t6o1doz _14vt1jia _1b24fnf5",
ringIntermediate: "_1xcj1syk _1n18idpf _1awx5cps",
checkIntermediate: "_cj1t1syk _1n5gidpf _1t6o5cps"
};
const getGlyph = (ringMaskId, checkMaskId) => `
<defs>
<mask id="${ringMaskId}" maskUnits="userSpaceOnUse" x="-4" y="-4" width="24" height="24">
<path data-anim="ring" d="M8 15.25A7.25 7.25 0 1 1 15.25 8" stroke="white" stroke-width="3" fill="none" stroke-linecap="butt" pathLength="100" />
</mask>
<mask id="${checkMaskId}" maskUnits="userSpaceOnUse" x="-4" y="-4" width="24" height="24">
<path data-anim="check" d="M4.25 8L6.75 11L11.75 5" stroke="white" stroke-width="3" fill="none" stroke-linecap="butt" stroke-linejoin="miter" pathLength="100" />
</mask>
</defs>
<path d="M0 8a8 8 0 1 1 16 0h-1.5A6.5 6.5 0 1 0 8 14.5V16a8 8 0 0 1-8-8z" fill="currentColor" mask="url(#${ringMaskId})"/>
<path d="M12.326 5.48l-5 6a.75.75 0 0 1-1.152 0l-2.5-3 1.152-.96L6.75 9.828l4.424-5.308z" fill="currentColor" mask="url(#${checkMaskId})"/>
<path data-anim="star" d="M13.115 10.009a.75.75 0 0 1 .541.378l.05.106.4 1.102c.051.138.16.248.3.299l1.1.4a.75.75 0 0 1 0 1.411l-1.1.401a.5.5 0 0 0-.3.3l-.4 1.1a.75.75 0 0 1-1.411 0l-.401-1.1a.5.5 0 0 0-.3-.3l-1.1-.4a.75.75 0 0 1-.485-.59L10 13l.009-.116a.75.75 0 0 1 .484-.59l1.102-.4a.5.5 0 0 0 .299-.3l.4-1.1.05-.107a.75.75 0 0 1 .655-.387z" fill="currentColor" style="transform-origin: 13px 13px;"/>
`;
/**
* Animated text review icon: the ring and check redraw while the star shrinks and returns.
*/
const TextReviewAnimatedIcon = /*#__PURE__*/forwardRef(function TextReviewAnimatedIcon(props, ref) {
const [phase] = useAnimatedIconPlayback(ref, TIMELINE);
const ringMaskId = useSvgMaskId('text-review-ring');
const checkMaskId = useSvgMaskId('text-review-check');
const glyph = useMemo(() => getGlyph(ringMaskId, checkMaskId), [ringMaskId, checkMaskId]);
return /*#__PURE__*/React.createElement("span", {
className: ax([animatedStyles.base, phase === 'start' && animatedStyles.start, phase === 'intermediate' && animatedStyles.ringIntermediate, (phase === 'check-intermediate' || phase === 'intermediate') && animatedStyles.checkIntermediate])
}, /*#__PURE__*/React.createElement(Icon, _extends({
name: "TextReviewIcon",
dangerouslySetGlyph: glyph,
isAnimatedIcon: true
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
}, props, {
size: "medium"
})));
});
TextReviewAnimatedIcon.displayName = 'TextReviewIcon';
export default TextReviewAnimatedIcon;