Skip to content

Commit

Permalink
client: add shake animation to claim username
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Lal committed May 14, 2024
1 parent 93e34a6 commit ba66c5a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions client/src/components/card/claim-username.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
import "./claim-username.css"
import { useCallback, useState } from "react"
import { PiArrowUpRightBold } from "react-icons/pi"
// import { LoadingSVG } from "../loading/svg"

const ClaimUsername = () => {
const [isSubmitted, setIsSubmitted] = useState(false);
const [username, setUsername] = useState('');

const handleKeyPress = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === ' ') e.preventDefault();
}, []);

const handleUsernameSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setIsSubmitted(true);
setTimeout(() => setIsSubmitted(false), 500);

if (username.trim()) {

}
}

return (
<form id='claim-username' onSubmit={handleUsernameSubmit}>
<p>Get Started</p>
<div className='username-input'>
<div className={`username-input ${isSubmitted && !username.trim() ? "shake" : ""}`}>
<span className='domain'>debatehive.com/</span>
<input placeholder='johndoe' />
<input
placeholder='johndoe'
value={username}
onChange={e => setUsername(e.target.value)}
onKeyPress={handleKeyPress}
style={{ border: isSubmitted && !username.trim() ? "2px dotted white" : "" }}
/>
</div>
<button className='submit-btn'>
<span>CLAIM USERNAME</span>
Expand Down

0 comments on commit ba66c5a

Please sign in to comment.