Browse Source

ref(overlay): convert progress bar to react

master
Leonard Kim 6 years ago
parent
commit
f0d3abffc5

+ 0
- 3
css/_inlay.scss View File

@@ -56,9 +56,6 @@
56 56
                 margin-bottom: 0px;
57 57
                 width: 100%;
58 58
                 border-radius: 0px;
59
-                > .aui-progress-indicator-value {
60
-                    border-radius: 0px;
61
-                }
62 59
             }
63 60
         }
64 61
         &__title {

+ 9
- 2
css/reload_overlay/_reload_overlay.scss View File

@@ -11,9 +11,16 @@
11 11
 }
12 12
 
13 13
 #reloadProgressBar {
14
-    width: 180px;
14
+    background: #e9e9e9;
15
+    border-radius: 3px;
16
+    height: 5px;
15 17
     margin: 5px auto;
16
-    > .aui-progress-indicator-value {
18
+    overflow: hidden;
19
+    width: 180px;
20
+
21
+    .progress-indicator-fill {
17 22
         background: $reloadProgressBarBg;
23
+        height: 100%;
24
+        transition: width .5s;
18 25
     }
19 26
 }

+ 11
- 19
react/features/overlay/components/AbstractPageReloadOverlay.js View File

@@ -8,7 +8,6 @@ import { randomInt } from '../../base/util';
8 8
 import { _reloadNow } from '../actions';
9 9
 import ReloadButton from './ReloadButton';
10 10
 
11
-declare var AJS: Object;
12 11
 declare var APP: Object;
13 12
 
14 13
 const logger = require('jitsi-meet-logger').getLogger(__filename);
@@ -141,8 +140,6 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
141 140
             `The conference will be reloaded after ${
142 141
                 this.state.timeoutSeconds} seconds.`);
143 142
 
144
-        AJS.progressBars.update('#reloadProgressBar', 0);
145
-
146 143
         this._interval
147 144
             = setInterval(
148 145
                 () => {
@@ -164,20 +161,6 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
164 161
                 1000);
165 162
     }
166 163
 
167
-    /**
168
-     * React Component method that executes once component is updated.
169
-     *
170
-     * @inheritdoc
171
-     * @returns {void}
172
-     */
173
-    componentDidUpdate() {
174
-        const { timeLeft, timeoutSeconds } = this.state;
175
-
176
-        AJS.progressBars.update(
177
-            '#reloadProgressBar',
178
-            (timeoutSeconds - timeLeft) / timeoutSeconds);
179
-    }
180
-
181 164
     /**
182 165
      * Clears the timer interval.
183 166
      *
@@ -214,11 +197,20 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
214 197
      * @returns {ReactElement}
215 198
      */
216 199
     _renderProgressBar() {
200
+        const { timeoutSeconds, timeLeft } = this.state;
201
+        const timeRemaining = timeoutSeconds - timeLeft;
202
+        const percentageComplete = Math.floor(
203
+            (timeRemaining / timeoutSeconds) * 100);
204
+
217 205
         return (
218 206
             <div
219
-                className = 'aui-progress-indicator'
207
+                className = 'progress-indicator'
220 208
                 id = 'reloadProgressBar'>
221
-                <span className = 'aui-progress-indicator-value' />
209
+                <div
210
+                    className = 'progress-indicator-fill'
211
+                    style = {{
212
+                        width: `${percentageComplete}%`
213
+                    }} />
222 214
             </div>
223 215
         );
224 216
     }

+ 1
- 1
react/features/overlay/components/OverlayContainer.js View File

@@ -111,7 +111,7 @@ class OverlayContainer extends Component {
111 111
     };
112 112
 
