Skip to content

Commit b0c720b

Browse files
JosanghyeonJosanghyeon
authored andcommitted
Merge remote-tracking branch 'origin/main' into main
2 parents 872f187 + 3c7920d commit b0c720b

File tree

2 files changed

+132
-18
lines changed

2 files changed

+132
-18
lines changed

docs/CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
## [1.3.5](https://github.com/team-aliens/design-system/compare/v1.3.4...v1.3.5) (2022-12-27)
2+
3+
4+
### Bug Fixes
5+
6+
* x,y 좌표 수정 ([84e0d59](https://github.com/team-aliens/design-system/commit/84e0d59bda9539531303dc29c9f40cf915534fda))
7+
8+
## [1.3.4](https://github.com/team-aliens/design-system/compare/v1.3.3...v1.3.4) (2022-12-27)
9+
10+
11+
### Bug Fixes
12+
13+
* studyRoom selected 로직 수정 ([f9e926d](https://github.com/team-aliens/design-system/commit/f9e926d6cf6e5513c66c2555227884ece773c753))
14+
15+
## [1.3.3](https://github.com/team-aliens/design-system/compare/v1.3.2...v1.3.3) (2022-12-27)
16+
17+
18+
### Bug Fixes
19+
20+
* width와 height에 -1를 하여 발생하는 에러 수정 ([cec1026](https://github.com/team-aliens/design-system/commit/cec1026e261d3562f7ae84fa5fb314fa59d983c1))
21+
22+
## [1.3.2](https://github.com/team-aliens/design-system/compare/v1.3.1...v1.3.2) (2022-12-27)
23+
24+
25+
### Bug Fixes
26+
27+
* default value 추가 ([9ef1910](https://github.com/team-aliens/design-system/commit/9ef1910fc6d24bf945560f013a924d3afe8f4734))
28+
29+
## [1.3.1](https://github.com/team-aliens/design-system/compare/v1.3.0...v1.3.1) (2022-12-27)
30+
31+
32+
### Bug Fixes
33+
34+
* selectedPosition optional 처리 ([d696052](https://github.com/team-aliens/design-system/commit/d6960527a34994c65e5bbe2a96413a51ca0dcf6a))
35+
36+
# [1.3.0](https://github.com/team-aliens/design-system/compare/v1.2.12...v1.3.0) (2022-12-27)
37+
38+
39+
### Features
40+
41+
* 자습실 에디터 기능 추가 ([079a490](https://github.com/team-aliens/design-system/commit/079a490f4d856b2615dbf2331b8be9150ccfd9b1))
42+
43+
## [1.2.12](https://github.com/team-aliens/design-system/compare/v1.2.11...v1.2.12) (2022-12-27)
44+
45+
46+
### Bug Fixes
47+
48+
* studyRoom 색 수정 ([b2cd88b](https://github.com/team-aliens/design-system/commit/b2cd88bee8b80f10ffc1c57910792e992b7c3225))
49+
150
## [1.2.11](https://github.com/team-aliens/design-system/compare/v1.2.10...v1.2.11) (2022-12-27)
251

352

src/components/studyRoom/index.tsx

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,23 @@ interface PropsType {
3434
total_width_size: number;
3535
total_height_size: number;
3636
seats: seatType[];
37+
isEdit?: boolean;
38+
onClickSeat?: (xPosition: number, yPosition: number) => void;
39+
selectedPosition?: {
40+
x: number;
41+
y: number;
42+
};
3743
}
3844

45+
const arr2Generator = (x: number, y: number) => {
46+
let arr = [];
47+
for (let i = 0; i < x; i++) {
48+
arr[i] = [];
49+
for (let j = 0; j < y; j++) arr[i][j] = 0;
50+
}
51+
return arr;
52+
};
53+
3954
export const StudyRoom = ({
4055
east_description,
4156
west_description,
@@ -44,6 +59,12 @@ export const StudyRoom = ({
4459
total_height_size,
4560
total_width_size,
4661
seats,
62+
isEdit = false,
63+
onClickSeat = (x, y) => {},
64+
selectedPosition = {
65+
x: -1,
66+
y: -1,
67+
},
4768
}: PropsType) => {
4869
const arr2Generator = (x: number, y: number) => {
4970
let arr = [];
@@ -74,32 +95,64 @@ export const StudyRoom = ({
7495
{north_description}
7596
</_NorthDirection>
7697
<_Room>
77-
{arr.map((seat, idx) => (
98+
{arr.map((seatY, y) => (
7899
<_Seats>
79-
{seat.map((seat, idx) => (
100+
{seatY.map((seat, x) => (
80101
<>
81102
{seat ? (
82103
seat.number ? (
83-
<_Seat
84-
display="inline-block"
85-
background={seat.type.color || '#b1d0ff'}
86-
color="gray1"
87-
size="bodyS"
104+
<_SeatBlock
105+
isEdit={isEdit}
106+
isSelected={
107+
isEdit &&
108+
selectedPosition?.x === x &&
109+
selectedPosition?.y === y
110+
}
88111
>
89-
{seat.type ? seat.type.name : seat.number}
90-
</_Seat>
112+
<_Seat
113+
onClick={() => isEdit && onClickSeat(x, y)}
114+
display="inline-block"
115+
background={seat.type.color || '#b1d0ff'}
116+
color="gray1"
117+
size="bodyS"
118+
>
119+
{seat.type ? seat.type.name : seat.number}
120+
</_Seat>
121+
</_SeatBlock>
91122
) : (
92-
<_Seat
93-
display="inline-block"
94-
background={'gray4'}
95-
color="gray1"
96-
size="bodyS"
123+
<_SeatBlock
124+
isEdit={isEdit}
125+
isSelected={
126+
isEdit &&
127+
selectedPosition?.x === x &&
128+
selectedPosition?.y === y
129+
}
97130
>
98-
사용불가
99-
</_Seat>
131+
<_Seat
132+
onClick={() => isEdit && onClickSeat(x, y)}
133+
display="inline-block"
134+
background={'gray4'}
135+
color="gray1"
136+
size="bodyS"
137+
>
138+
사용불가
139+
</_Seat>
140+
</_SeatBlock>
100141
)
101142
) : (
102-
<_Seat background={'gray1'} />
143+
<_SeatBlock
144+
isEdit={isEdit}
145+
isSelected={
146+
isEdit &&
147+
selectedPosition?.x === x &&
148+
selectedPosition?.y === y
149+
}
150+
>
151+
<_Seat
152+
onClick={() => isEdit && onClickSeat(x, y)}
153+
background={'gray1'}
154+
/>
155+
</_SeatBlock>
103156
)}
104157
</>
105158
))}
@@ -112,6 +165,19 @@ export const StudyRoom = ({
112165

113166
const _Seats = styled.div`
114167
display: flex;
168+
overflow: hidden;
169+
`;
170+
171+
const _SeatBlock = styled.div<{
172+
isEdit: boolean;
173+
isSelected: boolean;
174+
}>`
175+
width: 100px;
176+
height: 100px;
177+
padding: 10px;
178+
border: 1px solid
179+
${({ theme, isSelected, isEdit }) =>
180+
isEdit ? (isSelected ? theme.color.primary : theme.color.gray4) : 'none'};
115181
`;
116182

117183
const _Seat = styled(Text)<{ background: string }>`
@@ -120,7 +186,6 @@ const _Seat = styled(Text)<{ background: string }>`
120186
display: flex;
121187
justify-content: center;
122188
align-items: center;
123-
margin: 10px;
124189
border-radius: 70%;
125190
background-color: ${({ background }) => background};
126191
`;

0 commit comments

Comments
 (0)