-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
606 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import styles from './styles.module.scss'; | ||
|
||
const commands = [ | ||
"Type username into the field", | ||
"Type password into the field", | ||
"Press the login button" | ||
]; | ||
|
||
export default function DemoSection() { | ||
const [currentStep, setCurrentStep] = useState(0); | ||
const [username, setUsername] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [isAnimating, setIsAnimating] = useState(false); | ||
const [focusedField, setFocusedField] = useState(null); | ||
|
||
const simulateTyping = async (text, setter) => { | ||
for (let i = 0; i <= text.length; i++) { | ||
setter(text.slice(0, i)); | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const animationTimer = setInterval(async () => { | ||
setIsAnimating(true); | ||
|
||
switch (currentStep) { | ||
case 0: | ||
setFocusedField('username'); | ||
await simulateTyping('testuser', setUsername); | ||
break; | ||
case 1: | ||
setFocusedField('password'); | ||
await simulateTyping('********', setPassword); | ||
break; | ||
case 2: | ||
setFocusedField('login'); | ||
setTimeout(() => { | ||
setUsername(''); | ||
setPassword(''); | ||
setFocusedField(null); | ||
}, 1000); | ||
break; | ||
} | ||
|
||
setTimeout(() => { | ||
setIsAnimating(false); | ||
setCurrentStep((prev) => (prev + 1) % commands.length); | ||
}, 2000); | ||
}, 4000); | ||
|
||
return () => clearInterval(animationTimer); | ||
}, [currentStep]); | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
}; | ||
|
||
return ( | ||
<div className={styles.demoContainer}> | ||
<div className={styles.demoCommands}> | ||
{commands.map((command, index) => ( | ||
<div | ||
key={index} | ||
className={`${styles.command} ${ | ||
currentStep === index ? styles.active : '' | ||
} ${isAnimating && currentStep === index ? styles.animating : ''}`} | ||
> | ||
{currentStep === index && isAnimating && ( | ||
<span className={styles.spinner}></span> | ||
)} | ||
{command} | ||
</div> | ||
))} | ||
</div> | ||
|
||
<div className={styles.demoInteractive}> | ||
<form onSubmit={handleSubmit} className={styles.loginForm}> | ||
<div className={styles.inputGroup}> | ||
<input | ||
type="text" | ||
value={username} | ||
readOnly | ||
placeholder="Username" | ||
className={`${styles.demoInput} ${focusedField === 'username' ? styles.focused : ''}`} | ||
tabIndex="-1" | ||
/> | ||
</div> | ||
<div className={styles.inputGroup}> | ||
<input | ||
type="password" | ||
value={password} | ||
readOnly | ||
placeholder="Password" | ||
className={`${styles.demoInput} ${focusedField === 'password' ? styles.focused : ''}`} | ||
tabIndex="-1" | ||
/> | ||
</div> | ||
<button | ||
type="submit" | ||
className={`${styles.demoButton} ${focusedField === 'login' ? styles.focused : ''}`} | ||
tabIndex="-1" | ||
> | ||
Login | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.