delayed overlay and autorun spinner

This commit is contained in:
Vyacheslav Matyukhin 2022-07-27 22:37:46 +04:00
parent 329bb9432e
commit b1e7164c7e
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
3 changed files with 48 additions and 16 deletions

View File

@ -188,10 +188,7 @@ const RunControls: React.FC<{
)} )}
<Toggle <Toggle
texts={["Autorun", "Paused"]} texts={["Autorun", "Paused"]}
icons={[ icons={[CheckCircleIcon, PauseIcon]}
CheckCircleIcon, // note: we could replace this icon with RefreshIcon when spin is on, but that would cause blinking on each keystroke
PauseIcon,
]}
status={autorunMode} status={autorunMode}
onChange={onAutorunModeChange} onChange={onAutorunModeChange}
spinIcon={isRunning} spinIcon={isRunning}
@ -280,6 +277,10 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
const squiggleChart = const squiggleChart =
renderedCode === "" ? null : ( renderedCode === "" ? null : (
<div className="relative">
{isRunning ? (
<div className="absolute inset-0 bg-white opacity-0 animate-semi-appear" />
) : null}
<SquiggleChart <SquiggleChart
code={renderedCode} code={renderedCode}
executionId={executionId} executionId={executionId}
@ -289,6 +290,7 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
jsImports={imports} jsImports={imports}
enableLocalSettings={true} enableLocalSettings={true}
/> />
</div>
); );
const firstTab = vars.showEditor ? ( const firstTab = vars.showEditor ? (

View File

@ -1,3 +1,4 @@
import { RefreshIcon } from "@heroicons/react/solid";
import clsx from "clsx"; import clsx from "clsx";
import React from "react"; import React from "react";
@ -29,8 +30,16 @@ export const Toggle: React.FC<Props> = ({
)} )}
onClick={() => onChange(!status)} onClick={() => onChange(!status)}
> >
<div> <div className="relative w-6 h-6" key={String(spinIcon)}>
<CurrentIcon className={clsx("w-6 h-6", spinIcon && "animate-spin")} /> <CurrentIcon
className={clsx(
"w-6 h-6 absolute opacity-100",
spinIcon && "animate-hide"
)}
/>
{spinIcon && (
<RefreshIcon className="w-6 h-6 absolute opacity-0 animate-appear-and-spin" />
)}
</div> </div>
<span>{status ? onText : offText}</span> <span>{status ? onText : offText}</span>
</button> </button>

View File

@ -5,6 +5,27 @@ module.exports = {
}, },
important: ".squiggle", important: ".squiggle",
theme: { theme: {
extend: {}, extend: {
animation: {
"appear-and-spin":
"spin 1s linear infinite, squiggle-appear 0.2s forwards",
"semi-appear": "squiggle-semi-appear 0.2s forwards",
hide: "squiggle-hide 0.2s forwards",
},
keyframes: {
"squiggle-appear": {
from: { opacity: 0 },
to: { opacity: 1 },
},
"squiggle-semi-appear": {
from: { opacity: 0 },
to: { opacity: 0.5 },
},
"squiggle-hide": {
from: { opacity: 1 },
to: { opacity: 0 },
},
},
},
}, },
}; };