UNPKG

@atlaskit/icon

Version:

An icon is a symbol representing a command, device, directory, or common action.

70 lines (68 loc) • 5.57 kB
/* text-review.tsx generated by @compiled/babel-plugin v3.0.4 */ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./text-review.compiled.css"); var _react = _interopRequireWildcard(require("react")); var React = _react; var _runtime = require("@compiled/react/runtime"); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); var _iconNew = _interopRequireDefault(require("../components/icon-new")); var _useAnimatedIconPlayback = require("../components/use-animated-icon-playback"); var _useSvgMaskId = require("../components/use-svg-mask-id"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } /* 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. */ // 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. var TIMELINE = [{ phase: 'start', durationMs: 700 }, { phase: 'intermediate', durationMs: 100 }, { phase: 'check-intermediate', durationMs: 100 }]; var 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" }; var getGlyph = function getGlyph(ringMaskId, checkMaskId) { return "\n<defs>\n\t<mask id=\"".concat(ringMaskId, "\" maskUnits=\"userSpaceOnUse\" x=\"-4\" y=\"-4\" width=\"24\" height=\"24\">\n\t\t<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\" />\n\t</mask>\n\t<mask id=\"").concat(checkMaskId, "\" maskUnits=\"userSpaceOnUse\" x=\"-4\" y=\"-4\" width=\"24\" height=\"24\">\n\t\t<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\" />\n\t</mask>\n</defs>\n<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(#").concat(ringMaskId, ")\"/>\n<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(#").concat(checkMaskId, ")\"/>\n<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;\"/>\n"); }; /** * Animated text review icon: the ring and check redraw while the star shrinks and returns. */ var TextReviewAnimatedIcon = /*#__PURE__*/(0, _react.forwardRef)(function TextReviewAnimatedIcon(props, ref) { var _useAnimatedIconPlayb = (0, _useAnimatedIconPlayback.useAnimatedIconPlayback)(ref, TIMELINE), _useAnimatedIconPlayb2 = (0, _slicedToArray2.default)(_useAnimatedIconPlayb, 1), phase = _useAnimatedIconPlayb2[0]; var ringMaskId = (0, _useSvgMaskId.useSvgMaskId)('text-review-ring'); var checkMaskId = (0, _useSvgMaskId.useSvgMaskId)('text-review-check'); var glyph = (0, _react.useMemo)(function () { return getGlyph(ringMaskId, checkMaskId); }, [ringMaskId, checkMaskId]); return /*#__PURE__*/React.createElement("span", { className: (0, _runtime.ax)([animatedStyles.base, phase === 'start' && animatedStyles.start, phase === 'intermediate' && animatedStyles.ringIntermediate, (phase === 'check-intermediate' || phase === 'intermediate') && animatedStyles.checkIntermediate]) }, /*#__PURE__*/React.createElement(_iconNew.default, (0, _extends2.default)({ name: "TextReviewIcon", dangerouslySetGlyph: glyph, isAnimatedIcon: true // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props }, props, { size: "medium" }))); }); TextReviewAnimatedIcon.displayName = 'TextReviewIcon'; var _default = exports.default = TextReviewAnimatedIcon;