Code Monkey home page Code Monkey logo

steps's Introduction

rc-steps


React steps component.

NPM version build status Test coverage npm download bundle size

Usage

npm install rc-steps

<Steps current={1}>
  <Steps.Step title="first" />
  <Steps.Step title="second" />
  <Steps.Step title="third" />
</Steps>

Example

https://steps.vercel.app/

API

name type default description
type string default diretypetion of Steps, could be `default` `navigation` `inline`
direction string horizontal direction of Steps, enum: `horizontal` or `vertical`
current number 0 index of current step
initial number 0 index initial
size string size of Steps, could be `small`
labelPlacement string placement of step title, could be `vertical`
status string wait status of current Steps, could be `error` `process` `finish` `wait`
icons { finish: ReactNode, error: ReactNode } specify the default finish icon and error icon
itemRender (item: StepProps, stepItem: React.ReactNode) => React.ReactNode custom step item renderer
onChange (current: number) => void Trigger when Step changed

Steps.Step

name type default description
title ReactNode title of step item
subTitle ReactNode subTitle of step item
description ReactNode description of step item
icon ReactNode set icon of step item
status string status of current Steps, could be `error` `process` `finish` `wait`
tailContent ReactNode content above tail
disabled bool false disabled step when onChange exist
render (stepItem: React.ReactNode) => React.ReactNode custom step item renderer

Development

npm install
npm start

License

rc-steps is released under the MIT license.

steps's People

Contributors

07akioni avatar afc163 avatar benjycui avatar dbsds avatar ddcat1115 avatar dependabot-preview[bot] avatar dependabot[bot] avatar emersonlaurentino avatar fireairforce avatar gragland avatar heiyu4585 avatar hengkx avatar heskeybaozi avatar jarvisart avatar just-boris avatar kingwubin avatar li-jia-nan avatar madccc avatar mjoyce91 avatar musicq avatar smmoosavi avatar superraytin avatar warmhug avatar wrxpowered avatar yesmeck avatar yiminghe avatar yoyo837 avatar zhujun24 avatar zombiej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steps's Issues

How do I integrate this component with React router

Hi @afc163

