Skip to content

Commit b766153

Browse files
committed
Finished top section
1 parent 6563e70 commit b766153

File tree

7 files changed

+287
-107
lines changed

7 files changed

+287
-107
lines changed

.idea/workspace.xml

+194-86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"build": "npm-run-all build-css build-js",
2020
"test": "react-scripts test --env=jsdom",
2121
"eject": "react-scripts eject"
22+
},
23+
"devDependencies": {
24+
"bootstrap": "^4.0.0-beta.2"
2225
}
2326
}

src/demo/App.js

+31-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react';
22
import logo from './logo.svg';
33
import './App.css';
4+
import 'bootstrap/dist/css/bootstrap.css';
45

56
import '../publish_component/Stepper'
6-
import Stepper from "../publish_component/Stepper";
7+
import Stepper from '../publish_component/Stepper';
8+
import DummyData from '../publish_component/DummyData'
79

810
class App extends Component {
9-
render() {
10-
return (
11-
<div className="App">
12-
<header className="App-header">
13-
<img src={logo} className="App-logo" alt="logo" />
14-
<h1 className="App-title">Welcome to React</h1>
15-
</header>
16-
<p className="App-intro">
17-
To get started, edit <code>src/App.js</code> and save to reload.
18-
</p>
19-
<Stepper/>
20-
</div>
21-
);
22-
}
11+
constructor(props) {
12+
super(props);
13+
this.state = {
14+
steps: DummyData
15+
};
16+
}
17+
18+
19+
render() {
20+
return (
21+
<div className="container-fluid App no-gutters">
22+
<div className="row" style={{marginBottom: '2rem'}}>
23+
<div className="col no-gutters">
24+
<header className="App-header">
25+
<img src={logo} className="App-logo" alt="logo"/>
26+
<h1 className="App-title">Welcome to React</h1>
27+
</header>
28+
</div>
29+
</div>
30+
<div className="row justify-content-center align-items-center">
31+
<div className="col-8">
32+
<Stepper steps={this.state.steps}/>
33+
</div>
34+
</div>
35+
</div>
36+
);
37+
}
2338
}
2439

2540
export default App;

src/publish_component/DummyData.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
4+
export default [
5+
{
6+
icon: 'mail',
7+
name: 'first',
8+
title: 'Sample title 1',
9+
subtitle: 'Subtitle sample'
10+
11+
},
12+
{
13+
icon: 'report_problem',
14+
name: 'second',
15+
title: 'Sample title 2',
16+
subtitle: 'Subtitle sample'
17+
}
18+
]

src/publish_component/StepIndicator.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,46 @@ import React, {Component} from 'react'
22
import PropTypes from 'prop-types'
33

44
class StepIndicator extends Component {
5+
constructor(props) {
6+
super(props);
7+
8+
// Methods binding this
9+
this.isStepActive = this.isStepActive.bind(this);
10+
}
11+
12+
isStepActive(index) {
13+
if (this.props.currentStep.index === index) {
14+
return 'activated'
15+
} else {
16+
return 'deactivated'
17+
}
18+
}
19+
520
render() {
621
return (
7-
<div className="step">
22+
<div className={['step', this.isStepActive(this.props.index)].join(' ')}
23+
style={{width: `${100 / this.props.stepsLength}%`}}
24+
>
825
<div className="circle">
926
<i className="material-icons md-18">
10-
done
27+
{(this.props.step.completed) ? 'done' : this.props.step.icon}
1128
</i>
1229
</div>
1330
<div className="step-title">
14-
<h4>Test</h4>
15-
<h5 className="step-subtitle">Subtest</h5>
31+
<h4>{this.props.step.title}</h4>
32+
<h5 className="step-subtitle">{this.props.step.subtitle}</h5>
1633
</div>
1734
</div>
1835
)
1936
}
2037
}
2138

2239
StepIndicator.propTypes = {
40+
index: PropTypes.number,
41+
step: PropTypes.object,
42+
currentStep: PropTypes.object,
43+
stepsLength: PropTypes.number
44+
2345
};
2446

2547
export default StepIndicator;

src/publish_component/Stepper.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ class Stepper extends Component {
3333
<TopButtons show={this.props.topButtons} previous={true}
3434
currentIndex={this.state.currentStep.index}/>
3535

36-
<StepIndicator/>
36+
{/*Loops through indicator to show based on step amount*/}
37+
{this.props.steps.map( (step, index, array) =>
38+
<StepIndicator step={step} index={index} stepsLength={array.length}
39+
currentStep={this.state.currentStep}/>
40+
)}
3741

3842
<TopButtons show={this.props.topButtons} previous={false}
3943
currentIndex={this.state.currentStep.index}/>
4044
</div>
4145
</div>
46+
47+
<div className="content">
48+
49+
</div>
4250
</div>
4351
)
4452
}

0 commit comments

Comments
 (0)