Skip to content

Commit a3c523d

Browse files
authored
Feat:Updated component to support props orientation: horizontal/vertical and label position: top/bottom/left/right wrt step node
1 parent 1b9edfa commit a3c523d

35 files changed

+1305
-437
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/build
99
/dist
1010
.rpt2_cache
11+
coverage
1112

1213
# misc
1314
.DS_Store

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at [email protected]. All
58+
reported by contacting the project team at [email protected]. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Francisco Hodge
3+
Copyright (c) 2023 Keyvalue Software Systems
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

PULL_REQUEST_TEMPLATE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!-- Thank you for contributing to @keyvaluesystems/react-stepper! -->
2+
<!-- Before submitting a pull request, please review our contributing guidelines. -->
3+
4+
5+
6+
## Pull Request Checklist
7+
8+
9+
10+
- [ ] **Read the contributing guidelines.**
11+
- [ ] **Linked to an issue:** Fixes # (replace with the issue number, if applicable)
12+
- [ ] **Branch is up-to-date with the base branch:** `main`
13+
- [ ] **Changes pass tests locally:** `npm test` or `yarn test`
14+
- [ ] **Documentation has been updated, if necessary**
15+
- [ ] **Code follows the style guide of the project**
16+
17+
18+
## Description
19+
20+
21+
22+
<!-- Provide a brief description of your changes. -->
23+
24+
25+
26+
## Screenshots (if applicable)
27+
28+
29+
30+
<!-- Add screenshots or GIFs to help explain your changes. -->
31+
32+
33+
34+
## Additional Notes
35+
36+
37+
38+
<!-- Any additional information you want to provide that is not covered by the checklist or description. -->
39+
40+
41+
42+
## Related Issues or PRs
43+
44+
45+
46+
<!-- If your pull request is related to any issue(s) or other pull request(s), mention them here. -->
47+
48+
49+
50+
## Reviewer Guidelines
51+
52+
53+
54+
<!-- Suggest specific areas of the codebase that you would like the reviewer to focus on. -->
55+
56+
57+
58+
## Testing Instructions
59+
60+
61+
62+
<!-- Provide step-by-step instructions on how to test your changes. -->
63+
64+
65+
66+
## Checklist for Reviewers
67+
68+
69+
70+
- [ ] Code follows project conventions and style
71+
- [ ] Changes do not introduce new warnings or errors
72+
- [ ] Unit tests cover the changes
73+
- [ ] Documentation is updated
74+
75+
76+
## By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.

README.md

Lines changed: 99 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,72 @@
1+
# React Stepper
12

2-
# React Vertical Stepper
3-
<a href="https://www.npmjs.com/package/@keyvaluesystems/react-vertical-stepper"><img src="https://badgen.net/npm/v/@keyvaluesystems/react-vertical-stepper?color=blue" alt="npm version"></a> <a href="https://www.npmjs.com/package/@keyvaluesystems/react-vertical-stepper" ><img src="https://img.shields.io/npm/dw/@keyvaluesystems/react-vertical-stepper?label=Downloads" /></a> <a href="https://github.com/KeyValueSoftwareSystems/react-vertical-stepper"><img src="https://github.com/KeyValueSoftwareSystems/react-vertical-stepper/actions/workflows/update-and-publish.yml/badge.svg" alt="" /></a>
3+
<a href="https://www.npmjs.com/package/@keyvaluesystems/react-stepper"><img src="https://badgen.net/npm/v/@keyvaluesystems/react-stepper?color=blue" alt="npm version"></a> <a href="https://www.npmjs.com/package/@keyvaluesystems/react-stepper" ><img src="https://img.shields.io/npm/dw/@keyvaluesystems/react-stepper?label=Downloads" /></a> <a href="https://github.com/KeyValueSoftwareSystems/react-stepper"><img src="https://github.com/KeyValueSoftwareSystems/react-stepper/actions/workflows/update-and-publish.yml/badge.svg" alt="" /></a>
44

