1- import React , { useState , useEffect , useRef } from 'react'
1+ import React , { useState } from 'react'
22import OutputComponent from './OutputComponent'
33import InfoComponent from './InfoComponent'
44
5- export default function LevelComponent ( ) {
5+ export default function LevelComponent ( { onClose } : { onClose : ( ) => void } ) {
6+ const [ isClosing , setIsClosing ] = useState ( false ) ;
67
7- return (
8- < div className = "animate-[zoomIn_0.3s_ease-out_forwards] origin-center w-screen h-screen flex gap-10 p-4 font-mono overflow-hidden" >
9- < div className = "flex gap-4 p-4 w-6/7 mx-auto" >
8+ const handleClose = ( ) => setIsClosing ( true ) ;
109
11- < div className = "flex-1 bg-[#2a2a2a] rounded-2xl p-3 flex flex-col gap-3" >
12- < InfoComponent />
13- </ div >
14- < div className = "flex-1 bg-[#2a2a2a] rounded-2xl p-3 flex flex-col gap-3" >
15- < OutputComponent />
16- </ div >
10+ const handleAnimationEnd = ( ) => {
11+ if ( isClosing ) onClose ( ) ;
12+ } ;
1713
18- </ div >
19-
14+ return (
15+ < >
2016 < style > { `
21- @keyframes zoomIn {
17+ @keyframes expandDown {
2218 from { transform: scaleY(0); }
2319 to { transform: scaleY(1); }
2420 }
25- .zoom-in {
26- animation: zoomIn 0.3s ease-out forwards;
21+ @keyframes collapseUp {
22+ from { transform: scaleY(1); }
23+ to { transform: scaleY(0); }
24+ }
25+ .expand-down {
26+ animation: expandDown 0.2s ease-out forwards;
27+ transform-origin: center;
28+ }
29+ .collapse-up {
30+ animation: collapseUp 0.2s ease-in forwards;
2731 transform-origin: center;
2832 }
2933 ` } </ style >
30- < div className = "zoom-in" >
31- { /* your content */ }
32- </ div >
33-
34+ < div
35+ className = { `${ isClosing ? 'collapse-up' : 'expand-down' } w-screen h-screen flex gap-10 p-4 font-mono overflow-hidden` }
36+ onAnimationEnd = { handleAnimationEnd }
37+ >
38+ { /* X button */ }
39+ < button
40+ onClick = { handleClose }
41+ className = "absolute top-9 right-38 text-white text-xl leading-none"
42+ >
43+ ✕
44+ </ button >
3445
35- </ div >
36- )
46+ < div className = "flex gap-4 p-4 w-6/7 mx-auto" >
47+ < div className = "flex-1 bg-[#2a2a2a] rounded-2xl p-3 flex flex-col gap-3" >
48+ < InfoComponent />
49+ </ div >
50+ < div className = "flex-1 bg-[#2a2a2a] rounded-2xl p-3 flex flex-col gap-3" >
51+ < OutputComponent />
52+ </ div >
53+ </ div >
54+ </ div >
55+ </ >
56+ ) ;
3757}
0 commit comments