|
1 | 1 | import React from 'react'; |
2 | 2 | import PropTypes from 'prop-types'; |
3 | 3 | import './snackbar.scss'; |
| 4 | +import { SingleLoading, statusType } from './Loading'; |
| 5 | +import AvatarImage from './AvatarImage'; |
| 6 | +import string from '../lang'; |
4 | 7 |
|
5 | | -const Loading = () => ( |
6 | | - <div className="loading-ring"> |
7 | | - <div /> |
8 | | - <div /> |
9 | | - <div /> |
10 | | - <div /> |
11 | | - </div> |
12 | | -); |
| 8 | +const backupString = string.backup; |
13 | 9 |
|
14 | 10 | const Snackbar = props => ( |
15 | 11 | <div className="snackbar-wrapper"> |
16 | | - <ProgressIndicator {...props} /> |
17 | | - <div className="snackbar-message-contianer"> |
18 | | - <div className="snackbar-message"> |
19 | | - <span>{props.message}</span> |
20 | | - </div> |
21 | | - <div className="snackbar-account"> |
22 | | - <span>{props.email}</span> |
| 12 | + <div className="snackbar-title-container"> |
| 13 | + <h4>{backupString.title}</h4> |
| 14 | + <div className="snackbar-title-hide" onClick={props.onDismissSnackbar}> |
| 15 | + <span>{backupString.hide}</span> |
23 | 16 | </div> |
24 | 17 | </div> |
25 | | - {props.progress < 100 && ( |
26 | | - <div className="snackbar-close" onClick={props.onDismissSnackbar}> |
27 | | - <i className="icon-exit" /> |
| 18 | + <div className="snackbar-info-container"> |
| 19 | + <AvatarIndicator {...props} /> |
| 20 | + <div className="snackbar-message-contianer"> |
| 21 | + <div className="snackbar-message"> |
| 22 | + <Loader {...props} /> |
| 23 | + </div> |
| 24 | + <div className="snackbar-account"> |
| 25 | + <span>{props.email}</span> |
| 26 | + </div> |
28 | 27 | </div> |
29 | | - )} |
| 28 | + </div> |
30 | 29 | </div> |
31 | 30 | ); |
32 | 31 |
|
33 | | -const ProgressIndicator = props => { |
| 32 | +const Loader = props => { |
34 | 33 | switch (props.progress) { |
35 | 34 | case -2: |
36 | | - return ( |
37 | | - <div className="snackbar-loader-container"> |
38 | | - <div className="snackbar-failure-progress"> |
39 | | - <i className="icon-exit" /> |
40 | | - </div> |
41 | | - </div> |
42 | | - ); |
| 35 | + return <SingleLoading percent={100} animationClass={statusType.STOP} />; |
43 | 36 | case -1: |
44 | | - return ( |
45 | | - <div className="snackbar-loader-container"> |
46 | | - <Loading /> |
47 | | - </div> |
48 | | - ); |
| 37 | + return <SingleLoading percent={0} animationClass={statusType.ACTIVE} />; |
49 | 38 | case 100: |
50 | 39 | return ( |
51 | | - <div className="snackbar-loader-container"> |
52 | | - <div className="snackbar-success-progress"> |
53 | | - <i className="icon-check" /> |
54 | | - </div> |
55 | | - </div> |
| 40 | + <SingleLoading |
| 41 | + percent={props.progress} |
| 42 | + animationClass={statusType.COMPLETE} |
| 43 | + /> |
56 | 44 | ); |
57 | 45 | default: |
58 | 46 | return ( |
59 | | - <div className="snackbar-loader-container"> |
60 | | - <Loading /> |
61 | | - <span>{props.progress}%</span> |
62 | | - </div> |
| 47 | + <SingleLoading |
| 48 | + percent={props.progress} |
| 49 | + animationClass={statusType.ACTIVE} |
| 50 | + /> |
63 | 51 | ); |
64 | 52 | } |
65 | 53 | }; |
66 | 54 |
|
| 55 | +const AvatarIndicator = props => { |
| 56 | + return ( |
| 57 | + <div className="snackbar-loader-container"> |
| 58 | + <AvatarImage |
| 59 | + showBorder={false} |
| 60 | + name={props.name} |
| 61 | + color={props.color} |
| 62 | + avatarUrl={props.avatarUrl} |
| 63 | + /> |
| 64 | + </div> |
| 65 | + ); |
| 66 | +}; |
| 67 | + |
67 | 68 | Snackbar.propTypes = { |
68 | 69 | email: PropTypes.string, |
69 | | - message: PropTypes.string, |
70 | | - progress: PropTypes.number, |
71 | 70 | onDismissSnackbar: PropTypes.func |
72 | 71 | }; |
73 | 72 |
|
74 | | -ProgressIndicator.propTypes = { |
| 73 | +AvatarIndicator.propTypes = { |
| 74 | + progress: PropTypes.number, |
| 75 | + name: PropTypes.string, |
| 76 | + color: PropTypes.string, |
| 77 | + avatarUrl: PropTypes.string |
| 78 | +}; |
| 79 | + |
| 80 | +Loader.propTypes = { |
75 | 81 | progress: PropTypes.number |
76 | 82 | }; |
77 | 83 |
|
|
0 commit comments