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

Added color prop to ProgressStep and activeStepColor to ProgressTracker #2752

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

### Dependency updates

## [22.3.0] - 2023-09-08

### Added

`ProgressTracker`: `activeStepColor` prop. ([@qubis741](https://https://github.com/qubis741) in [#2752](https://github.com/teamleadercrm/ui/pull/2752))
`ProgressStep`: `color` prop. ([@qubis741](https://https://github.com/qubis741) in [#2752](https://github.com/teamleadercrm/ui/pull/2752))

## [22.2.2] - 2023-08-22

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@teamleader/ui",
"description": "Teamleader UI library",
"version": "22.2.2",
"version": "22.3.0",
"author": "Teamleader <development@teamleader.eu>",
"bugs": {
"url": "https://github.com/teamleadercrm/ui/issues"
Expand Down
10 changes: 7 additions & 3 deletions src/components/progressTracker/ProgressStep.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { ReactNode } from 'react';
import cx from 'classnames';
import React, { ReactNode } from 'react';
import theme from './theme.css';

import { GenericComponent } from '../../@types/types';
import Box from '../box';
import { TextSmall } from '../typography';
import { GenericComponent } from '../../@types/types';

export interface ProgressStepProps {
/** The label for the progress step */
Expand All @@ -15,6 +15,8 @@ export interface ProgressStepProps {
active?: boolean;
/** Whether or not the step has been completed */
completed?: boolean;
/** Color theme of the progress step. */
color?: string;
/** Callback function that is fired when the progress step is clicked */
onClick?: () => void;
}
Expand All @@ -24,16 +26,18 @@ const ProgressStep: GenericComponent<ProgressStepProps> = ({
meta,
active = false,
completed = false,
color = '',
onClick,
}: ProgressStepProps) => {
const classNames = cx(theme['step'], {
[theme['is-active']]: active,
[theme['is-completed']]: completed,
[theme['is-clickable']]: !!onClick,
[theme['has-meta']]: !!meta,
[theme['custom-color']]: !!color,
});
return (
<Box className={classNames}>
<Box className={classNames} style={{ '--step-color': color } as React.CSSProperties}>
<div className={theme['step-label-holder']}>
<TextSmall className={theme['step-label']}>{label}</TextSmall>
{meta && <TextSmall className={theme['step-meta']}>{meta}</TextSmall>}
Expand Down
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
21 changes: 20 additions & 1 deletion src/components/progressTracker/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

.status-bullet-halo {
transform: scale(0);
opacity: 0.5;
opacity: 0.6;
transition: transform var(--animation-duration) var(--animation-curve-default)
calc(var(--animation-duration) - 0.1s);
border-radius: 50%;
Expand Down Expand Up @@ -237,6 +237,25 @@
}
}

.custom-color {
&.is-completed,
&.is-active {
.status-bullet {
background-color: var(--step-color)!important;
}
}

&.is-active {
.status-bullet {
background-color: var(--step-color)!important;
}
}

.status-bullet-halo {
background-color: var(--step-color)!important;
}
}

.neutral .step {
&.is-completed,
&.is-active {
Expand Down