Skip to content

Commit 4728e32

Browse files
authored
Merge pull request #44 from boostcampwm-2022/feat/#43-S
Feat/#43-S : ์ƒ์„ฑ์™„๋ฃŒ ๋ชจ๋‹ฌ ๊ธฐ๋Šฅ ๊ตฌํ˜„
2 parents 60d0386 + a4cf20c commit 4728e32

File tree

6 files changed

+116
-23
lines changed

6 files changed

+116
-23
lines changed

โ€Žclient/src/components/WorkspaceModal/index.tsxโ€Ž

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1+
import { BiCopy } from '@react-icons/all-files/bi/BiCopy';
2+
import cx from 'classnames';
3+
14
import Button from '../common/Button';
25
import Modal from '../common/Modal';
36
import style from './style.module.scss';
47

58
interface WorkspaceModalProps {
69
title: string;
7-
text: string;
10+
texts: string[];
811
btnText: string;
912
inputValue: string;
1013
onChange?: (value: string) => void;
1114
onClose: () => void;
15+
onClick: () => void;
16+
isInputDisabled: boolean;
1217
}
1318

1419
function WorkspaceModal({
1520
title,
16-
text,
21+
texts,
1722
btnText,
1823
inputValue,
1924
onChange,
2025
onClose,
26+
onClick,
27+
isInputDisabled,
2128
}: WorkspaceModalProps) {
2229
const onInput = (e: React.ChangeEvent<HTMLInputElement>) => {
2330
if (onChange) onChange(e.target.value);
@@ -26,9 +33,28 @@ function WorkspaceModal({
2633
return (
2734
<Modal title={title} onClose={onClose}>
2835
<>
29-
<span className={style.text}>{text}</span>
30-
<input className={style.input} type="text" onChange={onInput} />
31-
<Button text={btnText} isDisabled={!inputValue.length} />
36+
{texts.map((text) => (
37+
<p key={text} className={style.text}>
38+
{text}
39+
</p>
40+
))}
41+
42+
<div className={style['input-section']}>
43+
{isInputDisabled && <BiCopy className={style['copy-icon']} />}
44+
<input
45+
className={cx(style.input, { [style.disabled]: isInputDisabled })}
46+
type="text"
47+
value={inputValue}
48+
onChange={onInput}
49+
disabled={isInputDisabled}
50+
/>
51+
</div>
52+
53+
<Button
54+
text={btnText}
55+
isDisabled={!inputValue.length}
56+
onClick={onClick}
57+
/>
3258
</>
3359
</Modal>
3460
);

โ€Žclient/src/components/WorkspaceModal/style.module.scssโ€Ž

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,29 @@
33
.text {
44
font-size: 14px;
55
}
6-
.input {
7-
width: calc(100% - 6rem);
8-
border: 1px solid $gray-100;
9-
border-radius: 10px;
10-
padding: 10px;
11-
font-size: 14px;
12-
margin: 15px 0;
6+
7+
.input-section {
8+
position: relative;
9+
width: 100%;
10+
text-align: center;
11+
12+
.copy-icon {
13+
position: absolute;
14+
top: 20px;
15+
right: 42px;
16+
cursor: pointer;
17+
}
18+
19+
.input {
20+
width: calc(100% - 6rem);
21+
border: 1px solid $gray-100;
22+
border-radius: 10px;
23+
padding: 10px;
24+
font-size: 14px;
25+
margin: 15px 0;
26+
}
27+
}
28+
29+
.disabled {
30+
text-align: center;
1331
}

โ€Žclient/src/components/common/Button/index.tsxโ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface ButtonProps {
1111
className?: string;
1212
isDisabled?: boolean;
1313
color?: string;
14+
onClick?: () => void;
1415
}
1516

1617
function Button({
@@ -20,16 +21,22 @@ function Button({
2021
className,
2122
isDisabled = false,
2223
color,
24+
onClick,
2325
}: ButtonProps) {
26+
const onClickBtn = () => {
27+
if (onClick) onClick();
28+
};
29+
2430
return href ? (
2531
<a href={href} className={cx(style.button, className)}>
2632
{icon}
2733
<span>{text}</span>
2834
</a>
2935
) : (
3036
<button
31-
className={cx(style.button, className)}
37+
className={cx(style.button, className, { disable: isDisabled })}
3238
disabled={isDisabled}
39+
onClick={onClickBtn}
3340
style={{ backgroundColor: color }}
3441
>
3542
{icon}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
1+
export const MENU = {
2+
CREATE_ID: 1,
3+
JOIN_ID: 2,
4+
JOIN_SUCCESS_ID: 3,
5+
};
6+
Object.freeze(MENU);
7+
18
export const MENUS = [
29
{ id: 1, text: '์ƒ์„ฑํ•˜๊ธฐ' },
310
{ id: 2, text: '์ฐธ์—ฌํ•˜๊ธฐ' },
411
];
12+
Object.freeze(MENUS);
513

614
export const MODAL_MENUS = [
715
{
816
id: 1,
917
props: {
1018
title: '์›Œํฌ์ŠคํŽ˜์ด์Šค ์ƒ์„ฑ',
11-
text: '์›Œํฌ์ŠคํŽ˜์ด์Šค ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.',
19+
texts: ['์›Œํฌ์ŠคํŽ˜์ด์Šค ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.'],
1220
btnText: '์ƒ์„ฑํ•˜๊ธฐ',
1321
},
1422
},
1523
{
1624
id: 2,
1725
props: {
1826
title: '์›Œํฌ์ŠคํŽ˜์ด์Šค ์ฐธ์—ฌ',
19-
text: '์›Œํฌ์ŠคํŽ˜์ด์Šค ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.',
27+
texts: ['์›Œํฌ์ŠคํŽ˜์ด์Šค ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.'],
2028
btnText: '์ฐธ์—ฌํ•˜๊ธฐ',
2129
},
2230
},
31+
{
32+
id: 3,
33+
props: {
34+
title: '์›Œํฌ์ŠคํŽ˜์ด์Šค ์ƒ์„ฑ ์™„๋ฃŒ',
35+
texts: [
36+
'์›Œํฌ์ŠคํŽ˜์ด์Šค๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.',
37+
' ๋ฉค๋ฒ„๋“ค์—๊ฒŒ ์ฐธ์—ฌ ์ฝ”๋“œ๋ฅผ ๊ณต์œ ํ•ด๋ณด์„ธ์š”.',
38+
],
39+
btnText: 'ํ™•์ธ',
40+
},
41+
},
2342
];
43+
Object.freeze(MODAL_MENUS);

โ€Žclient/src/pages/Workspace/index.tsxโ€Ž

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import SelcetModal from 'src/components/SelectModal';
33
import WorkspaceList from 'src/components/WorkspaceList';
44
import WorkspaceModal from 'src/components/WorkspaceModal';
5-
import { MENUS, MODAL_MENUS } from 'src/constants/workspace';
5+
import { MENU, MENUS, MODAL_MENUS } from 'src/constants/workspace';
66

77
import style from './style.module.scss';
88

@@ -19,6 +19,20 @@ function WorkspacePage() {
1919
setClickedMenuId(id);
2020
};
2121

22+
const onClickBtn = () => {
23+
if (clickedMenuId === MENU.CREATE_ID) {
24+
// ์ƒ์„ฑ ์™„๋ฃŒ ํ›„ ๋กœ์ง
25+
setClickedMenuId(MENU.JOIN_SUCCESS_ID);
26+
setInputValue('WAB123456'); // TODO: ๋ฐ›์•„์˜จ ์ฐธ์—ฌ์ฝ”๋“œ ๋„ฃ์–ด์ค„ ๊ฒƒ
27+
} else if (clickedMenuId === MENU.JOIN_ID) {
28+
// ์ฐธ์—ฌ ์™„๋ฃŒ ํ›„ ๋กœ์ง
29+
}
30+
};
31+
32+
useEffect(() => {
33+
if (clickedMenuId !== 3) setInputValue('');
34+
}, [clickedMenuId]);
35+
2236
return (
2337
<div className={style.container}>
2438
<WorkspaceList onSelectModalOpen={() => setIsOpenSelectModal(true)} />
@@ -37,15 +51,17 @@ function WorkspacePage() {
3751
</SelcetModal>
3852
)}
3953

40-
{MODAL_MENUS.map(({ id, props: { title, text, btnText } }) => {
54+
{MODAL_MENUS.map(({ id, props: { title, texts, btnText } }) => {
4155
if (id === clickedMenuId)
4256
return (
4357
<WorkspaceModal
4458
key={id}
45-
{...{ title, text, btnText }}
59+
{...{ title, texts, btnText }}
4660
inputValue={inputValue}
4761
onChange={onInput}
4862
onClose={() => setClickedMenuId(0)}
63+
onClick={onClickBtn}
64+
isInputDisabled={clickedMenuId === MENU.JOIN_SUCCESS_ID}
4965
/>
5066
);
5167
})}

โ€Žpackage-lock.jsonโ€Ž

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
ย (0)