@@ -40,6 +40,7 @@ export function CssRush({ gameDurationSeconds = 180 }: GameConfigProps) {
4040 return createCodeBlocks ( shuffled ) ;
4141 } ) ;
4242 const [ isClient , setIsClient ] = useState ( false ) ;
43+ const [ showSuccessFlash , setShowSuccessFlash ] = useState ( false ) ;
4344
4445 // Hooks
4546 const [ holdingBlockId , setHoldingBlockId ] = useState < string | null > ( null ) ;
@@ -102,10 +103,16 @@ export function CssRush({ gameDurationSeconds = 180 }: GameConfigProps) {
102103
103104 if ( userCode === targetCode ) {
104105 setGameState ( ( prev ) => ( { ...prev , score : prev . score + 1 } ) ) ;
105- const newTarget = getRandomTarget ( ) ;
106- setCurrentTarget ( newTarget ) ;
107- const shuffled = shuffleArray ( newTarget . blocks ) ;
108- setCode ( createCodeBlocks ( shuffled ) ) ;
106+ setShowSuccessFlash ( true ) ;
107+
108+ // Wait 0.5 second before loading next target
109+ setTimeout ( ( ) => {
110+ const newTarget = getRandomTarget ( ) ;
111+ setCurrentTarget ( newTarget ) ;
112+ const shuffled = shuffleArray ( newTarget . blocks ) ;
113+ setCode ( createCodeBlocks ( shuffled ) ) ;
114+ setShowSuccessFlash ( false ) ;
115+ } , 500 ) ;
109116 }
110117 } , [ code , currentTarget ] ) ;
111118
@@ -177,6 +184,7 @@ export function CssRush({ gameDurationSeconds = 180 }: GameConfigProps) {
177184 code = { code }
178185 setDroppableRef = { setDroppableRef }
179186 activeId = { holdingBlockId }
187+ showSuccessFlash = { showSuccessFlash }
180188 />
181189 </ Droppable >
182190 </ div >
0 commit comments