Skip to content

Commit 23ac629

Browse files
authored
Merge pull request #286 from Soohyuniii/feat--폼-변경사항-적용
feat: 친구저장 폼 항목 변경
2 parents a44d4d7 + 2d72390 commit 23ac629

File tree

2 files changed

+48
-66
lines changed

2 files changed

+48
-66
lines changed

src/components/button/FormButton.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@ const FormButton = ({
1313
children,
1414
onClick
1515
}: FormButtonProps) => {
16-
const baseStyles = "flex justify-center items-center rounded-lg transition";
16+
const baseStyles =
17+
"flex justify-center items-center rounded-lg transition-colors transform-none focus:transform-none active:transform-none select-none";
1718

1819
const sizeStyles =
1920
size === "sm" ? "min-w-[68px] w-auto h-[40px]" : "w-[70px] h-[72px]";
2021

21-
const fontSize =
22-
size === "md"
23-
? "text-[var(--text-2xl)]"
24-
: selected
25-
? "text-[16px]"
26-
: "text-[14px]";
22+
const getFontSize = () => {
23+
if (size === "md") return "text-[var(--text-2xl)]";
24+
25+
// 긴 텍스트인 경우 작은 폰트 적용
26+
const isLongText = children.length > 4;
27+
28+
if (selected) {
29+
return isLongText ? "text-[13px]" : "text-[16px]";
30+
} else {
31+
return isLongText ? "text-[12px]" : "text-[14px]";
32+
}
33+
};
34+
35+
const fontSize = getFontSize();
2736

2837
const fontWeight =
2938
size === "md" ? "font-bold" : selected ? "font-bold" : "font-medium";
@@ -34,8 +43,9 @@ const FormButton = ({
3443

3544
return (
3645
<button
37-
className={`${baseStyles} ${sizeStyles} ${fontSize} ${fontWeight} ${backgroundColor} ${borderColor} ${fontColor} border`}
46+
className={`${baseStyles} ${sizeStyles} ${fontSize} ${fontWeight} ${backgroundColor} ${borderColor} ${fontColor} border leading-none`}
3847
onClick={onClick}
48+
style={{ lineHeight: "1" }}
3949
>
4050
{children}
4151
</button>

src/pages/SelectInfo.tsx

Lines changed: 30 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ const SelectInfo = () => {
7979
const [name, setName] = useState<string>("");
8080
const [age, setAge] = useState<string | null>(null);
8181
const [gender, setGender] = useState<string | null>(null);
82-
const [relationship, setRelationship] = useState<string | null>(null);
83-
const [interest, setInterest] = useState<string[]>([]);
82+
const [job, setJob] = useState<string | null>(null);
83+
const [freeSetting, setFreeSetting] = useState<string>("");
8484
const [toastMessage, setToastMessage] = useState<string | null>(null);
8585

8686
useEffect(() => {
@@ -97,27 +97,15 @@ const SelectInfo = () => {
9797
const mbtiOptions = ["E", "N", "F", "P", "I", "S", "T", "J"];
9898
const ageOptions = ["10대", "20대", "30대 이상"];
9999
const genderOptions = ["여자", "남자"];
100-
const relationshipOptions = [
101-
"부모",
102-
"자녀",
103-
"친구",
104-
"짝사랑",
105-
"이별",
106-
"연인",
107-
"선생님",
108-
"직장동료"
109-
];
110-
const interestOptions = [
111-
"연애",
112-
"결혼",
113-
"취미",
114-
"사회생활",
115-
"여행",
116-
"운동",
117-
"심리",
118-
"뷰티/패션",
119-
"음식",
120-
"인간관계"
100+
const jobOptions = [
101+
"연습생",
102+
"아이돌",
103+
"스포츠선수",
104+
"배우",
105+
"작가",
106+
"스트리머",
107+
"유튜버",
108+
"프로게이머"
121109
];
122110

123111
const handleMBTISelect = (option: string) => {
@@ -133,18 +121,8 @@ const SelectInfo = () => {
133121
return selectedMBTI[group] === option;
134122
};
135123

136-
const handleInterestSelect = (option: string) => {
137-
if (interest.includes(option)) {
138-
setInterest((prevInterests) =>
139-
prevInterests.filter((item) => item !== option)
140-
);
141-
} else {
142-
setInterest((prevInterests) => [...prevInterests, option]);
143-
}
144-
};
145-
146-
const isInterestSelected = (option: string) => {
147-
return interest.includes(option);
124+
const handleFreeSettingChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
125+
setFreeSetting(e.target.value);
148126
};
149127

150128
const handleNameChange = (e: ChangeEvent<HTMLInputElement>) => {
@@ -206,21 +184,21 @@ const SelectInfo = () => {
206184
const commonData = {
207185
gender: gender === "남자" ? "MALE" : gender === "여자" ? "FEMALE" : null,
208186
mbti,
209-
interests: interest
187+
freeSetting
210188
};
211189

212190
const selectedData = isVirtualFriend
213191
? {
214192
...commonData,
215193
friendName: name,
216194
age: mapAgeToNumber(age),
217-
relationship
195+
job
218196
}
219197
: {
220198
...commonData,
221199
fastFriendName: name,
222200
fastFriendAge: mapAgeToNumber(age),
223-
fastFriendRelationship: relationship
201+
fastFriendJob: job
224202
};
225203

226204
const apiUrl = isVirtualFriend ? "api/virtual-friend" : "api/fast-friend";
@@ -387,43 +365,37 @@ const SelectInfo = () => {
387365
</div>
388366
</div>
389367

390-
{/* 관계 선택 */}
368+
{/* 직업 선택 */}
391369
<div className="pt-[20px] pb-[20px]">
392370
<p className="text-2lg leading-[24px] font-bold tracking-[0em] text-gray-600">
393-
상대방과 나의 관계
371+
직업
394372
</p>
395373
<div className="grid grid-cols-4 gap-[16px] pt-[16px]">
396-
{relationshipOptions.map((option) => (
374+
{jobOptions.map((option) => (
397375
<FormButton
398376
key={option}
399377
size="sm"
400-
selected={relationship === option}
401-
onClick={() =>
402-
handleButtonClick(option, setRelationship, relationship)
403-
}
378+
selected={job === option}
379+
onClick={() => handleButtonClick(option, setJob, job)}
404380
>
405381
{option}
406382
</FormButton>
407383
))}
408384
</div>
409385
</div>
410386

411-
{/* 관심사 선택 */}
387+
{/* 자유 설정 */}
412388
<div className="pt-[20px] pb-[26px]">
413389
<p className="text-2lg leading-[24px] font-bold tracking-[0em] text-gray-600">
414-
관심사
390+
자유 설정
415391
</p>
416-
<div className="grid grid-cols-4 gap-[16px] pt-[16px]">
417-
{interestOptions.map((option) => (
418-
<FormButton
419-
key={option}
420-
size="sm"
421-
selected={isInterestSelected(option)}
422-
onClick={() => handleInterestSelect(option)}
423-
>
424-
{option}
425-
</FormButton>
426-
))}
392+
<div className="pt-[8px]">
393+
<textarea
394+
value={freeSetting}
395+
onChange={handleFreeSettingChange}
396+
className="h-[92px] w-full resize-none overflow-y-auto rounded-lg border border-gray-300 px-4 py-4 text-sm focus:border-primary-light focus:ring-primary-light focus:outline-none"
397+
placeholder="상황, 상대방과의 관계, 세계관 등을 입력해주세요"
398+
/>
427399
</div>
428400
</div>
429401
</div>

0 commit comments

Comments
 (0)