Skip to content

TypeScript Refactor #130

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 19 commits into
base: master
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
12 changes: 2 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
"presets": [
"@babel/env",
"@babel/react"
],
"presets": ["@babel/env", "@babel/react"],
"env": {
"production": {
"plugins": [
["transform-react-remove-prop-types", {
"mode": "remove",
"removeImport": true
}]
]
"plugins": []
}
},
"plugins": ["@babel/plugin-proposal-class-properties"]
Expand Down
14 changes: 8 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"env": {
"node": true,
"browser": true,
"jest": true
},
"extends": [
"airbnb-base",
"plugin:react/recommended"
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"settings": {
"react": {
"version": "16.0"
"version": "16.0"
}
},
"parser": "babel-eslint",
"plugins": ["babel"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"arrow-parens": 0,
"indent": [ "error", 4 ],
"indent": ["error", 4],
"no-console": ["error", { "allow": ["error"] }],
"no-continue": 0,
"operator-linebreak": 0,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- '**' # This triggers the workflow on pull requests to any branch

Expand All @@ -17,6 +18,11 @@ jobs:
with:
node-version: 20.13.1

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist
!app/dist/
react-step-wizard-*.tgz
coverage/
app/next
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ _config.yml
.eslintrc
.gitignore
.nvmrc
.prettierrc
.vscode/
app/
docs/
CHANGELOG.md
coverage/
example.gif
example/
.github/
index.html
jest.config.json
jest.config.js
react-step-wizard-*.tgz
rollup.config.js
scripts/
src/
tsconfig.json
webpack.config.js
yarn.lock
yarn*.log
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.5.0
20.13.1
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

### [5.4.0-beta.2]
• Generate `main: cjs`, `browser: umd`, and `module: esm` bundles for better import compatibility - like with Next.js
• Generate accurate types thanks to TypeScript

> Dev Changes
• Refactor codebase in Typescript
• Update packages to address security vulnerabilities

### [5.3.11]
• Add missing transition type - intro - Thanks [bundit](https://github.com/bundit)

Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
Steps to develop locally:

• `nvm use`
• `npm install`
• `pnpm install`
• `npm start`

### Testing

Once your changes look good, test it intensely!

• `npm test` - runs existing unit tests. If your changes require a new unit test, please add it to `src/index.test.js`
Expand All @@ -20,6 +21,7 @@ Create a production build of the example app and test in Chrome, Safari, Firefox
Open `app/index.html` in all the browsers listed above and ensure there are no console errors. Also, make sure hashKeys still work as expected.

### Create Pull Request

If you feel confidence in your changes, open a PR for me to review. I'll most likely have you merge into a dev branch before going straight to master. From there I will handle the versioning and publish your changes! I'm working on automating publishing straight to NPM when a new release is created.

To up the version use `npm version` for semantic versioning.
Expand Down
10 changes: 4 additions & 6 deletions app/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { hot } from 'react-hot-loader';
import { createRoot } from 'react-dom/client';

import Wizard from './components/wizard';

import 'bootstrap/dist/css/bootstrap.min.css';
import './less/app.less';

const App = () => (
<Wizard />
);

/** HMR */
hot(module)(App);
const domNode = document.getElementById('app');
const root = createRoot(domNode);

ReactDOM.render(<App />, document.getElementById('app'));
root.render(<App />);
3 changes: 2 additions & 1 deletion app/components/nav.less → app/components/nav.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.nav {
.wizard-nav {
margin-bottom: 15px;
text-align: center;
justify-content: center;
}

.dot {
Expand Down
5 changes: 2 additions & 3 deletions app/components/nav.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
/* eslint react/prop-types: 0 */
import styles from './nav.less';
import styles from './nav.css';

const Nav = (props) => {
const dots = [];
Expand All @@ -16,7 +15,7 @@ const Nav = (props) => {
}

return (
<div className={styles.nav}>{dots}</div>
<div className={styles['wizard-nav']}>{dots}</div>
);
};

Expand Down
File renamed without changes.
22 changes: 12 additions & 10 deletions app/components/wizard.less → app/components/wizard.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
}

/** Progress Bar */
@progress-height: 5px;
@duration: 3s;
:root {
--progress-height: 5px;
--duration: 3s;
}

@keyframes stripes {
from { background-position: 1rem 0 }
Expand All @@ -30,17 +32,17 @@
}

.progress {
height: @progress-height;
height: var(progress-height);
overflow: hidden;
}

.progress-bar {
height: @progress-height;
height: var(--progress-height);
width: 100%;

.loaded & {
animation: grow @duration ease,
stripes 1s linear infinite,
rainbow @duration ease infinite;
}
}

.loaded .progress-bar {
animation: grow var(--duration) ease,
stripes 1s linear infinite,
rainbow var(--duration) ease infinite;
}
17 changes: 9 additions & 8 deletions app/components/wizard.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { Fragment, useState, useEffect } from 'react';
import StepWizard from '../../dist/react-step-wizard.min';
import StepWizard from '../../';

import Nav from './nav';
import Plugs from './Plugs';

import styles from './wizard.less';
import transitions from './transitions.less';
/* eslint react/prop-types: 0 */
import styles from './wizard.css';
import transitions from './transitions.css';
import 'bootstrap/dist/css/bootstrap.min.css';

/**
* A basic demonstration of how to use the step wizard
Expand Down Expand Up @@ -64,11 +64,12 @@ const Wizard = () => {
<Progress stepName='progress' />
{null /* will be ignored */}
<Last hashKey={'TheEnd!'} />
<Last />
</StepWizard>
</div>
</div>
</div>
{ (demo && SW) && <InstanceDemo SW={SW} /> }
{(demo && SW) && <InstanceDemo SW={SW} />}
</div>
);
};
Expand Down Expand Up @@ -103,10 +104,10 @@ const Stats = ({
}) => (
<div>
<hr />
{ step > 1 &&
{step > 1 &&
<button className='btn btn-default btn-block' onClick={previousStep}>Go Back</button>
}
{ step < totalSteps ?
{step < totalSteps ?
<button className='btn btn-primary btn-block' onClick={nextStep}>Continue</button>
:
<button className='btn btn-success btn-block' onClick={nextStep}>Finish</button>
Expand Down Expand Up @@ -151,7 +152,7 @@ const Second = props => {

return (
<div>
{ props.form.firstname && <h3>Hey {props.form.firstname}! 👋</h3> }
{props.form.firstname && <h3>Hey {props.form.firstname}! 👋</h3>}
I've added validation to the previous button.
<Stats step={2} {...props} previousStep={validate} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/dist/app.bundle.js

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,11 @@ if (isDev) {

config.output.publicPath = publicPath;
config.devServer = {
compress: true,
host: '0',
index: server.index,
openPage: server.root,
overlay: {
warnings: false,
errors: true,
},
port: server.port,
public: host,
publicPath,
stats: config.stats,
static: {
directory: path.join(__dirname),
serveIndex: true,
},
};
config.optimization = {
minimize: false,
Expand Down
Empty file added docs/.nojekyll
Empty file.
Loading