I'm new with React and am working on a project which uses your Steps component.
I have created a couple of components that act like pages of the Steps component and is using next and prev buttons to navigate between different pages(it's actually more like a Tab component). It all works great except the URL part. I've searched from GitHub and stackoverflow for hours but still, cannot figure out how to get it working with React Router.

Thank you!

Single steps are not rendered

React 18, Nextjs 12.3

import Steps from 'rc-steps';

import 'rc-steps/assets/index.css';


const { Step } = Steps;

const Tracking = () => {
  const [current, setCurrent] = useState(0);

  const onChange = (value) => {
    console.log('onChange:', current);
    setCurrent(value);
  };

  return (
    <>
      <Steps current={current} onChange={onChange}>
        <Step title="Step 1" description="This is a description." />
        <Step title="Step 2" description="This is a description." />
        <Step title="Step 3" description="This is a description." />
      </Steps>

      <Steps current={current} onChange={onChange} direction="vertical">
        <Step title="Step 1" description="This is a description." />
        <Step title="Step 2" description="This is a description." />
        <Step title="Step 3" description="This is a description." />
      </Steps>
    </>
  );
}

The single steps are not rendered within the Steps wrapper.
image

_resize函数this对象的问题

你好,我很想请教一个问题,我单独安装Steps使用,拖动改变窗口大小时候,会报这样的错误:
Uncaught Invariant Violation: Element appears to be neither ReactComponent nor DOMNode
显示错误是在_resize函数里面的 const w = Math.floor(ReactDOM.findDOMNode(this).offsetWidth);
this显示为window对象而不是我们这个Steps对象, 所以findDOMNode不支持非ReactElement就报错了;但是在antd组件里面却没有错误,查看antd的steps组件和最终的export文件也看不出什么端倪,感觉没有做什么循序bind的事情。

requiring instead of importing

Hey guys!
I'm having the following error when rendering

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

This happens only when using

const Steps = require('rc-steps');

Instead of

import Steps from 'rc-steps';

The problem is that, because a limitation at my work, I can't use import. Is there any other workaround to make this module work with require?

Thanks in advance!

tailContent is not working

when you add a tailContent it just makes the tail-content div to be display: none, nothing happens. ... please help

Component not working for any version above 4.1.4

Not sure if there was a breaking syntax change between versions 4 and 5 that is causing this, but I upgraded from 4.1.4 to 6.0.1 and it broke rc-steps in my project. The container div shows up but there is no content and css height is 0 px. I downgraded to 5.0.0 to see if that fixed anything and I got the same result. Downgrading again to 4.1.4 renders my steps implementation normally again.

组件宽度计算失败

组件一开始被隐藏导致计算最后一个节点宽度为 0,后续展示后不触发 update,组件始终隐藏。

Cannot interact with clickable steps via keyboard

If you tab to a clickable step and press Enter, nothing happens. Clicking with a mouse works though. The cause is likely the fact that instead of a button element, a div[role=button] is used. Those do not respond to keyboard interactions by default.

icons error has error in console

Hi,
I would like to know how to pass 'icons' props in . Actually when the status is finish or else is working fine. BUT when status= error, it has error on console and the icons is not correct ( I would like to use the old style as you have) as the screenshot.
I send icons props as icons="error" is this correct?

image

image

Thanks.

两个tab 里面都有 steps 组件的样式错位问题

两个tab 里面都有 steps 组件 ,然后切换两个tab ,程序会把两个tab的steps的margin-right都修改 导致样式错位 会重新计算另一个tab里面的steps组件的margin-right值
注释Steps.jsx这里的代码 即可解决:
componentDidUpdate() {
// this.calcLastStepOffsetWidth();
}

Click event on step number

Sometimes we need to go next/prev by clicking directly on step number from the process bar, It is good if we put onClick callback on click event of steps.

Btw thank you for this effort, It looks so good.

Property 'Step' does not exist on type 'typeof Steps'.

When I converted my .js file into .tsx.

It started giving me this error:
"Property 'Step' does not exist on type 'typeof Steps'."

Please help me figure out this issue.

Previously it was working fine with .js file. But as we're moving to TS and converting files, it is giving me this issue.

Warning that timeout callback sets state on unmounted component

warning.js?8a56:44 Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component.
warning
  @ warning.js?8a56:44getInternalInstanceReadyForUpdate
  @ ReactUpdateQueue.js?fd2c:45ReactUpdateQueue.enqueueSetState
  @ ReactUpdateQueue.js?fd2c:192ReactComponent.setState
  @ ReactComponent.js?702a:67(anonymous function)
  @ Steps.js?da93:51

React: 15.0.2; react-router: 2.4.0; webpack: 1.12.14.

I can't give too many specific details as this is not a personal project.

I can reproduce this by routing away from the page which embeds the step component, or by forcing a hot reload with webpack. My belief, as I've seen this sort of warning a few times, is that:

  • a componentDidUpdate call occurs right before unmount (don't know if this is a canonical React lifecycle order or simple occurence or an effect of the packages)
  • the call to setState is async and occurs after the unmount, generating the no-op warning.

As far as I've read the code, you could solve it by guarding the call with a 'mounted' flag (which is set in the other lifecycle methods: willmount/willunmount) or simply setting state synchronously in componentDidUpdate (in fact, as far as I've seen, the state change will only be changed after the lifecycle method anyway). Cheers for the component.

Change icon background color

The default icon back color is blue #2db7f5 .
And the current props are :

Step.propTypes = {
  className: _react.PropTypes.string,
  prefixCls: _react.PropTypes.string,
  style: _react.PropTypes.object,
  wrapperStyle: _react.PropTypes.object,
  tailWidth: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),
  status: _react.PropTypes.string,
  iconPrefix: _react.PropTypes.string,
  icon: _react.PropTypes.node,
  adjustMarginRight: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),
  stepLast: _react.PropTypes.bool,
  stepNumber: _react.PropTypes.string,
  description: _react.PropTypes.any,
  title: _react.PropTypes.any
};

No props seems related to icon color . Is it required enhancement or already exist ? Where is if it iswas existed .

Assets missing

It seems the assets are missing from the package.

image

image

"rc-steps": "^3.0.0",

styling does not exist

There is no styling included currently. In the README, was it suppose to mention adding the .less files?

examples not working

Having the following errors on console:

Uncaught Error: Cannot find module "prop-types"

previous step text

Can I show also text in the circle of the previous steps?
It is not showing the text(1,2) of previous steps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.