Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 1, 2022
2 parents 309c246 + 6347f55 commit beb02f7
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 90 deletions.
9 changes: 0 additions & 9 deletions .fatherrc.js

This file was deleted.

5 changes: 5 additions & 0 deletions .fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from 'father';

export default defineConfig({
plugins: ['@rc-component/father-plugin'],
});
114 changes: 114 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- uses: actions/setup-node@v1
with:
node-version: '12'

- name: cache package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: create package-lock.json
run: npm i --package-lock-only

- name: hack for singe file
run: |
if [ ! -d "package-temp-dir" ]; then
mkdir package-temp-dir
fi
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci

lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: lint
run: npm run lint

needs: setup

compile:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: compile
run: npm run compile

needs: setup

coverage:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: coverage
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)

needs: setup
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

lint-staged
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

84 changes: 48 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,62 @@
"name": "rc-steps",
"version": "5.0.0-alpha.0",
"description": "steps ui component for react",
"engines": {
"node": ">=8.x"
},
"keywords": [
"react",
"react-component",
"react-steps"
],
"files": [
"assets/*.css",
"dist",
"es",
"lib"
],
"main": "./lib/index",
"module": "./es/index",
"types": "./lib/index.d.ts",
"homepage": "http://github.com/react-component/steps",
"bugs": {
"url": "http://github.com/react-component/steps/issues"
},
"repository": {
"type": "git",
"url": " git+ssh://[email protected]/react-component/steps.git"
},
"license": "MIT",
"maintainers": [
{
"name": "afc163",
"email": "[email protected]"
}
],
"repository": {
"type": "git",
"url": " git+ssh://[email protected]/react-component/steps.git"
},
"bugs": {
"url": "http://github.com/react-component/steps/issues"
},
"license": "MIT",
"main": "./lib/index",
"module": "./es/index",
"types": "./lib/index.d.ts",
"files": [
"assets/*.css",
"dist",
"es",
"lib"
],
"scripts": {
"start": "dumi dev",
"build": "dumi build",
"compile": "father build && lessc assets/index.less assets/index.css",
"gh-pages": "npm run build && father doc deploy",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"postpublish": "npm run gh-pages",
"coverage": "umi-test --coverage",
"docs:build": "dumi build",
"docs:deploy": "gh-pages -d .doc",
"gh-pages": "npm run docs:build && npm run docs:deploy",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
"prepare": "husky install",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"test": "father test",
"coverage": "father test --coverage"
"postpublish": "npm run gh-pages",
"start": "dumi dev",
"test": "umi-test"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
"lint-staged": {
"**/*.{js,jsx,tsx,ts,md,json}": [
"prettier --write",
"git add"
]
},
"dependencies": {
"@babel/runtime": "^7.16.7",
"classnames": "^2.2.3",
"rc-util": "^5.16.1"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.1",
"@types/classnames": "^2.2.9",
"@types/enzyme": "^3.10.11",
"@types/jest": "^26.0.5",
Expand All @@ -63,20 +70,25 @@
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.1.2",
"eslint": "^7.1.0",
"father": "^2.30.13",
"father": "^4",
"husky": "^8.0.1",
"less": "^3.11.2",
"lint-staged": "^13.0.3",
"np": "^7.6.0",
"prettier": "^2.5.1",
"querystring": "^0.2.0",
"rc-dialog": "8.x",
"rc-tools": "^9.6.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"typescript": "^4.5.4"
"typescript": "^4.5.4",
"umi-test": "^1.9.7"
},
"dependencies": {
"@babel/runtime": "^7.16.7",
"classnames": "^2.2.3",
"rc-util": "^5.16.1"
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
},
"engines": {
"node": ">=8.x"
}
}
27 changes: 13 additions & 14 deletions src/Steps.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint react/no-did-mount-set-state: 0, react/prop-types: 0 */
import React from 'react';
import classNames from 'classnames';
import type { Status, Icons } from './interface';
import Step from './Step';
import React from 'react';
import type { Icons, Status } from './interface';
import type { StepProps } from './Step';
import Step from './Step';

export type StepIconRender = (info: {
index: number;
Expand Down Expand Up @@ -98,28 +98,26 @@ export default class Steps extends React.Component<StepsProps> {

return (
<div className={classString} style={style} {...restProps}>
{(items || [])
{items
.filter((item) => item)
.map((item, index) => {
const mergedItem = { ...item };
const stepNumber = initial + index;
// fix tail color
if (status === 'error' && index === current - 1) {
item.className = `${prefixCls}-next-error`;
mergedItem.className = `${prefixCls}-next-error`;
}

if (!item.status) {
if (stepNumber === current) {
item.status = status;
} else if (stepNumber < current) {
item.status = 'finish';
} else {
item.status = 'wait';
}
if (stepNumber === current) {
mergedItem.status = status;
} else if (stepNumber < current) {
mergedItem.status = 'finish';
} else {
mergedItem.status = 'wait';
}

return (
<Step
{...item}
active={stepNumber === current}
stepNumber={stepNumber + 1}
stepIndex={stepNumber}
Expand All @@ -131,6 +129,7 @@ export default class Steps extends React.Component<StepsProps> {
stepIcon={stepIcon}
icons={icons}
onStepClick={onChange && this.onStepClick}
{...mergedItem}
/>
);
})}
Expand Down
Loading

0 comments on commit beb02f7

Please sign in to comment.