5-
<div align="center">
6-
<img src="./src/assets/vertical-stepper-example.png" alt="" width="269" height="416"/>
5+
<div style="display: flex; align-items: center;">
6+
<div style="padding-left: 30px">
7+
<img src="./src/assets/vertical-stepper-example.png" alt="" width="173" height="281"/>
78
</div>
8-
9-
A fully customizable ready to use vertical stepper UI package for React.
10-
Try tweaking a vertical stepper using this codesandbox link <a href="https://codesandbox.io/s/vertical-stepper-demo-x24q7u" >here</a>
9+
<div style="padding-left: 30px">
10+
<img src="./src/assets/horizontal-stepper-example.png" alt="" width="576" height="132"/>
11+
</div>
12+
</div>
13+
A fully customizable ready to use stepper UI package for React.
14+
Try tweaking a stepper using this codesandbox link <a href="https://codesandbox.io/p/sandbox/react-stepper-zp2jrs?file=%2Fsrc%2FApp.js" >here</a>
1115

1216
## Installation
1317

18+
The easiest way to use react-stepper-ui-component is to install it from npm and build it into your app with Webpack.
19+
1420
```bash
15-
npm install react-vertical-stepper
21+
npm install @keyvaluesystems/react-stepper
1622
```
1723

1824
You’ll need to install React separately since it isn't included in the package.
1925

2026
## Usage
2127

22-
React Vertical Stepper can run in a very basic mode by just providing the `steps` and `currentStepIndex` props like this:
28+
React Stepper can run in a very basic mode by just providing the `steps` and `currentStepIndex` props like this:
2329

2430
```jsx
25-
import React, { useState } from 'react';
26-
import Stepper from 'react-vertical-stepper';
27-
28-
function App() {
29-
const [currentStepIndex, setCurrentStepIndex] = useState(0);
30-
31-
stepsArray = [{
32-
label: 'Step 1',
33-
description: 'This is Step 1',
34-
status: 'completed'
35-
},{
36-
label: 'Step 2',
37-
description: 'This is Step 2',
38-
status: 'visited'
39-
},{
40-
label: 'Step 3',
41-
description: 'This is Step 3',
42-
status: 'unvisited'
43-
}];
44-
45-
return (
46-
<Stepper
47-
steps={stepsArray}
48-
currentStepIndex={currentStepIndex}
49-
/>
50-
);
51-
}
52-
53-
export default App;
31+
<Stepper
32+
steps={[
33+
{
34+
label: "Step 1",
35+
description: "This is Step 1",
36+
completed: true,
37+
},
38+
{
39+
label: "Step 2",
40+
description: "This is Step 2",
41+
completed: false,
42+
},
43+
{
44+
label: "Step 3",
45+
description: "This is Step 3",
46+
completed: false,
47+
},
48+
]}
49+
currentStepIndex={1}
50+
/>
5451
```
55-
The `steps` array is an array of objects with basic keys like
5652

57-
- `label` - a string that can be shown as step label title to your step indicator
58-
- `description` - a string that can be show as step description below the step label
59-
- `status` - can be provided with any of `visited`, `unvisited`, `completed`. Will be required if you are using default styles.
53+
The `steps` array is an array of objects with following keys:
6054

61-
>Note: You can also add any other keys to the step object and other statuses like `skipped` for different customizations as per requirements
55+
- `label` - A mandatory string representing the label/title of the step.
56+
- `description` - Optional extra information or description for the step.
57+
- `completed` - Boolean flag for indicating step completion status.
6258

63-
You can customize the step indicator bubble with your own DOM element using the `renderBubble` prop
59+
You can customize each step node with your own DOM element using the `renderNode` prop
6460

