Implement vertical stepper in create new project with template flow (#14)

* Implement vertical stepper in create project page

* Handle if active step is not found

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
Nabarun Gogoi 2023-12-20 16:30:08 +05:30 committed by GitHub
parent 237bd01159
commit cfb299c79e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 7 deletions

View File

@ -22,6 +22,7 @@
"react-tabs": "^6.0.2",
"react-timer-hook": "^3.0.7",
"typescript": "^4.9.5",
"vertical-stepper-nav": "^1.0.2",
"web-vitals": "^2.1.4"
},
"scripts": {

View File

@ -0,0 +1,49 @@
import React from 'react';
import { StepperNav } from 'vertical-stepper-nav';
const COLOR_COMPLETED = '#059669';
const COLOR_ACTIVE = '#CFE6FC';
const COLOR_NOT_STARTED = '#F1F5F9';
interface StepperValue {
step: number;
route: string;
label: string;
}
interface StepperProps {
activeStep: number;
stepperValues: StepperValue[];
}
const Stepper = ({ activeStep, stepperValues }: StepperProps) => {
return (
<StepperNav
steps={stepperValues.map((stepperValue: StepperValue) => {
return {
stepContent: () => (
<div
className={`text-sm ${
activeStep === stepperValue.step
? 'text-black font-semibold'
: 'text-gray-600'
}`}
>
{stepperValue.label}
</div>
),
stepStatusCircleSize: 30,
stepStateColor: `${
activeStep > stepperValue.step
? COLOR_COMPLETED
: activeStep === stepperValue.step
? COLOR_ACTIVE
: COLOR_NOT_STARTED
}`,
};
})}
/>
);
};
export default Stepper;

View File

@ -38,7 +38,7 @@ const CancelDeploymentDialog = ({
<Button variant="outlined" onClick={handleOpen} className="mr-1">
<span>Cancel</span>
</Button>
<Link to="/projects/create/template/">
<Link to="/projects/create/template">
<Button variant="gradient" color="red" onClick={handleOpen}>
<span>Yes, Cancel deployment</span>
</Button>

View File

@ -1,7 +1,23 @@
import React from 'react';
import { Outlet } from 'react-router-dom';
import React, { useMemo } from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import Stepper from '../../../components/Stepper';
const STEPPER_VALUES = [
{ step: 1, route: '/projects/create/template', label: 'Create repository' },
{ step: 2, route: '/projects/create/template/deploy', label: 'Deploy' },
];
const CreateWithTemplate = () => {
const location = useLocation();
const activeStep = useMemo(
() =>
STEPPER_VALUES.find((data) => data.route === location.pathname)?.step ??
0,
[location.pathname],
);
return (
<div className="flex flex-col items-center">
<div className="flex justify-between w-5/6 my-4 bg-gray-200 rounded-xl p-6">
@ -11,8 +27,7 @@ const CreateWithTemplate = () => {
</div>
<div className="grid grid-cols-3 w-5/6 p-6">
<div>
<div>1 Create repository</div>
<div>2 Deploy</div>
<Stepper activeStep={activeStep} stepperValues={STEPPER_VALUES} />
</div>
<div className="col-span-2">
<Outlet />

View File

@ -5488,7 +5488,7 @@ eslint-plugin-jest@^25.3.0:
dependencies:
"@typescript-eslint/experimental-utils" "^5.0.0"
eslint-plugin-jsx-a11y@^6.5.1:
eslint-plugin-jsx-a11y@^6.4.1, eslint-plugin-jsx-a11y@^6.5.1:
version "6.8.0"
resolved "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.8.0.tgz"
integrity sha512-Hdh937BS3KdwwbBaKd5+PLCOmYY6U4f2h9Z2ktwtNKvIdIEu137rjYbcb9ApSbVJfWxANNuiKTD/9tOKjK9qOA==
@ -12312,6 +12312,13 @@ vary@~1.1.2:
resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==
vertical-stepper-nav@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/vertical-stepper-nav/-/vertical-stepper-nav-1.0.2.tgz#788e057a8b59bc9073e87f422d231f78f87f307b"
integrity sha512-lCOcD2hGS7W9jOy/LIFMZU1/EgBFpSOyf78IqEsGGPcES6FrMMK3oh9HszxeUCE5X8c9q/RKl3bvmHOcuK4lSQ==
dependencies:
eslint-plugin-jsx-a11y "^6.4.1"
w3c-hr-time@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz"