Skip to content

Commit e42ebc9

Browse files
committed
initial commit
0 parents  commit e42ebc9

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

index.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use babel'
2+
import React from 'react'
3+
import cls from 'classnames'
4+
5+
function mkarray(n) {
6+
var arr = []
7+
arr.length = n
8+
for (var i=0; i < n; i++)
9+
arr[i] = false
10+
return arr
11+
}
12+
13+
export default class SteppedProgressBar extends React.Component {
14+
render() {
15+
const n = this.props.num || this.props.labels.length
16+
const hasLabels = !!this.props.labels
17+
const labels = this.props.labels || mkarray(n)
18+
return <ul className={'stepped-progress-bar n'+n+(this.props.canGoBack?' can-go-back':'')+(hasLabels?'':' no-labels')}>
19+
{ labels.map((label, i) => {
20+
const onClick = (this.props.canGoBack) ? (()=>this.props.onClick(i)) : undefined
21+
const className = cls({
22+
active: (i <= this.props.current),
23+
current: (i == this.props.current)
24+
})
25+
return <li key={i} className={className} onClick={onClick}>{label}</li>
26+
}) }
27+
</ul>
28+
}
29+
}

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "patchkit-stepped-progress-bar",
3+
"version": "1.0.0",
4+
"description": "React UI component for a progress bar with multiple steps",
5+
"main": "index.jsx",
6+
"dependencies": {
7+
"classnames": "^2.2.3",
8+
"react": "^0.14.6"
9+
},
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/ssbc/patchkit-stepped-progress-bar.git"
16+
},
17+
"keywords": [
18+
"react",
19+
"ui",
20+
"component",
21+
"progress",
22+
"bar"
23+
],
24+
"author": "Paul Frazee <[email protected]>",
25+
"license": "GPL-3.0",
26+
"bugs": {
27+
"url": "https://github.com/ssbc/patchkit-stepped-progress-bar/issues"
28+
},
29+
"homepage": "https://github.com/ssbc/patchkit-stepped-progress-bar#readme"
30+
}

styles.less

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// http://thecodeplayer.com/walkthrough/jquery-multi-step-form-with-progress-bar
2+
3+
.stepped-progress-bar {
4+
padding: 0;
5+
overflow: hidden;
6+
counter-reset: step;
7+
8+
li {
9+
list-style-type: none;
10+
color: gray;
11+
font-size: 16px;
12+
width: 100%;
13+
float: left;
14+
position: relative;
15+
text-align: center;
16+
17+
&:before {
18+
content: counter(step);
19+
counter-increment: step;
20+
position: relative;
21+
z-index: 2;
22+
text-align: center;
23+
width: 20px;
24+
line-height: 20px;
25+
display: block;
26+
font-size: 10px;
27+
color: #333;
28+
background: #ddd;
29+
border-radius: 10px;
30+
margin: 0 auto 5px auto;
31+
}
32+
&:after {
33+
content: '';
34+
width: 100%;
35+
height: 2px;
36+
background: #ddd;
37+
position: absolute;
38+
left: -50%;
39+
top: 9px;
40+
z-index: 1;
41+
42+
background: linear-gradient(to right, #ddd 50%, #4DA1FF 50%);
43+
background-size: 200% 100%;
44+
background-position: 0 0;
45+
transition: background-position 1s;
46+
}
47+
&:first-child:after {
48+
content: none;
49+
}
50+
&.current {
51+
color:#4DA1FF;
52+
}
53+
&.active:before {
54+
background: #4DA1FF;
55+
color: #ddd;
56+
}
57+
&.active:after{
58+
background-position: -100% 0;
59+
}
60+
}
61+
62+
&.n2 li { width: 50%; }
63+
&.n3 li { width: 33.33%; }
64+
&.n4 li { width: 25%; }
65+
&.n5 li { width: 20%; }
66+
67+
&.can-go-back li.active:before {
68+
cursor: pointer;
69+
}
70+
}

0 commit comments

Comments
 (0)