-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 닉네임 설정 화면 UX 개선 및 리팩토링 #252
[REFACTOR] 닉네임 설정 화면 UX 개선 및 리팩토링
- Loading branch information
Showing
20 changed files
with
170 additions
and
63 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
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
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
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,2 @@ | ||
export const NICKNAME_MAX_LENGTH = 12; | ||
export const POLLING_DELAY = 1000; |
This file was deleted.
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 |
---|---|---|
|
@@ -34,5 +34,9 @@ | |
"nickname": "프콩", | ||
"isMaster": false | ||
} | ||
] | ||
], | ||
"master": { | ||
"memberId": 2, | ||
"nickname": "든콩" | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
frontend/src/pages/NicknamePage/NicknameInput/NicknameInput.styled.ts
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,26 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
import { Theme } from '@/styles/Theme'; | ||
|
||
export const nicknameInputContainer = css` | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
height: 4.8rem; | ||
padding: 0 1rem; | ||
border-radius: ${Theme.borderRadius.radius10}; | ||
background-color: ${Theme.color.gray200}; | ||
`; | ||
|
||
export const nicknameInput = css` | ||
width: 100%; | ||
border: 0; | ||
background-color: ${Theme.color.gray200}; | ||
outline: none; | ||
`; | ||
|
||
export const nicknameLengthText = css` | ||
color: ${Theme.color.gray500}; | ||
`; |
38 changes: 38 additions & 0 deletions
38
frontend/src/pages/NicknamePage/NicknameInput/NicknameInput.tsx
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,38 @@ | ||
import { RefObject } from 'react'; | ||
|
||
import useNicknameInput from './hooks/useNicknameInput'; | ||
import { nicknameInput, nicknameInputContainer, nicknameLengthText } from './NicknameInput.styled'; | ||
import createRandomNickname from '../createRandomNickname'; | ||
|
||
import { NICKNAME_MAX_LENGTH } from '@/constants/config'; | ||
|
||
interface NicknameInputProps { | ||
nicknameInputRef: RefObject<HTMLInputElement>; | ||
handleMakeOrEnterRoom: () => void; | ||
} | ||
|
||
const NicknameInput = ({ nicknameInputRef, handleMakeOrEnterRoom }: NicknameInputProps) => { | ||
const { nickname, handleChangeInput, handleKeyDown } = useNicknameInput({ | ||
handleMakeOrEnterRoom, | ||
}); | ||
const randomNickname = createRandomNickname(); | ||
|
||
return ( | ||
<div css={nicknameInputContainer}> | ||
<input | ||
ref={nicknameInputRef} | ||
css={nicknameInput} | ||
placeholder={randomNickname} | ||
maxLength={NICKNAME_MAX_LENGTH} | ||
value={nickname} | ||
onChange={handleChangeInput} | ||
onKeyDown={handleKeyDown} | ||
/> | ||
<span css={nicknameLengthText}> | ||
{nickname.length}/{NICKNAME_MAX_LENGTH} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default NicknameInput; |
27 changes: 27 additions & 0 deletions
27
frontend/src/pages/NicknamePage/NicknameInput/hooks/useNicknameInput.ts
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,27 @@ | ||
import { ChangeEvent, useState } from 'react'; | ||
|
||
import { NICKNAME_MAX_LENGTH } from '@/constants/config'; | ||
|
||
interface UseNicknameInputProps { | ||
handleMakeOrEnterRoom: () => void; | ||
} | ||
|
||
const useNicknameInput = ({ handleMakeOrEnterRoom }: UseNicknameInputProps) => { | ||
const [nickname, setNickname] = useState(''); | ||
|
||
const handleChangeInput = (e: ChangeEvent<HTMLInputElement>) => { | ||
if (e.target.value.length <= NICKNAME_MAX_LENGTH) { | ||
setNickname(e.target.value); | ||
} | ||
}; | ||
|
||
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (event.key === 'Enter') { | ||
handleMakeOrEnterRoom(); | ||
} | ||
}; | ||
|
||
return { nickname, handleChangeInput, handleKeyDown }; | ||
}; | ||
|
||
export default useNicknameInput; |
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
Oops, something went wrong.