6561
```jsx
6662
<Stepper
6763
steps={stepsArray}
6864
currentStepIndex={currentStepIndex}
69-
renderBubble={(step, stepIndex) => (<div key={stepIndex}>{step.label}</div>)}
65+
renderNode={(step, stepIndex) => <div key={stepIndex}>{step.label}</div>}
7066
/>
7167
```
72-
The `step` param provided by the `renderBubble` callback is the same object you pass as array item in `steps` prop.
68+
69+
The `step` param provided by the `renderNode` callback is the same object you pass as array item in `steps` prop.
7370

7471
## Props
7572

@@ -90,31 +87,52 @@ Props that can be passed to the component are listed below:
9087
<td><code>undefined</code></td>
9188
</tr>
9289
<tr>
93-
<td><code><b>currentIndex:</b> number</code></td>
90+
<td><code><b>currentStepIndex:</b> number</code></td>
9491
<td>The index of current active step.</td>
9592
<td><code>0</code></td>
9693
</tr>
9794
<tr>
9895
<td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
9996
<td>
100-
A step click handler that fires each time you click on a step, its label or its description.
97+
A step click handler that fires each time you click on a step.
10198
</td>
10299
<td><code>undefined</code></td>
103100
</tr>
104101
<tr>
105-
<td><code><b>renderBubble?:</b> (step: object, stepIndex: number): ReactElement</code></td>
102+
<td><code><b>renderNode?:</b> (step: object, stepIndex: number): ReactElement</code></td>
106103
<td>
107-
A render function to customize your step indicator with your own element.
104+
A render function to customize each step node with your own element.
108105
</td>
109106
<td><code>undefined</code></td>
110107
</tr>
111108
<tr>
112-
<td><code><b>labelPosition?:</b> 'left' | 'right'</code></td>
109+
<td><code><b>orientation?:</b> 'horizontal' | 'vertical'</code></td>
110+
<td>
111+
Determines the layout of the stepper.
112+
</td>
113+
<td><code>vertical</code></td>
114+
</tr>
115+
<tr>
116+
<td><code><b>labelPosition?:</b> 'left' | 'right' | 'top' | 'bottom'</code></td>
113117
<td>
114-
Allows you to align step label and description to either <code>left</code> or <code>right</code> of step indicator
118+
Allows you to align step label and description with respect to its node
115119
</td>
116120
<td><code>right</code></td>
117121
</tr>
122+
<tr>
123+
<td><code><b>showDescriptionsForAllSteps</b> boolean</code></td>
124+
<td>
125+
A boolean prop specifying whether to show descriptions for all steps within the stepper.
126+
</td>
127+
<td><code>false</code></td>
128+
</tr>
129+
<tr>
130+
<td><code><b>stepContent</b>(step: object, stepIndex: number): ReactElement</code></td>
131+
<td>
132+
Prop that allows for dynamic content display when the step is active
133+
</td>
134+
<td><code>undefined</code></td>
135+
</tr>
118136
<tr>
119137
<td><code><b>styles?:</b> object</code></td>
120138
<td>
@@ -127,44 +145,43 @@ Props that can be passed to the component are listed below:
127145

128146
## Style Customizations
129147

130-
All the default styles provided by this package are overridable using the `style` prop
131-
the below code shows all the overridable styles:
148+
All the default styles provided by this package can be overridden using the `style` prop
149+
the below code shows all the styles that can be overridden:
132150

