@@ -18,11 +18,12 @@ export function Repl({
1818 const historyRef = useRef < HTMLDivElement > ( null ) ;
1919 const inputRef = useRef < HTMLInputElement > ( null ) ;
2020 const formRef = useRef < HTMLFormElement > ( null ) ;
21+ const wandButtonRef = useRef < HTMLButtonElement > ( null ) ;
2122 const [ input , setInput ] = useState ( "" ) ;
2223 const { handleInput, commandRunning } = useReplLogic ( { engine } ) ;
2324 const [ inputFocus , setInputFocus ] = useState ( false ) ;
2425 const { history } = useReplHistory ( ) ;
25- const [ wandButtonUsed , setWandButtonUsed ] = useState ( false ) ;
26+ const [ wandButtonUsed , setWandButtonUsed ] = useState < boolean | null > ( null ) ;
2627 const { getExampleCommand, remainingExampleCommands, doneExampleCommands } =
2728 useGetExampleCommand ( ) ;
2829
@@ -64,8 +65,30 @@ export function Repl({
6465 }
6566 } , [ inputFocus ] ) ;
6667
68+ useEffect ( ( ) => {
69+ if ( wandButtonRef . current ) {
70+ wandButtonRef . current . addEventListener ( "animationend" , ( ) => {
71+ setWandButtonUsed ( false ) ;
72+ } ) ;
73+ }
74+ } , [ ] ) ;
75+
6776 return (
6877 < div className = { className } >
78+ < style >
79+ { `
80+ @keyframes wandEnter {
81+ 0% {
82+ transform: translate(-30vw, -60vh) scale(3);
83+ opacity: 0.2;
84+ }
85+ 100% {
86+ transform: translate(0, 0) scale(1);
87+ opacity: 1;
88+ }
89+ }
90+ ` }
91+ </ style >
6992 < ReplHistory
7093 ref = { historyRef }
7194 className = "fixed top-[80px] bottom-[100px] overflow-y-scroll max-w-4xl w-full pr-8"
@@ -108,6 +131,7 @@ export function Repl({
108131 < Play />
109132 </ button >
110133 < button
134+ ref = { wandButtonRef }
111135 onClick = { ( ) => {
112136 setWandButtonUsed ( true ) ;
113137 if ( commandRunning ) {
@@ -126,8 +150,14 @@ export function Repl({
126150 type = "button"
127151 className = { cn (
128152 "cursor-pointer bg-primary text-white px-4 py-2 rounded-md relative" ,
129- ! wandButtonUsed && "animate-bounce" ,
153+ wandButtonUsed === false && "animate-bounce" ,
130154 ) }
155+ style = { {
156+ animation :
157+ wandButtonUsed === null
158+ ? "wandEnter 1s ease-in-out forwards"
159+ : "" ,
160+ } }
131161 title = "Run example command"
132162 >
133163 < WandSparkles />
0 commit comments