Skip to content

Commit

Permalink
feat: Progressbar 관련 options 추가, 스타일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnks2U committed Sep 20, 2024
1 parent e2d1613 commit 04be11f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
18 changes: 14 additions & 4 deletions src/components/Progress/ProgressBar.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import React from 'react';
import React, { useEffect, useState } from 'react';

const ProgressBar = (props) => {
const { percent } = props;
const roundPercent = Math.round(percent);
const { percent, preset = 'default' } = props;
const [roundPercent, setRoundPercent] = useState(0);
const overHalf = roundPercent > 50;

useEffect(() => {
if (preset === 'full') {
setRoundPercent(100);
} else if (preset === 'fail') {
setRoundPercent(Math.round(0));
} else {
setRoundPercent(Math.round(percent));
}
}, [preset, percent]);

return (
<div className={`entry-modal-progressbar-wrapper`}>
<progress className={`entry-modal-progressbar`} value={roundPercent} max="100" />
Expand All @@ -13,7 +23,7 @@ const ProgressBar = (props) => {
overHalf ? 'entry-modal-text-invert' : ''
}`}
>
{roundPercent}%
{preset === 'fail' ? '!' : `${roundPercent}%`}
</div>
</div>
);
Expand Down
21 changes: 10 additions & 11 deletions src/components/Progress/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@ const Progress = (props) => {
],
options = {
btnAlignCol: false,
// style: { width, height }
// INFO: 예외상황은 progressPreset로, 일반적인 상황은 event.percent로 다룬다.
// progressPreset: 'full' | 'fail'
// event: { close, percent }
},
onEvent,
} = props;

// const { title, negativeButtonText, positiveButtonText } = useMemo(() => {
// return {
// title: props.title || getLang('General.progress_title', 'progress'),
// negativeButtonText: options.negativeButtonText || getLang('Buttons.cancel', 'cancel'),
// positiveButtonText:
// options.positiveButtonText || getLang('Buttons.course_done', 'cancel'),
// };
// }, [props.title, options]);

const [percent, setPercent] = useState(undefined);

const handleButtonClick = useCallback(
Expand Down Expand Up @@ -143,7 +137,10 @@ const Progress = (props) => {
>
{title}
</Title>
<div className={'entry-modal-contentView'}>
<div
className={'entry-modal-contentView'}
style={options?.style ? options.style : null}
>
<StepTitle
className={'entry-modal-stepTitle'}
titles={stepTitle.titles}
Expand All @@ -153,7 +150,9 @@ const Progress = (props) => {
{!!imageType && typeof imageType === 'string' && (
<ContentImage imageType={imageType} />
)}
{!!percent && <ProgressBar percent={percent} />}
{(!!percent || options.progressPreset) && (
<ProgressBar percent={percent} preset={options && options.progressPreset} />
)}
<div className={'entry-modal-button-group'}>
<Buttons
buttonInfos={buttonInfos}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Buttons = (props) => {
} = props;

return (
<div className={`${alignCol ? 'entry-modal-buttons-col' : ''}`}>
<div className={`${alignCol ? 'entry-modal-buttons-col' : 'entry-modal-buttons-row'}`}>
{buttonInfos.map((button, idx) => {
return (
<Button
Expand Down
12 changes: 8 additions & 4 deletions src/styles/entry/Progress.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.progress {
background: #fff;
width: 388px;
min-height: 203px;
min-width: 388px;
min-height: 278px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 6px;
Expand Down Expand Up @@ -51,7 +51,7 @@
align-items: center;

.content {
width: 320px;
min-width: 320px;
color: #2c313d;
font-family: NanumGothicOTF;
font-weight: bold;
Expand Down Expand Up @@ -185,13 +185,17 @@
height: 48px;
}
}

.buttons-row {
display: flex;
}
}

.progressbar-wrapper {
position: relative;
width: 300px;
height: 24px;
margin: 25px 0px 40px 0px;
margin: 25px 0px 0px 0px;
}

.progressbar {
Expand Down

0 comments on commit 04be11f

Please sign in to comment.