Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepper component #675

Open
wants to merge 15 commits into
base: release/1.1.0
Choose a base branch
from
Open
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
410 changes: 410 additions & 0 deletions example/src/components/StepperDemo.tsx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export { ButtonGroupDemo } from './ButtonGroupDemo';
export { CardDemo } from './CardDemo';
export { SkeletonDemo } from './SkeletonDemo';
export { LoadingSpinnerDemo } from './LoadingSpinnerDemo';
export { default as StepperDemo } from './StepperDemo';
121 changes: 121 additions & 0 deletions example/src/components/stepper.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
.dcx-stepper {
width: 100%;
margin-bottom: 40px;
}

.dcx-horizontal-stepper .dcx-header-container {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
flex-wrap: nowrap;
}

.dcx-vertical-stepper .dcx-header-container {
display: flex;
flex-direction: column;
align-items: flex-start;
}

.dcx-header-wrapper {
display: flex;
align-items: center;
margin-bottom: 10px;
}

.dcx-step-header {
cursor: pointer;
display: flex;
align-items: center;
font-weight: bold;
font-size: 16px;
color: #333;
}

.dcx-step-header .step-number {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #d1d0ce;
color: white;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
font-size: 14px;
font-weight: bold;
}

.dcx-step-header .step-number.active {
background-color: #1976d2;
}

.dcx-step-content {
display: none;
}

.dcx-step-content.dcx-visible-content {
display: block;
}

.dcx-content-container {
margin-top: 20px;
}

.step-button {
padding: 10px 20px;
font-size: 14px;
background-color: #1976d2;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin: 0 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s ease;
}

.step-button:hover {
background-color: #0056b3;
}

.step-button.submit {
background-color: #28a745;
}

.step-button.submit:hover {
background-color: #218838;
}

.custom-separator {
margin: 0 10px;
border: 0;
height: 1px;
background: #ccc;
}

.form-label {
display: flex;
flex-direction: column;
font-weight: bold;
}

.form-input,
.form-select,
.form-textarea {
padding: 8px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 4px;
}

.form-checkbox {
margin-top: 10px;
}

.custom-separator {
width: 100%;
border: 0;
border-top: 1px solid #ccc;
margin: 10px 0;
}
4 changes: 3 additions & 1 deletion example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
TableDemo,
ToggleDemo,
TooltipDemo,
LoadingSpinnerDemo
LoadingSpinnerDemo,
StepperDemo,
} from './components';
import { BrowserRouter, Route, Routes } from 'react-router-dom';

Expand Down Expand Up @@ -83,6 +84,7 @@ const App = () => (
<Route path="/paginator" element={<PaginatorDemo />} />
<Route path="/skeleton" element={<SkeletonDemo />} />
<Route path="/loadingSpinner" element={<LoadingSpinnerDemo />} />
<Route path="/stepper" element={<StepperDemo />} />
</Routes>
</BrowserRouter>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ export * from './card';
export * from './paginator';
export * from './skeleton';
export * from './spinner';
export * from './stepper';
14 changes: 14 additions & 0 deletions src/stepper/Step.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

type StepProps = React.HTMLAttributes<HTMLDivElement> & {
/**
* The children prop is an array of JSX elements that represent the content of the step.
*/
children: JSX.Element[];
};

export const Step = ({ children, ...rest }: StepProps) => (
<div {...rest}>
{children}
</div>
);
33 changes: 33 additions & 0 deletions src/stepper/StepContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { classNames } from '../common';

export type StepContentProps = {
/**
* it will allow to specify the content you prefer
*/
children?: any;
/**
* will allow to style the content of each step
*/
className?: string;
/**
* allow to show hide the content
*/
visible?: boolean;
};

export const StepContent = ({
children,
className,
visible,
}: StepContentProps) => (
<div
role="tabpanel"
className={classNames(['dcx-stepper-content', className])}
style={{
display: visible ? 'inherit' : 'none',
}}
>
{children}
</div>
);
50 changes: 50 additions & 0 deletions src/stepper/StepHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { useStepper } from './UseStepper';
import { classNames } from '../common';
export type StepHeaderProps = {
/**
* this will allow to pass a custom content to the header like a span or other.
* The container will be a button
*/
children?: JSX.Element;
/**
*
*/
headerClassName?: string;
/**
* you can define a custom separator between each steps
*/
separator?: JSX.Element;
/**
* internal usage to determine the content that need to be displayed
**/
_index?: number;
};


export const StepHeader = ({
_index,
separator,
children,
headerClassName,
...props
}: any) => {
const { changeActiveStep } = useStepper();
const headerClassNames = classNames([
'dcx-stepper-header-content',
headerClassName,
]);
return (
<>
<button
role="tab"
className={headerClassNames}
onClick={() => changeActiveStep(_index)}
{...props}
>
{children}
</button>
<>{separator}</>
</>
);
};
Loading