UNPKG

chromogen

Version:

simple, interaction-driven Jest test generator for Recoil and React Hooks apps

128 lines (126 loc) 4.67 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importStar(require("react")); const RecordButton = (props) => { const [isHover, setIsHover] = (0, react_1.useState)(false); const handleMouseEnter = () => { setIsHover(true); }; const handleMouseLeave = () => { setIsHover(false); }; const recordButtonShape = { display: 'flex', flexDirection: 'row', alignItems: 'center', position: 'absolute', width: '252px', height: '48px', borderRadius: '42px', justifyContent: 'center', padding: '14px 24px', columnGap: '16px', background: '#181818', border: '1px solid rgba(243, 246, 248, 0.1)', boxShadow: '0px 18px 24px rgba(0, 0, 0, 0.16), 0px 12px 16px rgba(6, 9, 11, 0.1), 0px 6px 12px rgba(0, 0, 0, 0.18), 0px 1px 20px rgba(0, 0, 0, 0.12)', cursor: 'pointer', bottom: '20px', }; const recordIcon = { width: '20px', height: '20px', background: '#D75959', opacity: '0.8', boxShadow: '0px 2px 6px rgba(215, 89, 89, 0.24), 0px 6px 10px rgba(215, 89, 89, 0.2), 0px 1px 16px rgba(215, 89, 89, 0.06)', borderRadius: '30px', flex: 'none', order: '0', flexGrow: '0', animation: !isHover ? 'glowing 1500ms infinite' : 'none', }; const glowingAnimation = ` @keyframes glowing { 0% { background-color: #D75959; box-shadow: 0 0 3px #D75959; } 50% { background-color: #ce4949; box-shadow: 0 0 30px #D75959; } 100% { background-color: #D75959; box-shadow: 0 0 3px #D75959; } } .glowing { animation: glowing 1500ms infinite; } `; const recordText = { fontSize: '14px', lineHeight: '16px', color: '#CB4F4F', opacity: '0.8', flex: 'none', order: '1', flexGrow: '0', }; const stopButtonShape = { display: 'flex', fontSize: '14px', flexDirection: 'row', alignItems: 'center', position: 'absolute', justifyContent: 'center', width: '252px', height: '48px', borderRadius: '42px', padding: '14px 24px', columnGap: '16px', background: '#212121', border: '1px solid rgba(243, 246, 248, 0.1)', boxShadow: '0px 18px 24px rgba(0, 0, 0, 0.16), 0px 12px 16px rgba(6, 9, 11, 0.1), 0px 6px 12px rgba(0, 0, 0, 0.18), 0px 1px 20px rgba(0, 0, 0, 0.12)', cursor: 'pointer', bottom: '20px', }; const stopIcon = { width: '14px', height: '16px', background: 'rgba(243, 246, 248, 0.9)', borderRadius: '1px', flex: 'none', order: '0', flexGrow: '0', }; const stopText = { height: '16px', fontSize: '14px', lineHeight: '16px', color: '#F3F6F8', opacity: '0.8', flex: 'none', order: '1', flexGrow: '0', }; return (react_1.default.createElement(react_1.default.Fragment, null, react_1.default.createElement("style", null, glowingAnimation), react_1.default.createElement("button", { style: isHover ? stopButtonShape : recordButtonShape, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: props.handleClick }, react_1.default.createElement("div", { style: isHover ? stopIcon : recordIcon }), react_1.default.createElement("div", { style: isHover ? stopText : recordText }, isHover ? 'Stop recording' : 'Recording in progress')))); }; exports.default = RecordButton;