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

Step status props #673

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `0.0.42`.
- Added `status` prop to `EuiStep` for additional styling ([#673](https://github.com/elastic/eui/pull/673))

## [`0.0.42`](https://github.com/elastic/eui/tree/v0.0.42)

Expand Down
69 changes: 69 additions & 0 deletions src-docs/src/views/steps/status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

import React, {
Component,
Fragment,
} from 'react';

import {
EuiSpacer,
EuiSteps,
EuiButton,
} from '../../../../src/components';

export default class extends Component {

constructor(props) {
super(props);

this.state = {
status: 'incomplete',
};

this.handleComplete = this.handleComplete.bind(this);
}

handleComplete() {
this.setState({
status: 'complete',
});
}

render() {

let button;
if (this.state.status === "incomplete") {
button = (
<EuiButton onClick={this.handleComplete}>You complete me</EuiButton>
);
}

const firstSetOfSteps = [
{
title: 'Normal step',
children: <p>Do this first</p>,
},
{
title: 'Push the button to complete this final step',
children: (
<Fragment>
<p>
I am a fancy button just waiting to be pushed!
</p>
<EuiSpacer />
{button}
</Fragment>
),
status: this.state.status,
},
];

return (
<div>
<EuiSteps
steps={firstSetOfSteps}
/>

</div>
);
}
}
25 changes: 24 additions & 1 deletion src-docs/src/views/steps/steps_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import {
EuiCode,
EuiSteps,
EuiStep,
} from '../../../../src/components';

import Steps from './steps';
Expand All @@ -27,6 +28,10 @@ import StepsHorizontal from './steps_horizontal';
const stepsHorizontalSource = require('!!raw-loader!./steps_horizontal');
const stepsHorizontalHtml = renderToHtml(StepsHorizontal);

import Status from './status';
const statusSource = require('!!raw-loader!./status');
const statusHtml = renderToHtml(Steps);

export const StepsExample = {
title: 'Steps',
sections: [{
Expand All @@ -42,7 +47,7 @@ export const StepsExample = {
Numbered steps
</p>
),
props: { EuiSteps },
props: { EuiSteps, EuiStep },
demo: <Steps />,
},
{
Expand Down Expand Up @@ -87,6 +92,24 @@ export const StepsExample = {
),
demo: <HeadingElementSteps />,
},
{
title: 'Steps status',
source: [{
type: GuideSectionTypes.JS,
code: statusSource,
}, {
type: GuideSectionTypes.HTML,
code: statusHtml,
}],
text: (
<p>
Steps can optionally include <EuiCode>status</EuiCode> prop with
a value of <EuiCode>complete</EuiCode> or <EuiCode>incomplete</EuiCode>. This
is used mostly as a final step when you need to make some sort of final check.
</p>
),
demo: <Status />,
},
{
title: 'Horizontal',
source: [{
Expand Down
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export {
} from './spacer';

export {
EuiStep,
EuiSteps,
EuiSubSteps,
EuiStepsHorizontal,
Expand Down
6 changes: 5 additions & 1 deletion src/components/steps/__snapshots__/step.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ exports[`EuiStep is rendered 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
1
</div>
<h3
class="euiTitle euiTitle--small euiStep__title"
data-step-num="1"
>
First step
</h3>
Expand Down
54 changes: 45 additions & 9 deletions src/components/steps/__snapshots__/steps.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ exports[`EuiSteps renders step title inside "headingElement" element 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
1
</div>
<h2
class="euiTitle euiTitle--small euiStep__title"
data-step-num="1"
>
first title
</h2>
Expand All @@ -36,9 +40,13 @@ exports[`EuiSteps renders step title inside "headingElement" element 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
2
</div>
<h2
class="euiTitle euiTitle--small euiStep__title"
data-step-num="2"
>
second title
</h2>
Expand All @@ -58,9 +66,13 @@ exports[`EuiSteps renders step title inside "headingElement" element 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
3
</div>
<h2
class="euiTitle euiTitle--small euiStep__title"
data-step-num="3"
>
third title
</h2>
Expand Down Expand Up @@ -89,9 +101,13 @@ exports[`EuiSteps renders steps 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
1
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="1"
>
first title
</p>
Expand All @@ -111,9 +127,13 @@ exports[`EuiSteps renders steps 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
2
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="2"
>
second title
</p>
Expand All @@ -133,9 +153,13 @@ exports[`EuiSteps renders steps 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
3
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="3"
>
third title
</p>
Expand Down Expand Up @@ -164,9 +188,13 @@ exports[`EuiSteps renders steps with firstStepNumber 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
10
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="10"
>
first title
</p>
Expand All @@ -186,9 +214,13 @@ exports[`EuiSteps renders steps with firstStepNumber 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
11
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="11"
>
second title
</p>
Expand All @@ -208,9 +240,13 @@ exports[`EuiSteps renders steps with firstStepNumber 1`] = `
>
Step
</span>
<div
class="euiStep__circle"
>
12
</div>
<p
class="euiTitle euiTitle--small euiStep__title"
data-step-num="12"
>
third title
</p>
Expand Down
30 changes: 22 additions & 8 deletions src/components/steps/_steps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@
line-height: $euiStepNumberSize; /* 1 */
}

.euiStep__title {
font-weight: $euiFontWeightMedium;
.euiStep__circle {
@include createStepsNumber();

margin-right: $euiStepNumberMargin;
vertical-align: top; /* 1 */

&::before {
content: attr(data-step-num); // Get the number from the data attribute
@include createStepsNumber();
&.euiStep__circle--incomplete {
background-color: transparent;
border: solid 2px $euiColorPrimary;
color: $euiColorDarkShade;
}

&.euiStep__circle--complete {
animation: euiGrow $euiAnimSpeedFast $euiAnimSlightBounce;
}

margin-right: $euiStepNumberMargin;
vertical-align: top; /* 1 */
.euiStep__circleIcon {
position: relative;
top: -2px;
}
}

.euiStep__title {
font-weight: $euiFontWeightMedium;
display: inline-block;
}

.euiStep__content {
border-left: $euiBorderThick;
padding: $euiSize $euiSize $euiSizeXL;
Expand All @@ -36,4 +51,3 @@
margin-left: ($euiStepNumberSize/2) - 1px;
}
}

4 changes: 4 additions & 0 deletions src/components/steps/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export {
EuiStep,
} from './step';

export {
EuiSteps,
} from './steps';
Expand Down
Loading