Skip to content

Commit b9c2672

Browse files
authored
Added support for SSR
1 parent a376522 commit b9c2672

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<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

55
<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"/>
6+
<div>
7+
<img src="./src/assets/vertical-stepper-example.png" alt="" width="155" height="252"/>
88
</div>
9-
<div style="padding-left: 30px">
10-
<img src="./src/assets/horizontal-stepper-example.png" alt="" width="576" height="132"/>
9+
<div>
10+
<img src="./src/assets/horizontal-stepper-example.png" alt="" width="518" height="118"/>
1111
</div>
1212
</div>
1313
A fully customizable ready to use stepper UI package for React.
@@ -23,6 +23,8 @@ npm install @keyvaluesystems/react-stepper
2323

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

26+
Note for **Next.js** users, if you are using Next.js version 13 or later, you will have to use the `use client` feature to ensure proper compatibility.
27+
2628
## Usage
2729

2830
React Stepper can run in a very basic mode by just providing the `steps` and `currentStepIndex` props like this:
@@ -31,18 +33,18 @@ React Stepper can run in a very basic mode by just providing the `steps` and `cu
3133
<Stepper
3234
steps={[
3335
{
34-
label: "Step 1",
35-
description: "This is Step 1",
36+
stepLabel: "Step 1",
37+
stepDescription: "This is Step 1",
3638
completed: true,
3739
},
3840
{
39-
label: "Step 2",
40-
description: "This is Step 2",
41+
stepLabel: "Step 2",
42+
stepDescription: "This is Step 2",
4143
completed: false,
4244
},
4345
{
44-
label: "Step 3",
45-
description: "This is Step 3",
46+
stepLabel: "Step 3",
47+
stepDescription: "This is Step 3",
4648
completed: false,
4749
},
4850
]}
@@ -52,8 +54,8 @@ React Stepper can run in a very basic mode by just providing the `steps` and `cu
5254

5355
The `steps` array is an array of objects with following keys:
5456

55-
- `label` - A mandatory string representing the label/title of the step.
56-
- `description` - Optional extra information or description for the step.
57+
- `stepLabel` - A mandatory string representing the label/title of the step.
58+
- `stepDescription` - Optional extra information or description for the step.
5759
- `completed` - Boolean flag for indicating step completion status.
5860

5961
You can customize each step node with your own DOM element using the `renderNode` prop
@@ -62,7 +64,7 @@ You can customize each step node with your own DOM element using the `renderNod
6264
<Stepper
6365
steps={stepsArray}
6466
currentStepIndex={currentStepIndex}
65-
renderNode={(step, stepIndex) => <div key={stepIndex}>{step.label}</div>}
67+
renderNode={(step, stepIndex) => <div key={stepIndex}>{step.stepLabel}</div>}
6668
/>
6769
```
6870

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
"starter",
3131
"es6",
3232
"react",
33+
"nextJS",
3334
"typescript",
3435
"webpack",
3536
"steps",
3637
"stepper",
3738
"vertical-stepper",
38-
"horizontal stepper",
39+
"horizontal-stepper",
3940
"steps-ui",
4041
"workflow-stepper",
4142
"progress-ui"
@@ -77,7 +78,7 @@
7778
"react-scripts": "5.0.1",
7879
"sass": "^1.58.3",
7980
"sass-loader": "^13.2.0",
80-
"style-loader": "^3.3.1",
81+
"style-loader": "^3.3.3",
8182
"terser-webpack-plugin": "^5.3.5",
8283
"ts-jest": "^29.0.5",
8384
"ts-loader": "^9.4.2",

src/stepper/step.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Step: (props: IStepProps) => JSX.Element = ({
4242
const width = node.getBoundingClientRect().width;
4343
setNodeWidth(width);
4444
}
45-
}, [steps, nodeRef]);
45+
}, [steps]);
4646

4747
// prevConnector represents the connector line from the current step's node (nth node) to the preceding step's node (n-1 th node).
4848
const prevConnectorClassName = `stepConnector leftConnector ${

webpack.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ module.exports = {
3030
output: {
3131
filename: 'index.js',
3232
path: path.resolve(__dirname, 'build'),
33-
library: "MyLibrary",
33+
library: "React Stepper",
3434
libraryTarget: 'umd',
35-
clean: true
35+
clean: true,
36+
globalObject: 'this'
3637
},
3738
externals: {
3839
react: 'react'

0 commit comments

Comments
 (0)