Skip to content

Commit 2b9d8fb

Browse files
authored
Merge pull request #46 from SWM-FIRE/FIRE-307-fe-모달창-ui-수정
Fire 307 fe 모달창 UI 수정
2 parents 26ad1dc + 5e01988 commit 2b9d8fb

File tree

6 files changed

+96
-71
lines changed

6 files changed

+96
-71
lines changed

src/components/layout/Modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ const ModalBox = styled.div`
6363
flex-direction: column;
6464
justify-content: center;
6565
align-items: center;
66-
top: 20rem;
66+
top: 16rem;
6767
padding: 9rem 3rem 7rem 3rem;
6868
`;

src/components/login/Avater.tsx

+24-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,38 @@ import MyAvatar from '../../assets/avatar/MyAvatar';
44
import UserStore from '../../stores/userStore';
55

66
export default function Avater() {
7-
const { avatar } = UserStore();
7+
const { avatar, setAvatar } = UserStore();
8+
const onClick = () => {
9+
const randomNumber = Math.floor(Math.random() * 30) + 1; // 1~30 사이 정수 생성
10+
setAvatar(JSON.stringify(randomNumber));
11+
console.log(avatar);
12+
};
813
return (
914
<AvatarContainer>
1015
<MyAvatar num={Number(avatar)} />
16+
<Button type="button" onClick={onClick}>
17+
아바타 재생성
18+
</Button>
1119
</AvatarContainer>
1220
);
1321
}
1422

1523
const AvatarContainer = styled.div`
16-
height: 4rem;
17-
width: 17rem;
24+
height: 23rem;
25+
display: flex;
26+
flex-direction: column;
27+
justify-content: center;
28+
align-items: center;
1829
svg {
19-
width: 100%;
20-
height: 100%;
30+
width: 80%;
31+
height: 80%;
2132
}
2233
`;
34+
35+
const Button = styled.button`
36+
width: 80%;
37+
font-size: 1.5rem;
38+
background-color: white;
39+
margin-top: 2rem;
40+
cursor: pointer;
41+
`;

src/components/login/Buttons.tsx

-34
This file was deleted.

src/components/login/LoginModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function LoginModal({
1212
return (
1313
<>
1414
<Vector src={vectors.Lamp} left={0} top={0} size={40} />
15-
<Vector src={vectors.Book} left={28.7} top={14.4} size={60} />
15+
<Vector src={vectors.Book} left={28.7} top={10.4} size={60} />
1616
<ModalTitle />
1717
<UserInput modalHandler={modalHandler} />
1818
</>

src/components/login/Nickname.tsx

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
export default function Nickname({
5+
newNickname,
6+
getData,
7+
}: {
8+
newNickname: string;
9+
getData: (_newNickname: string) => void;
10+
}) {
11+
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
12+
getData(event.target.value);
13+
};
14+
15+
return (
16+
<Component>
17+
<Input
18+
autoComplete="off"
19+
value={newNickname}
20+
onChange={onChange}
21+
placeholder="닉네임을 입력해주세요"
22+
id="nickname"
23+
/>
24+
<Button>확인</Button>
25+
</Component>
26+
);
27+
}
28+
29+
const Component = styled.div`
30+
display: flex;
31+
flex-direction: column;
32+
align-items: flex-end;
33+
justify-content: center;
34+
height: 12rem;
35+
width: 25rem;
36+
`;
37+
38+
const Input = styled.input`
39+
background-color: rgb(30, 41, 75);
40+
color: white;
41+
font-size: 1.7rem;
42+
text-justify: center;
43+
padding-left: 1rem;
44+
width: 100%;
45+
`;
46+
47+
const Button = styled.button`
48+
font-family: PretendardRegular;
49+
font-weight: 600;
50+
height: 6rem;
51+
width: 100%;
52+
border-radius: 0.8rem;
53+
font-size: 1.5rem;
54+
background-color: white;
55+
margin-top: 2rem;
56+
cursor: pointer;
57+
`;

src/components/login/UserInput.tsx

+13-30
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styled from 'styled-components';
55
import { v4 as uuidv4 } from 'uuid';
66
import UserStore from '../../stores/userStore';
77
import Avater from './Avater';
8-
import Buttons from './Buttons';
8+
import Nickname from './Nickname';
99

1010
export default function UserInput({
1111
modalHandler,
@@ -15,7 +15,10 @@ export default function UserInput({
1515
const navigate = useNavigate();
1616
const { nickname, uid, avatar, setNickname, setUid } = UserStore();
1717
const [newNickname, setNewNickname] = useState(nickname);
18-
console.log('newnickname ', newNickname);
18+
const getData = (newNickname) => {
19+
setNewNickname(newNickname);
20+
};
21+
1922
useEffect(() => {
2023
if (!localStorage.getItem('uid')) {
2124
const newUID = uuidv4();
@@ -43,7 +46,6 @@ export default function UserInput({
4346
const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
4447
event.preventDefault();
4548
if (newNickname === null) {
46-
console.log('으악');
4749
return false;
4850
}
4951
// socket connection
@@ -61,57 +63,38 @@ export default function UserInput({
6163
return true;
6264
};
6365

64-
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
65-
setNewNickname(event.target.value);
66-
};
67-
6866
return (
6967
<Form onSubmit={onSubmit}>
7068
<Settings>
7169
<Avater />
72-
<Input
73-
autoComplete="off"
74-
value={newNickname}
75-
onChange={onChange}
76-
placeholder="Enter Nickname"
77-
id="nickname"
78-
/>
70+
<Nickname getData={getData} newNickname={newNickname} />
7971
</Settings>
80-
<Buttons />
8172
{/* <Button>GitHub 계정</Button> */}
8273
</Form>
8374
);
8475
}
8576

8677
const Form = styled.form`
87-
margin-top: 15rem;
78+
margin-top: 4rem;
8879
display: flex;
8980
flex-direction: column;
90-
align-items: center;
81+
/* align-items: flex-end; */
9182
justify-content: center;
9283
z-index: 1001;
93-
width: 35rem;
94-
button,
95-
input {
84+
/* width: 40rem; */
85+
input,
86+
button {
9687
font-family: PretendardRegular;
9788
font-weight: 600;
9889
height: 6rem;
99-
width: 17rem;
10090
border-radius: 0.8rem;
10191
}
10292
`;
10393

10494
const Settings = styled.div`
95+
gap: 3rem;
10596
display: flex;
106-
align-items: center;
97+
align-items: flex-end;
10798
justify-content: space-between;
10899
width: 100%;
109100
`;
110-
111-
const Input = styled.input`
112-
background-color: rgb(30, 41, 75);
113-
color: white;
114-
font-size: 1.7rem;
115-
text-justify: center;
116-
padding-left: 1rem;
117-
`;

0 commit comments

Comments
 (0)