Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
added activeStepColor prop to ProgressTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
qubis741 committed Sep 8, 2023
1 parent cb6c64f commit f058ec0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/progressTracker/ProgressTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface ProgressTrackerProps {
children?: ReactNode;
/** Color theme of the progress tracker. */
color?: typeof COLORS[number];
/** Color of the progress step. */
activeStepColor?: string;
/** Where to position the labels. Alternating allows for wider labels. */
labelPosition?: 'top' | 'alternating' | 'bottom';
}
Expand All @@ -26,19 +28,21 @@ const ProgressTracker: GenericComponent<ProgressTrackerProps> & { ProgressStep:
currentStep = 0,
done,
labelPosition = 'top',
activeStepColor,
}: ProgressTrackerProps) => {
const classNames = cx(theme['tracker'], theme[color], theme[`tracker-${labelPosition}`]);

return (
<Box data-teamleader-ui="progress-tracker" className={classNames}>
{React.Children.map(children, (child, index) => {
const activeStep = Math.max(0, currentStep);
const isActiveStep = index === activeStep;
const childProps = React.isValidElement(child) && child.props;

const hasColoredActiveStep = isActiveStep && activeStepColor && !done;
return (
<ProgressStep
active={done ? false : index === activeStep}
active={done ? false : isActiveStep}
completed={done || index < activeStep}
color={hasColoredActiveStep ? activeStepColor : ''}
{...childProps}
/>
);
Expand Down

0 comments on commit f058ec0

Please sign in to comment.