forked from zoltantothcom/Design-Patterns-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBar.jsx
More file actions
54 lines (45 loc) · 1.17 KB
/
ProgressBar.jsx
File metadata and controls
54 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { connect } from 'react-redux';
import { getAnswers, getRemaining } from '../selectors';
const Container = styled.div`
display: flex;
height: 3px;
justify-content: space-between;
margin: 1.25rem 0 1rem;
width: 100%;
`;
const Step = styled.span`
background: ${props => (props.nature ? props.theme[props.nature] : props.theme.ALTO)};
display: flex;
height: 2px;
width: 3.75%;
`;
export const ProgressBar = props => {
const { answers, remaining } = props;
return (
<Container>
{answers.map(({ uuid, answered, correct }) => {
let nature;
if (answered && correct) {
nature = 'ATLANTIS';
} else {
nature = 'CRIMSON';
}
return <Step key={uuid} nature={nature} />;
})}
{remaining.map(({ uuid }) => (
<Step key={uuid} />
))}
</Container>
);
};
ProgressBar.propTypes = {
answers: PropTypes.array.isRequired,
remaining: PropTypes.array.isRequired
};
export default connect(state => ({
answers: getAnswers(state),
remaining: getRemaining(state)
}))(ProgressBar);