728x90
next14 + tailwind
가로 프로그레스 바
const [_step, setStep] = useState(0);
const isRunAnimation = useMemo(() => {
if (step !== _step) {
setStep(step);
return true;
} else {
return false;
}
}, [step]);
<div className="z-[501] bg-white px-10 py-4">
<div className="relative h-1 rounded-full bg-gray-300">
<div
className="h-full rounded-lg bg-orange-700 transition-all duration-300"
style={{ width: `${step * 23}%` }}
/>
{!isCompleted && (
<div
style={{
animation: `${animation.pulse} 0.7s both`,
animationPlayState: isRunAnimation ? "running" : "paused",
}}>
<BasicTooltip
isVisible={true}
description="+1,500원"
caretVerticalPosition="top"
caretHorizontalPosition="right"
positionOption="right-[-20px] top-[15px]"
/>
</div>
)}
</div>
</div>
재사용가능한 컴포넌트로 만들기 위해서 step값을 props로 받아서 사용했다.
세로 프로그레스바
<div className="relative h-12 w-1.5 rounded-[50px] bg-gray-200">
<div
className={cx(
"absolute bottom-0 w-full rounded-[50px] transition-all duration-300",
// 가장 높은 값을 가진 프로그래스 바의 색을 변경하기 위함
maxTotalCount && maxTotalCount === info.totalCount ? "bg-orange-900 " : "bg-gray-400")}
style={{ height: `${maxHeight(info.totalCount)}%`}}
/>
</div>
728x90
'FE' 카테고리의 다른 글
[zustand]WEEK2 미들웨어 redux.ts와 subscribewithSelector.ts (0) | 2025.07.02 |
---|---|
[zustand]WEEK1 vanilla.ts로 zustand의 핵심 로직 파헤치기 (1) | 2025.07.02 |
CSS & tailwind -정사각형 이미지 만들기 (0) | 2023.12.29 |
CSS - Reset vs Normalize CSS: 웹 스타일링 초기화 방법 비교 (0) | 2023.08.30 |
JS - dangerouslySetInnerHTML 문자열로 출력된 html렌더링 (0) | 2023.04.20 |