113 113
     /**
114
-     * Initializes a new ReloadTimer instance.
114
+     * Initializes a new OverlayContainer instance.
115 115
      *
116 116
      * @param {Object} props - The read-only properties with which the new
117 117
      * instance is to be initialized.

+ 0
- 167
react/features/overlay/components/ReloadTimer.js View File

@@ -1,167 +0,0 @@
1
-/* global AJS */
2
-
3
-import PropTypes from 'prop-types';
4
-import React, { Component } from 'react';
5
-
6
-import { translate } from '../../base/i18n';
7
-
8
-/**
9
- * Implements a React Component for the reload timer. Starts counter from
10
- * props.start, adds props.step to the current value on every props.interval
11
- * seconds until the current value reaches props.end. Also displays progress
12
- * bar.
13
- */
14
-class ReloadTimer extends Component {
15
-    /**
16
-     * ReloadTimer component's property types.
17
-     *
18
-     * @static
19
-     */
20
-    static propTypes = {
21
-        /**
22
-         * The end of the timer. When this.state.current reaches this value the
23
-         * timer will stop and call onFinish function.
24
-         *
25
-         * @public
26
-         * @type {number}
27
-         */
28
-        end: PropTypes.number,
29
-
30
-        /**
31
-         * The interval in sec for adding this.state.step to this.state.current.
32
-         *
33
-         * @public
34
-         * @type {number}
35
-         */
36
-        interval: PropTypes.number,
37
-
38
-        /**
39
-         * The function that will be executed when timer finish (when
40
-         * this.state.current === this.props.end)
41
-         */
42
-        onFinish: PropTypes.func,
43
-
44
-        /**
45
-         * The start of the timer. The initial value for this.state.current.
46
-         *
47
-         * @public
48
-         * @type {number}
49
-         */
50
-        start: PropTypes.number,
51
-
52
-        /**
53
-         * The value which will be added to this.state.current on every step.
54
-         *
55
-         * @public
56
-         * @type {number}
57
-         */
58
-        step: PropTypes.number,
59
-
60
-        /**
61
-         * The function to translate human-readable text.
62
-         *
63
-         * @public
64
-         * @type {Function}
65
-         */
66
-        t: PropTypes.func
67
-    };
68
-
69
-    /**
70
-     * Initializes a new ReloadTimer instance.
71
-     *
72
-     * @param {Object} props - The read-only properties with which the new
73
-     * instance is to be initialized.
74
-     * @public
75
-     */
76
-    constructor(props) {
77
-        super(props);
78
-
79
-        this.state = {
80
-            /**
81
-             * Current value(time) of the timer.
82
-             *
83
-             * @type {number}
84
-             */
85
-            current: this.props.start,
86
-
87
-            /**
88
-             * The absolute value of the time from the start of the timer until
89
-             * the end of the timer.
90
-             *
91
-             * @type {number}
92
-             */
93
-            time: Math.abs(this.props.end - this.props.start)
94
-        };
95
-    }
96
-
97
-    /**
98
-     * React Component method that executes once component is mounted.
99
-     *
100
-     * @inheritdoc
101
-     * @returns {void}
102
-     * @protected
103
-     */
104
-    componentDidMount() {
105
-        AJS.progressBars.update('#reloadProgressBar', 0);
106
-
107
-        const intervalId
108
-            = setInterval(
109
-                () => {
110
-                    if (this.state.current === this.props.end) {
111
-                        clearInterval(intervalId);
112
-                        this.props.onFinish();
113
-                    } else {
114
-                        this.setState((prevState, props) => {
115
-                            return {
116
-                                current: prevState.current + props.step
117
-                            };
118
-                        });
119
-                    }
120
-                },
121
-                Math.abs(this.props.interval) * 1000);
122
-    }
123
-
124
-    /**
125
-     * React Component method that executes once component is updated.
126
-     *
127
-     * @inheritdoc
128
-     * @returns {void}
129
-     * @protected
130
-     */
131
-    componentDidUpdate() {
132
-        AJS.progressBars.update(
133
-            '#reloadProgressBar',
134
-            Math.abs(this.state.current - this.props.start) / this.state.time);
135
-    }
136
-
137
-    /**
138
-     * Implements React's {@link Component#render()}.
139
-     *
140
-     * @inheritdoc
141
-     * @returns {ReactElement|null}
142
-     * @public
143
-     */
144
-    render() {
145
-        const { t } = this.props;
146
-
147
-        return (
148
-            <div>
149
-                <div
150
-                    className = 'aui-progress-indicator'
151
-                    id = 'reloadProgressBar'>
152
-                    <span className = 'aui-progress-indicator-value' />
153
-                </div>
154
-                <span className = 'reload_overlay_text'>
155
-                    {
156
-                        this.state.current
157
-                    }
158
-                    <span>
159
-                        { t('dialog.conferenceReloadTimeLeft') }
160
-                    </span>
161
-                </span>
162
-            </div>
163
-        );
164
-    }
165
-}
166
-
167
-export default translate(ReloadTimer);

Loading…
Cancel
Save