Skip to content

Commit

Permalink
Merge pull request #159 from bsideproject/moon
Browse files Browse the repository at this point in the history
[feat] Stepper Component 수정
  • Loading branch information
KinDDoGGang authored Sep 24, 2023
2 parents d6daaf5 + 3d1f178 commit 9a161f2
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions components/Stepper2/Stepper2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,45 @@ interface StepperProps {
callbackCount?: (count: number) => void;
}

/**
* @see Stepper + - Component
*/
export default function Stepper2({ disabled, disabledLeft, disabledRight, initCount, callbackCount }: StepperProps) {
const [count, setCount] = useState(initCount || 0);

useEffect(() => {
setCount(initCount);
}, [initCount]);

const sendCount = (count: number) => {
callbackCount?.(count);
const sendCount = (_count: number) => {
callbackCount?.(_count);
};

return (
<div className={styles.stepper_container}>
<button
type="button"
className={`${styles.rounded} ${(disabled || disabledLeft) && styles.disabled } `}
onClick={() => { setCount(count - 1); sendCount(count-1); return;}}
className={`${styles.rounded} ${(disabled || disabledLeft) && styles.disabled} `}
onClick={() => {
setCount(count - 1);
sendCount(count - 1);
}}
disabled={disabled || disabledLeft}
>-</button>
<span className='w-10 inline-block text-center font-bold text-g7'>{count}</span>
<button
>
-
</button>
<span className="w-10 inline-block text-center font-bold text-g7">{count}</span>
<button
type="button"
className={`${styles.rounded} ${(disabled || disabledRight) && styles.disabled } `}
onClick={() => { setCount(count + 1); sendCount(count+1); return;}}
className={`${styles.rounded} ${(disabled || disabledRight) && styles.disabled} `}
onClick={() => {
setCount(count + 1);
sendCount(count + 1);
}}
disabled={disabled || disabledRight}
>+</button>
>
+
</button>
</div>
);
};
}

0 comments on commit 9a161f2

Please sign in to comment.