133151
```jsx
134-
import React from 'react';
135-
import Stepper from 'react-vertical-stepper';
152+
import React from "react";
153+
import Stepper from "react-stepper";
136154

137155
function App() {
138-
139-
const stylesOverride = {
140-
LabelTitle: (step, stepIndex) => ({...styles}),
141-
ActiveLabelTitle: (step, stepIndex) => ({...styles}),
142-
LabelDescription: (step, stepIndex) => ({...styles}),
143-
ActiveLabelDescription: (step, stepIndex) => ({...styles}),
144-
LineSeparator: (step, stepIndex) => ({...styles}),
145-
InactiveLineSeparator: (step, stepIndex) => ({...styles}),
146-
Bubble: (step, stepIndex) => ({...styles}),
147-
ActiveBubble: (step, stepIndex) => ({...styles}),
148-
InActiveBubble: (step, stepIndex) => ({...styles}),
149-
};
150-
return (
151-
<Stepper
156+
const stylesOverride = {
157+
LabelTitle: (step, stepIndex) => ({ ...styles }),
158+
ActiveLabelTitle: (step, stepIndex) => ({ ...styles }),
159+
LabelDescription: (step, stepIndex) => ({ ...styles }),
160+
ActiveLabelDescription: (step, stepIndex) => ({ ...styles }),
161+
LineSeparator: (step, stepIndex) => ({ ...styles }),
162+
InactiveLineSeparator: (step, stepIndex) => ({ ...styles }),
163+
Node: (step, stepIndex) => ({ ...styles }),
164+
ActiveNode: (step, stepIndex) => ({ ...styles }),
165+
InActiveNode: (step, stepIndex) => ({ ...styles }),
166+
};
167+
return (
168+
<Stepper
152169
steps={stepsArray}
153170
currentStepIndex={currentStepIndex}
154171
styles={stylesOverride}
155-
/>
156-
);
172+
/>
173+
);
157174
}
158175

159176
export default App;
160177
```
161-
162-
- `LabelTitle` - overrides the step label style
163-
- `ActiveLabelTitle` - overrides the step label style of current active step
164-
- `LabelDescription` - overrides the step description style
165-
- `ActiveLabelDescription` - overrides the step description style of current active step
166-
- `LineSeparator` - overrides default step connector line styles
167-
- `InactiveLineSeparator` - overrides styles of step connector line after current active step
168-
- `Bubble` - overrides default styles of step indicator
169-
- `ActiveBubble` - overrides default styles of step indicator of current active step
170-
- `InActiveBubble` - overrides default styles of step indicator that has `unvisited` step status
178+
179+
- `LabelTitle` - overrides the step label style
180+
- `ActiveLabelTitle` - overrides the step label style of current active step
181+
- `LabelDescription` - overrides the step description style
182+
- `ActiveLabelDescription` - overrides the step description style of current active step
183+
- `LineSeparator` - overrides default step connector line styles
184+
- `InactiveLineSeparator` - overrides styles of step connector line after current active step
185+
- `Node` - overrides default styles of step indicator
186+
- `ActiveNode` - overrides default styles of step indicator of current active step
187+
- `InActiveNode` - overrides default styles of step indicator that is not completed and not active

STYLE_GUIDELINES.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## SCSS Style Guidelines for @keyvaluesystems/react-stepper
2+
3+
**Introduction**
4+
5+
As an open-source project utilizing SCSS, @keyvaluesystems/react-stepper strives to maintain a consistent and well-structured codebase. These SCSS style guidelines serve as a reference for contributors, ensuring that their SCSS code adheres to established conventions and best practices.
6+
7+
**SCSS Coding Conventions**
8+
9+
- Organize SCSS files into a logical structure.
10+
- Use meaningful and descriptive names for variables, mixins, and classes.
11+
- Use SCSS nesting judiciously to organize complex styles.
12+
- Include comments to explain non-obvious logic and complex styles.
13+
- Utilize SCSS variables to define reusable values.
14+
- Employ a SCSS linting tool.
15+
- Should support devices with all resolutions
16+
- Follow CamelCase conventions for class names that concisely convey their purpose, enhancing code organization and readability
17+
- Adhere to the practice of reusing style classes to improve code organization and maintainability.
18+
19+
**Documentation Practices**
20+
21+
- Provide clear documentation for exported mixins and variables.
22+
- Include a README file within the SCSS directory if necessary.
23+
- Add comments to SCSS files.

0 commit comments

Comments
 (0)