refactor(welcome): Improve readability of sections

This commit is contained in:
alexsparkes
2024-02-19 19:51:12 +00:00
parent fc9d1c3f65
commit ffb1c513c9
13 changed files with 209 additions and 140 deletions

View File

@@ -1,22 +1,26 @@
import { memo } from 'react';
function ProgressBar({ count, currentTab, switchTab }) {
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">
{count.map((num) => {
let className = 'step';
const index = count.indexOf(num);
if (index === currentTab) {
className = 'step active';
}
return (
<div className={className} key={index} onClick={() => switchTab(index)}>
<span>{index + 1}</span>
</div>
);
})}
{Array.from({ length: numberOfTabs }, (_, index) => (
<Step
key={index}
isActive={index === currentTab}
index={index}
onClick={() => switchTab(index)}
/>
))}
</div>
);
}

View File

@@ -0,0 +1,7 @@
const Content = ({ children }) => {
return (
<div className="content">{children}</div>
)
}
export { Content as default, Content };

View File

@@ -1,12 +1,6 @@
const Panel = ({ children, type }) => (
<section className={type}>
{type === 'content' ? (
<div className="content">{children}</div>
) : type === 'aside' ? (
<>{children}</>
) : (
children
)}
{children}
</section>
);

View File

@@ -1,3 +1,4 @@
export * from './Wrapper';
export * from './Panel';
export * from './Header';
export * from './Header';
export * from './Content';