Skip to content

Readme file creation #5

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
221463e
integrated step click handler
GokulSNath Feb 21, 2023
11b99c0
added step click integration for step label
GokulSNath Feb 21, 2023
8d10866
changed to styles in ts from css
GokulSNath Feb 21, 2023
e0e7711
started with customisation
GokulSNath Feb 21, 2023
89d9474
added customizations to all elements
GokulSNath Feb 21, 2023
a6c0d6a
fixed destructuring issue
GokulSNath Feb 22, 2023
a38db32
changed functional component tyoe
GokulSNath Feb 22, 2023
ad27483
added left and right alignment options for label
GokulSNath Feb 22, 2023
5d63c1e
moved constants file to a global constants file
GokulSNath Feb 22, 2023
a981261
Added Cutomisations and integrated step click handler
aarathyKeyvalue Feb 22, 2023
2ee9034
Sass-loader Integration
aarathyKeyvalue Feb 23, 2023
cf0fccc
Unit test cases - React testing library
aarathyKeyvalue Feb 23, 2023
80ec347
changed built in styles to scss
GokulSNath Feb 23, 2023
8e5bb9a
Merge branch 'main' of github.com:aarathyKeyvalue/vertical-stepper in…
GokulSNath Feb 23, 2023
4e861e2
changed props name and stepClick handle function params
GokulSNath Feb 23, 2023
0c52f63
changes as per PR comments
GokulSNath Feb 23, 2023
12e8d6a
Changed default styles in to scss and changed prop names
aarathyKeyvalue Feb 23, 2023
ccd8fcd
Git commit - changes to test file
aarathyKeyvalue Feb 23, 2023
adeb138
added readme file
GokulSNath Feb 24, 2023
c3fc5ea
Merge branch 'main' of github.com:aarathyKeyvalue/vertical-stepper in…
GokulSNath Feb 24, 2023
94ef29e
formatted readme file
GokulSNath Feb 24, 2023
da85b39
formatted readme file
GokulSNath Feb 24, 2023
12ad43e
changed style customization props
GokulSNath Feb 28, 2023
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
8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
"@typescript-eslint/explicit-function-return-type": "error",
"react/prop-types": "warn",
"indent": ["error", 2],
"arrow-body-style": ["error", "as-needed"]
"arrow-body-style": ["error", "as-needed"],
"no-trailing-spaces":"error",
"comma-dangle":"error",
"default-case":"error",
"block-spacing": "error",
"max-len":["warn", 150],
"space-before-blocks":"error"
},
"settings": {
"react": {
Expand Down
11 changes: 11 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
Expand All @@ -11,5 +12,15 @@ module.exports = {
"framework": "@storybook/react",
"core": {
"builder": "@storybook/builder-webpack5"
},
"webpackFinal": async (config) => {
config.module.rules.push({
rules: [{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: path.resolve(__dirname, '../')
}]
});
return config;
}
}
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// import './main.css';
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
Expand Down
195 changes: 151 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,174 @@
<div align="center">
<img align="center" width="230" src="https://i.imgur.com/iHgtvmg.png" />
<h2>Typescript Library Boilerplate Basic</h2>
<blockquote>Minimal Library Starter Kit for your Typescript projects</blockquote>

<a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a>

<strong>For a plain Javascript alternative, check out [js-library-boilerplate-basic](https://github.com/hodgef/js-library-boilerplate-basic).</strong>
# React Vertical Stepper
<!--
<a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a> -->

</div>

>A fully customizable ready to use vertical stepper UI package.

## ⭐️ Features

- Webpack 5
- Babel 7
- Hot reloading (`npm start`)
- Automatic Types file generation (index.d.ts)
- UMD exports, so your library works everywhere.
- Jest unit testing
- Customizable file headers for your build [(Example 1)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/index.js) [(Example2)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/css/index.css)
- Daily [dependabot](https://dependabot.com) dependency updates
## Installation

## 📦 Getting Started

```
git clone https://github.com/hodgef/ts-library-boilerplate-basic.git myLibrary
npm install
npm install react-vertical-stepper
```
You’ll need to install React separately since it isn't included in the package.

## 💎 Customization
## Usage

> Before shipping, make sure to:
React Vertical Stepper can run in a very basic mode by just providing the `steps` and `currentStepIndex` props like this:
```
import Stepper from 'react-vertical-stepper';

<Stepper
steps={stepsArray}
currentStepIndex={currentStepIndex}
/>
```
Here the steps array is an array of objects with basic keys like

1. Edit `LICENSE` file
2. Edit `package.json` information (These will be used to generate the headers for your built files)
3. Edit `library: "MyLibrary"` with your library's export name in `./webpack.config.js`
- `label` - a string that can be shown as step label title to your step indicator

## 🚀 Deployment
- `description` - a string that can be show as step description below the step label

1. `npm publish`
2. Your users can include your library as usual
- `status` - can be provided with any of `visited`, `unvisited`, `completed`. Will be required if you are using default styles.

### npm
> You can also add other keys to the step object and other statuses like `skipped` for different customizations as per requirements

An example for steps array is shown below:
```
import MyLibrary from 'my-library';
const libraryInstance = new MyLibrary();
...
stepsArray = [
{
label: 'Step 1',
description: 'This is Step 1',
status: 'visited'
},
{
label: 'Step 2',
description: 'This is Step 2',
status: 'unvisited'
},
{
label: 'Step 3',
description: 'This is Step 3',
status: 'completed'
}
];
```
You can use `onStepClick` event handler which fires each time you click on a step or its label or description
```
const [activeStepIndex, setActiveStepIndex] = useState(0);

### self-host/cdn
const handleStepClick = (step, stepIndex) => {
setActiveStepIndex(stepIndex);S
};

<Stepper
steps={stepsArray}
currentStepIndex={activeStepIndex}
onStepClick={handleStepClick}
/>
```
<script src="build/index.js"></script>

const MyLibrary = window.MyLibrary.default;
const libraryInstance = new MyLibrary();
...
You can also customize the step indicator bubble with your own DOM element using the `renderBubble` prop
```
<Stepper
steps={stepsArray}
currentStepIndex={currentStepIndex}
renderBubble={(step, stepIndex) => (<div key={stepIndex}>{step.label}</div>)}
/>
```

## ✅ Libraries built with this boilerplate

> Made a library using this starter kit? Share it here by [submitting a pull request](https://github.com/hodgef/ts-library-boilerplate-basic/pulls)!
>Note: The `step` param provided by the `renderBubble` callback is the same object you pass as array item in `steps` prop.

## Props

Props that can be passed to the component are listed below:

<table>
<thead>
<tr>
<th>Prop</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><b>steps:</b> object[]</code></td>
<td>
An array of step objects to render.
</td>
<td><code>undefined</code></td>
</tr>
<tr>
<td><code><b>currentIndex:</b> number</code></td>
<td>
The index of current active step.
</td>
<td>0</td>
</tr>
<tr>
<td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
<td>
A step click handler that fires each time you click on a step, its label or its description.
</td>
<td><code>undefined</code></td>
</tr>
<tr>
<td><code><b>renderBubble?:</b> (step: object, stepIndex: number): ReactElement</code></td>
<td>
A render function to customize your step indicator with your own element.
</td>
<td><code>undefined</code></td>
</tr>
<tr>
<td><code><b>labelPosition?:</b> 'left' | 'right'</code></td>
<td>
Allows you to align step label and description to either <code>left</code> or <code>right</code> of step indicator
</td>
<td><code>right</code></td>
</tr>
<tr>
<td><code><b>styles?:</b> object</code></td>
<td>
Provides you with a bunch of callback functions to override the default styles.
</td>
<td><code>undefined</code></td>
</tr>
</tbody>
</table>

## Style Customizations

All the default styles provided by this package are overridable using the `style` prop.
the below code shows all the overridable styles:
```
<Stepper
steps={stepsArray}
currentStepIndex={currentStepIndex}
styles={{
getLabelTitleStyles: (step, stepIndex) => ({...styles}),
getActiveLabelTitleStyles: (step, stepIndex) => ({...styles}),,
getLabelDescriptionStyles: (step, stepIndex) => ({...styles}),,
getActiveLabelDescriptionStyles: (step, stepIndex) => ({...styles}),,
getLineSeparatorStyles: (step, stepIndex) => ({...styles}),,
getInactiveLineSeparatorStyles: (step, stepIndex) => ({...styles}),,
getBubbleStyles: (step, stepIndex) => ({...styles}),,
getActiveBubbleStyles: (step, stepIndex) => ({...styles}),,
getInActiveBubbleStyles: (step, stepIndex) => ({...styles}),,
}}
/>
```

- [simple-keyboard](https://github.com/hodgef/simple-keyboard) - Javascript Virtual Keyboard
- [react-simple-keyboard](https://github.com/hodgef/react-simple-keyboard) - React Virtual Keyboard
- [simple-keyboard-layouts](https://github.com/hodgef/simple-keyboard-layouts) - Keyboard layouts for simple-keyboard
> All the `getXXStyles` functions can be passed optionally using `styles` prop and can be used to override specific css styles to the respective elements.

- `getLabelTitleStyles` - overrides the step label style
- `getActiveLabelTitleStyles` - overrides the step label style of current active step
- `getLabelDescriptionStyles` - overrides the step description style
- `getActiveLabelDescriptionStyles` - overrides the step description style of current active step
- `getLineSeparatorStyles` - overrides default step connector line styles
- `getInactiveLineSeparatorStyles` - overrides styles of step connector line after current active step
- `getBubbleStyles` - overrides default styles of step indicator
- `getActiveBubbleStyles` - overrides default styles of step indicator of current active step
- `getInActiveBubbleStyles` - overrides default styles of step indicator that has `unvisited` step status
4 changes: 4 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
declare module "*.svg" {
const content: string;
export default content;
}
declare module '*.scss' {
const content: Record<string, string>;
export default content;
}
15 changes: 15 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
// Other configuration above...

// Add the next three options if using TypeScript
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
preset: "ts-jest",
roots: ["<rootDir>/src"],
transform: {
"^.+\\.[t|j]sx?$": "ts-jest",
"^.+\\.svg?$": "<rootDir>/transform.js",
"^.+\\.scss?$": "<rootDir>/transform.js"
},
"testEnvironment": "jsdom",
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
};
Loading