I created a progress bar component that takes props like color, height, value and max. Right now it shows one sigle progress bar and i am trying to group progress bar and group them by color. Here is my component
const ProgressBar = ({
heightSize,
value,
max,
...customProps
}) => {
const classes = classNames([
'my-ProgressBar',
{ [`my-ProgressBar--${heightSize}`]: heightSize },
customProps.className,
]);
const normalizedValue = (value / max) * 100;
return (
<progress
{...customProps}
style={{ color: customProps.color }}
className={classes}
max={100}
value={normalizedValue}
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={normalizedValue}
tabIndex="-1"
/>);
};
I am trying to update this component so that if i pass an array to this component, it'll return grouped progress bar. Here is one of my failed attempts.
const ProgressBar = (groups) => {
const GroupProgressBar= groups.map((group) => (
<div key={group.color}>
color: {group.color},
heightSize: {group.height},
value: {group.value},
color: {group.color}
</div>
));
return (
<progress
{...customProps}
style={{ color: group.color }}
className={classes}
max={100}
value={normalizedValue}
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={normalizedValue}
tabIndex="-1"
/>);
});
How do i udpate my component so it will work on groups?