mue/src/features/welcome/components/Elements/ProgressBar/ProgressBar.jsx

32 lines
739 B
React
Raw Normal View History

import { memo } from 'react';
2022-10-30 16:56:26 +00:00
const Step = memo(({ isActive, index, onClick }) => {
const className = isActive ? 'step active' : 'step';
return (
<div className={className} onClick={onClick}>
<span>{index + 1}</span>
</div>
);
});
function ProgressBar({ numberOfTabs, currentTab, switchTab }) {
return (
<div className="progressbar">
{Array.from({ length: numberOfTabs }, (_, index) => (
<Step
key={index}
isActive={index === currentTab}
index={index}
onClick={() => switchTab(index)}
/>
))}
</div>
);
}
2022-10-30 16:56:26 +00:00
const MemoizedProgressBar = memo(ProgressBar);
export default MemoizedProgressBar;
2024-03-19 21:45:17 +00:00
export { MemoizedProgressBar as ProgressBar };