@sanity/desk-tool
Version:
Tool for managing all sorts of content in a structured manner
177 lines (176 loc) • 6.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AnimatedStatusIcon = AnimatedStatusIcon;
var _react = _interopRequireDefault(require("react"));
var _framerMotion = require("framer-motion");
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _templateObject, _templateObject2, _templateObject3;
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var StyledMotionPath = (0, _styledComponents.default)(_framerMotion.motion.path)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n transform-origin: center;\n"])));
var Circle = props => /*#__PURE__*/_react.default.createElement(_framerMotion.motion.circle, _extends({
fill: "none",
r: "8",
cx: "12.5",
cy: "12.5",
strokeWidth: "1.2"
}, props));
var Arrows = props => /*#__PURE__*/_react.default.createElement(StyledMotionPath, _extends({
fill: "none",
d: "M14 17.5619L11.5 20.5L14.5 23.0619M11 7.43811L13.5 4.50001L10.5 1.93811"
}, props));
var Checkmark = props => /*#__PURE__*/_react.default.createElement(_framerMotion.motion.path, _extends({
d: "M9.5 12.1316L11.7414 14.5L16 10"
}, props));
var Edit = props => /*#__PURE__*/_react.default.createElement(_framerMotion.motion.path, _extends({
d: "M15 7L18 10M6 19L7 15L17 5L20 8L10 18L6 19Z"
}, props));
var rotateAnimation = (0, _styledComponents.keyframes)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n transform: rotate(0);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
var RotateGroup = _styledComponents.default.g(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n transform-origin: center;\n\n &[data-rotate] {\n animation: ", " 1s ease-in-out infinite;\n }\n"])), rotateAnimation);
var root = {
syncing: {
scale: 1,
transition: {
duration: 0
}
},
saved: {
scale: [1, 0.8, 1.2, 0.9, 1.1, 0.95, 1.05, 0.99, 1],
transition: {
duration: 0.5,
delay: 0.2
}
},
changes: {
transition: {
duration: 0
}
}
};
var circle = {
syncing: {
strokeDasharray: '0, 0, 23, 3, 23, 3',
strokeDashoffset: 10,
opacity: 1,
transition: {
duration: 0
}
},
saved: {
strokeDasharray: '0, 0, 23, 0, 23, 0',
strokeDashoffset: 10,
opacity: 1,
transition: {
duration: 0.2
}
},
changes: {
strokeDasharray: '0, 60, 23, 0, 23, 0',
strokeDashoffset: 0,
opacity: 0,
transition: {
duration: 0.5
}
}
};
var arrows = {
syncing: {
opacity: 1,
transition: {
duration: 0
}
},
saved: {
opacity: 0,
transition: {
duration: 0.2
}
},
changes: {
opacity: 0
}
};
var checkmark = {
syncing: {
pathLength: 0,
transition: {
duration: 0
}
},
saved: {
pathLength: 1,
transition: {
delay: 0.4,
duration: 0.3
}
},
changes: {
pathLength: 0,
transition: {
duration: 0.2
}
}
};
var edit = {
syncing: {
pathLength: 0,
transition: {
duration: 0
}
},
saved: {
pathLength: 0,
transition: {
duration: 0
}
},
changes: {
pathLength: 1,
transition: {
duration: 0.4,
delay: 0.5
}
}
};
function AnimatedStatusIcon(props) {
var status = props.status;
if (!status) {
return null;
}
return /*#__PURE__*/_react.default.createElement("svg", {
width: "1em",
height: "1em",
viewBox: "0 0 25 25",
fill: "none",
stroke: "currentColor",
strokeWidth: "1.2",
"data-sanity-icon": ""
}, /*#__PURE__*/_react.default.createElement(_framerMotion.motion.g, {
variants: root,
initial: status,
animate: status
}, /*#__PURE__*/_react.default.createElement(RotateGroup, {
"data-rotate": status === 'changes' ? undefined : ''
}, /*#__PURE__*/_react.default.createElement(Arrows, {
variants: arrows,
initial: status,
animate: status
}), /*#__PURE__*/_react.default.createElement(Circle, {
variants: circle,
initial: status,
animate: status
})), /*#__PURE__*/_react.default.createElement(Checkmark, {
variants: checkmark,
initial: status,
animate: status
}), /*#__PURE__*/_react.default.createElement(Edit, {
variants: edit,
initial: status,
animate: status
})));
}