File size: 1,689 Bytes
6bcb42f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';

import Box from '../box/box.jsx';
import styles from './connection-modal.css';

const Dots = props => (
    <Box
        className={classNames(
            props.className,
            styles.dotsRow
        )}
    >
        <div
            className={classNames(
                styles.dotsHolder,
                {
                    [styles.dotsHolderError]: props.error,
                    [styles.dotsHolderSuccess]: props.success
                }
            )}
        >
            {Array(props.total).fill(0)
                .map((_, i) => {
                    let type = 'inactive';
                    if (props.counter === i) type = 'active';
                    if (props.success) type = 'success';
                    if (props.error) type = 'error';
                    return (<Dot
                        key={`dot-${i}`}
                        type={type}
                    />);
                })}
        </div>
    </Box>
);

Dots.propTypes = {
    className: PropTypes.string,
    counter: PropTypes.number,
    error: PropTypes.bool,
    success: PropTypes.bool,
    total: PropTypes.number
};

const Dot = props => (
    <div
        className={classNames(
            styles.dot,
            {
                [styles.inactiveStepDot]: props.type === 'inactive',
                [styles.activeStepDot]: props.type === 'active',
                [styles.successDot]: props.type === 'success',
                [styles.errorDot]: props.type === 'error'
            }
        )}
    />
);

Dot.propTypes = {
    type: PropTypes.string
};

export default Dots;