Skip to content

Commit bb4591d

Browse files
committed
feat: 투표 등록 전 UI 수정
1 parent 347897e commit bb4591d

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

client/src/components/Block/VoteBlock/VoteBlockTemplate.tsx

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -144,61 +144,65 @@ function VoteBlockTemplate({
144144

145145
return (
146146
<div className={style['vote-container']}>
147-
<h3 className={style.title}>투표</h3>
147+
<h3 className={style.title}>
148+
{isCreateMode ? '투표 등록중 ^^' : '투표'}
149+
</h3>
148150
{(isRegisteredMode || isEndMode) && (
149151
<span className={style['participant-cnt']}>
150152
{participantCount}명 참여
151153
</span>
152154
)}
153-
154-
<ul>
155-
{options.map(({ id, text, count }, index) => (
156-
<li
157-
className={cx('option-item', {
158-
'selected-item':
159-
(isRegisteredMode || isEndMode) && id === selectedOptionId,
160-
})}
161-
key={id}
162-
onClick={() => onSelect(id)}
163-
>
164-
{isEndMode && (
165-
<div
166-
className={style['vote-result-bar']}
167-
style={{
168-
width: `${getPercent(count)}%`,
169-
backgroundColor: color.highlight100,
170-
}}
171-
></div>
172-
)}
173-
174-
<div className={style['box-fill']}>{index + 1}</div>
175-
<input
176-
type="text"
177-
className={cx('option-input', {
178-
selected: isRegisteredMode,
155+
{isCreateMode ? (
156+
<></>
157+
) : (
158+
<ul>
159+
{options.map(({ id, text, count }, index) => (
160+
<li
161+
className={cx('option-item', {
162+
'selected-item':
163+
(isRegisteredMode || isEndMode) && id === selectedOptionId,
179164
})}
180-
placeholder="항목을 입력해주세요"
181-
onChange={onChange}
182-
data-id={id}
183-
readOnly={isRegisteredMode || isEndMode}
184-
defaultValue={text}
185-
/>
186-
{isRegisteringMode && (
187-
<Button
188-
icon={<BiX size="20" color="white" />}
189-
ariaLabel="항목 삭제"
190-
onClick={() => onDelete(id)}
165+
key={id}
166+
onClick={() => onSelect(id)}
167+
>
168+
{isEndMode && (
169+
<div
170+
className={style['vote-result-bar']}
171+
style={{
172+
width: `${getPercent(count)}%`,
173+
backgroundColor: color.highlight100,
174+
}}
175+
></div>
176+
)}
177+
178+
<div className={style['box-fill']}>{index + 1}</div>
179+
<input
180+
type="text"
181+
className={cx('option-input', {
182+
selected: isRegisteredMode,
183+
})}
184+
placeholder="항목을 입력해주세요"
185+
onChange={onChange}
186+
data-id={id}
187+
readOnly={isRegisteredMode || isEndMode}
188+
defaultValue={text}
191189
/>
192-
)}
193-
{isEndMode && (
194-
<div className={style['vote-result-text']}>
195-
{getVoteResultText(count)}
196-
</div>
197-
)}
198-
</li>
199-
))}
200-
</ul>
201-
190+
{isRegisteringMode && (
191+
<Button
192+
icon={<BiX size="20" color="white" />}
193+
ariaLabel="항목 삭제"
194+
onClick={() => onDelete(id)}
195+
/>
196+
)}
197+
{isEndMode && (
198+
<div className={style['vote-result-text']}>
199+
{getVoteResultText(count)}
200+
</div>
201+
)}
202+
</li>
203+
))}
204+
</ul>
205+
)}
202206
<div className={style['vote-buttons']}>
203207
{isRegisteringMode && (
204208
<>

0 commit comments

Comments
 (0)