Changeset 64dc53b for components/LoginScreen.jsx
- Timestamp:
- 06/11/22 23:50:19 (2 years ago)
- Branches:
- main
- Children:
- 4a1a3ca
- Parents:
- 87614a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
components/LoginScreen.jsx
r87614a5 r64dc53b 2 2 3 3 import { useSelector, useDispatch } from 'react-redux' 4 5 import { useRef } from 'react' 4 6 5 7 import { setPlayer } from '../redux/reducers/playerSlice'; … … 9 11 10 12 const LoginScreen = () => { 13 const ref = useRef(null); 14 11 15 const dispatch = useDispatch(); 12 16 13 17 const playerState = useSelector(state => state.player); 14 18 const styleState = useSelector(state => state.style); 19 20 setTimeout(() => { 21 if (styleState.style.displayLoginScreen && styleState.style.loginScreenInfo.setFocus) { 22 ref.current.focus(); 23 dispatch(setStyle({ 24 ...styleState.style, 25 loginScreenInfo: { 26 ...styleState.style.loginScreenInfo, 27 setFocus: false 28 } 29 })) 30 } 31 }, 10); 15 32 16 33 function onChangeUsername(e) { … … 34 51 } 35 52 53 function keyUp(e) { 54 if (e.key === 'Enter') { 55 login(); 56 } 57 } 58 36 59 function closeForm() { 37 60 dispatch(setStyle({ … … 44 67 inlineAlertText: '', 45 68 })); 69 46 70 } 47 48 71 function login() { 49 72 dispatch(setStyle({ … … 119 142 <div> 120 143 <span>Username:</span> 121 <input type="text" onChange={(e) => {onChangeUsername(e)}} value={styleState.style.loginScreenInfo.username}/>144 <input ref={ref} type="text" onChange={(e) => {onChangeUsername(e)}} onKeyUp={(e) => keyUp(e)} value={styleState.style.loginScreenInfo.username} placeholder="your username..."/> 122 145 <span>Password:</span> 123 <input type="password" onChange={(e) => {onChangePassword(e)}} value={styleState.style.loginScreenInfo.password}/>146 <input type="password" onChange={(e) => {onChangePassword(e)}} onKeyUp={(e) => keyUp(e)} value={styleState.style.loginScreenInfo.password} placeholder="your password..."/> 124 147 <div style={{width: '100%', display: 'flex', flexDirection: 'row', justifyContent: 'space-between'}}> 125 148 <button className="primaryButton" onClick={() => closeForm()}>Close Form</button>
Note:
See TracChangeset
for help on using the changeset viewer.