Skip to content
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

Stepper component #83

Merged
merged 21 commits into from Oct 16, 2015
Merged

Stepper component #83

merged 21 commits into from Oct 16, 2015

Conversation

cameronviner
Copy link
Contributor

What does this PR do? (please provide any background)

Adds a stepper component to to the UI Toolkit

What tests does this PR have?

Unit tests added to cover the new component

How can this be tested?

checkout the branch and then run:

grunt docs

scroll to the bottom of the page and test the steppers functionality.

Screenshots / Screencast

Stepper image

What gif best describes how you feel about this work?


Developer Definition of Done/Quality Checklist (for PR author to complete BEFORE code review):

Software Engineer or Developer review:

  • I’ve witnessed the work behaving as expected (this could be on the authors machine or screencast).
  • I’ve checked for coding anti-patterns.
  • I’ve checked for appropriate test coverage.
  • I’ve checked all the tests are passing.

Software Engineer or project guru review:

  • I’ve witnessed the work behaving as expected (this could be on the authors machine or screencast).
  • I’ve checked for coding anti-patterns.
  • I’ve checked for appropriate test coverage.
  • I’ve checked all the tests are passing.

"classnames": "^2.1.0",
"font-awesome": "^4.3.0",
"grunt": "^0.4.5",
"grunt-shell": "^1.1.1",
"gruntfile-gtx": "^0.3.0",
"jest-cli": "^0.5.10",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has Jest been introduced again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something I remember adding in, I have removed the dependency.

@hxtomprice
Copy link

Dev

@hxtomprice
Copy link

I'm getting the same issue as before where the stepper loses the event handler. This time it only seems to happen when you hit the limiters

<CustomComponent codeText={fs.readFileSync(__dirname + '/../examples/Stepper.jsx', 'utf8')} />
<h4>Attributes</h4>
<ul>
<li><code>value</code> Number - The value of the stepper</li>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this read "The initial value of the stepper"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok, the onChange call will re-render the stepper passing in a new actual value...

@hxtomprice
Copy link

@cameronviner suggested removing node_modules from the docs/ directory and installing again. Stepper is all working as expected now

@hxpaul
Copy link
Contributor

hxpaul commented Oct 15, 2015

taking a review

@lukehansell
Copy link
Contributor

Trading have a new requirement for their wizard, a stepper which displays a value with text (eg "2am"). How difficult would it be to extend this to match this new use case? I'm not suggesting we do it here, merely asking your thoughts.


getInitialState: function() {
return {
value: this.props.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is an antipattern, I have been reliably informed! I think we can get away without the stepper maintaining its own state at all. Only use this.props.value and do not increment it but call the onChange with this.props.value + 1 or this.props.value - 1. Let me check this with someone with more react experience though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider that checked! Get rid of state completely here, it simplifies your code. Then one more general point, if you run coverage you'll see if your new test covers all the possibilities - right now it does not.

npm run coveralls;
open coverage/lcov-report/index.html 

some of the other tests do not cover enough either, that's not your problem and I will fix that, but you should aim for 100% coverage with your stepper test. When you get rid of state you will find you have less code to cover so your test might even get simpler.
coveralls is the name of the npm script here though it's likely to change to npm run coverage soon if we standardise...

@hxpaul
Copy link
Contributor

hxpaul commented Oct 15, 2015

to cover displaying an alternative value to the actual number you're incrementing (2am, 5 cakes, etc) you might pass in an optional transform function... easy enough I think, but shouldn't bog down this release imo

@cameronviner
Copy link
Contributor Author

@hxpaul @hxtomprice I've updated this now with your changes and better test coverage (an empty function is stopping this getting 100%). Could you take another look when you get a chance?

"react-data-attributes-mixin": "git://github.com/holidayextras/react-data-attributes-mixin",
"reactify": "~1.1.0",
"redirectify": "^1.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think this is needed is it?

@hxpaul
Copy link
Contributor

hxpaul commented Oct 16, 2015

it is a thing of beauty now 👍

@hxtomprice
Copy link

👍

@hxpaul
Copy link
Contributor

hxpaul commented Oct 16, 2015

Seen it working too, I'm using it in the hotel wizard now...

cameronviner added a commit that referenced this pull request Oct 16, 2015
@cameronviner cameronviner merged commit 72cc940 into master Oct 16, 2015
@cameronviner cameronviner deleted the stepper branch October 16, 2015 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants