1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/stepper/stepper.tsx
Janne Savolainen 589472c2b5
Shorten license header to reduce amount of clutter in top of the files (#4709)
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-01-18 10:18:10 +02:00

49 lines
1.3 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./stepper.scss";
import React from "react";
import { cssNames } from "../../utils";
export interface StepperProps extends React.HTMLProps<any> {
step: number;
steps: Step[];
}
interface Step {
title?: string;
}
export class Stepper extends React.Component<StepperProps, {}> {
render() {
const { className, steps, ...props } = this.props;
const stepsCount = steps.length;
let { step } = this.props;
step = Math.min(Math.max(1, step), stepsCount);
return (
<div {...props} className={cssNames("Stepper flex auto", className)}>
{steps.map(({ title }, i) => {
const stepNumber = i + 1;
const isLast = i === stepsCount - 1;
const stepClass = {
done: stepNumber < step,
active: stepNumber === step,
};
return (
<div key={i} className={cssNames("box step", stepClass)}>
{!isLast ? <span className="line"/> : null}
<div className="point">{stepNumber}</div>
<span className="step-title">{title}</span>
</div>
);
})}
</div>
);
}
}