-
Notifications
You must be signed in to change notification settings - Fork 841
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
add Steps component #202
Changes from 2 commits
3f36a32
1d7124e
c150655
38fba87
cf81499
be7c3cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiCode, | ||
EuiSpacer, | ||
EuiSteps, | ||
EuiText, | ||
} from '../../../../src/components'; | ||
|
||
const firstSetOfSteps = [ | ||
{ | ||
title: 'step 1', | ||
children: (<p>{'Do this first'}</p>) | ||
}, | ||
{ | ||
title: 'step 2', | ||
children: (<p>{'Then this'}</p>) | ||
}, | ||
{ | ||
title: 'step 3', | ||
children: (<p>{'And finally, do this'}</p>) | ||
}, | ||
]; | ||
|
||
const nextSetOfSteps = [ | ||
{ | ||
title: 'good step', | ||
children: (<p>{'Do this first'}</p>) | ||
}, | ||
{ | ||
title: 'better step', | ||
children: (<p>{'Then this'}</p>) | ||
}, | ||
{ | ||
title: 'best step', | ||
children: (<p>{'And finally, do this'}</p>) | ||
}, | ||
]; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiSteps | ||
steps={firstSetOfSteps} | ||
/> | ||
|
||
<EuiText> | ||
<EuiSpacer size="m"/> | ||
<p> | ||
Set <EuiCode>firstStepNumber</EuiCode> to continue step numbering after any type of break in the content | ||
</p> | ||
<EuiSpacer size="m"/> | ||
</EuiText> | ||
|
||
<EuiSteps | ||
firstStepNumber={firstSetOfSteps.length} | ||
steps={nextSetOfSteps} | ||
/> | ||
</div> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import Steps from './steps'; | ||
const stepsSource = require('!!raw-loader!./steps'); | ||
const stepsHtml = renderToHtml(Steps); | ||
|
||
export const StepsExample = { | ||
title: 'Steps', | ||
sections: [{ | ||
title: 'Steps', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: stepsSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: stepsHtml, | ||
}], | ||
text: ( | ||
<p> | ||
Numbered steps | ||
</p> | ||
), | ||
demo: <Steps />, | ||
}], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiStep is rendered 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
1 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
First step | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
Do this | ||
</p> | ||
</div> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiSteps renders steps 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiSteps testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
1 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
first title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
Do this first | ||
</p> | ||
</div> | ||
</div> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
2 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
second title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
Then this | ||
</p> | ||
</div> | ||
</div> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
3 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
third title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
And finally, do this | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiSteps renders steps with firstStepNumber 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiSteps testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
10 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
first title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
Do this first | ||
</p> | ||
</div> | ||
</div> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
11 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
second title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
Then this | ||
</p> | ||
</div> | ||
</div> | ||
<div> | ||
<div> | ||
<div | ||
class="euiStepNumber" | ||
> | ||
12 | ||
</div> | ||
<p | ||
class="euiTitle euiStepTitle" | ||
> | ||
third title | ||
</p> | ||
</div> | ||
<div | ||
class="euiStep" | ||
> | ||
<p> | ||
And finally, do this | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'steps'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.euiSteps { | ||
|
||
} | ||
|
||
.euiStepNumber { | ||
width: 32px; | ||
height: 32px; | ||
display: inline-block; | ||
line-height: 32px; | ||
text-align: center; | ||
color: #FFF; | ||
border-radius: 100%; | ||
background-color: #0079a5; | ||
} | ||
|
||
.euiStepTitle { | ||
display: inline-block; | ||
margin-left: 16px; | ||
} | ||
|
||
.euiStep { | ||
border-left: medium solid #D9D9D9; | ||
margin-top: 8px; | ||
margin-bottom: 8px; | ||
margin-left: 16px; | ||
padding-left: 24px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { | ||
EuiSteps, | ||
} from './steps'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { | ||
EuiTitle | ||
} from '../title'; | ||
|
||
export const EuiStep = ({ | ||
className, | ||
children, | ||
step, | ||
title, | ||
...rest | ||
}) => { | ||
return ( | ||
<div | ||
className={className} | ||
{...rest} | ||
> | ||
|
||
<div> | ||
<div className="euiStepNumber"> | ||
{step} | ||
</div> | ||
<EuiTitle className="euiStepTitle"> | ||
<p>{title}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
</EuiTitle> | ||
</div> | ||
|
||
<div className="euiStep"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{children} | ||
</div> | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
EuiStep.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
step: PropTypes.number.isRequired, | ||
title: PropTypes.string.isRequired, | ||
}; |
There was a problem hiding this comment.
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.