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

add Steps component #202

Merged
merged 6 commits into from
Dec 14, 2017
Merged

add Steps component #202

merged 6 commits into from
Dec 14, 2017

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Dec 12, 2017

Needs some CSS work to use variable instead of hard coded colors and sizes but otherwise is complete

screen shot 2017-12-11 at 2 03 40 pm

@nreese nreese requested review from snide and cjcenizal December 12, 2017 02:11
@nreese nreese mentioned this pull request Dec 12, 2017
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Looking good! I had a few suggestions but they're all pretty minor.

Did you use the Yeoman generator to create these files? We've found it to be really useful for scaffolding up components, creating the test files, and maintaining consistency among them.

import React from 'react';
import PropTypes from 'prop-types';

export function EuiStep({ children, step, title }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add className and ...rest to this destructuring assignment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a snapshot test for this component too?


export function EuiStep({ children, step, title }) {
return (
<div>
Copy link
Contributor

Choose a reason for hiding this comment

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

And can we assign them as props to this div?

Copy link
Contributor

Choose a reason for hiding this comment

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

As well as add a standard component class of euiStep?

function renderSteps(steps, offset = 0) {
return steps.map((step, index) => (
<EuiStep
className="kuiVerticalRhythm"
Copy link
Contributor

Choose a reason for hiding this comment

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

kui? What is this kui you speak of? :)

Can we also change this logic to allow the consumer to specify className and other arbitrary props on the step object?

function renderSteps(steps, firstStepNumber) {
  return steps.map((step, index) => {
    const {
      className,
      children,
      title,
      ...rest
    } = step;
  
    return (
      <EuiStep
        className={className}
        key={index}
        step={firstStepNumber + index}
        title={title}
        {...rest}
      >
        {children}
      </EuiStep>
    );
  ));
}


EuiSteps.propTypes = {
className: PropTypes.string,
offset: PropTypes.number,
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to read the docs to understand the role of this prop, but I think a clearer name would help. Maybe something like firstStepNumber?

Copy link
Contributor

Choose a reason for hiding this comment

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

And can we set defaultProps so this defaults to 1, and remove the default on line 6?

<div className="euiStepNumber">
{step}
</div>
<h3 className="euiStepTitle">
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we can hardcode the h3 here. For accessibility purposes, headings should always be sequential, so if there is an <h3> on the page then there must also be at least one <h2> and only one <h1>.

I think our best option would be to allow the consumer to specify which element gets used for the heading, and to default to <p> if none is specified. This could be specified as a headingElement prop on KuiSteps, since I think we'd want to use the same heading element for each KuiStep within a KuiSteps instance.

We'd probably also want to put the step number inside of the heading element too, if possible, so that screen readers will read the number and heading text together.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, can we reuse the EuiTitle component here?

    <EuiTitle>
      <headingElement>{title}</headingElement>
    </EuiTitle>

@cjcenizal
Copy link
Contributor

We should also add a note about this new component to the CHANGELOG.md.

</EuiTitle>
</div>

<div className="euiStep">
Copy link
Contributor

Choose a reason for hiding this comment

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

@nreese Can you actually put the .euiStep className on the entire wrapping div and rename this one to be euiStepContent? This way I can know which EuiStep is the last one in the EuiSteps container.

{step}
</div>
<EuiTitle className="euiStepTitle">
<p>{title}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

@nreese Is it possible to propagate what the html tag inside the EuiTitle should be? Meaning, can we add a prop to EuiSteps that is something like titleTag which should be an html tag like 'h2' or 'h3' and defaults to 'p'?

This will help with the DOM flow of headers for accessibility since only when we instantiate the component will we know where in the hierarchy it will lie. I think @cjcenizal mentioned something like this during his review.

@cchaos
Copy link
Contributor

cchaos commented Dec 14, 2017

👍 LGTM to start styling.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Cool, let's merge down, and then @cchaos can style it up.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM! I had a few nits but not blockers.

const steps = [
{
title: 'inspect me',
children: (<h3>{'Did you notice the step title is inside a Heading 2 element?'}</h3>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit but I don't think the parens are necessary here.

<h1>Heading 1</h1>
<EuiSteps
steps={steps}
headingElement={'h2'}
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be "h2" (no braces necessary).

const firstSetOfSteps = [
{
title: 'step 1',
children: (<p>{'Do this first'}</p>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same nit about parens here and elsewhere in the file.

};

EuiSteps.defaultProps = {
firstStepNumber: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set this default to 1? Then you won't need to add 1 on line 20.

},
{
title: 'third title',
children: (<p>{'And finally, do this'}</p>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same nit about parens.

@nreese nreese merged commit 202bd18 into elastic:steps_component Dec 14, 2017
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.

4 participants