浏览代码

squash: pass class name into filmstrip

j8
Leonard Kim 7 年前
父节点
当前提交
880d3525db
共有 1 个文件被更改,包括 44 次插入60 次删除
  1. 44
    60
      react/features/filmstrip/components/web/Filmstrip.js

+ 44
- 60
react/features/filmstrip/components/web/Filmstrip.js 查看文件

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
 import _ from 'lodash';
3
 import _ from 'lodash';
4
-import PropTypes from 'prop-types';
5
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
6
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
7
 
6
 
13
 
12
 
14
 declare var interfaceConfig: Object;
13
 declare var interfaceConfig: Object;
15
 
14
 
15
+/**
16
+ * The type of the React {@code Component} props of {@link Filmstrip}.
17
+ */
18
+type Props = {
19
+
20
+    /**
21
+     * Additional CSS class names top add to the root.
22
+     */
23
+    _className: string,
24
+
25
+    /**
26
+     * Whether the UI/UX is filmstrip-only.
27
+     */
28
+    _filmstripOnly: boolean,
29
+
30
+    /**
31
+     * Whether or not remote videos are currently being hovered over. Hover
32
+     * handling is currently being handled detected outside of react.
33
+     */
34
+    _hovered: boolean,
35
+
36
+    /**
37
+     * The redux {@code dispatch} function.
38
+     */
39
+    dispatch: Dispatch<*>
40
+};
41
+
16
 /**
42
 /**
17
  * Implements a React {@link Component} which represents the filmstrip on
43
  * Implements a React {@link Component} which represents the filmstrip on
18
  * Web/React.
44
  * Web/React.
19
  *
45
  *
20
  * @extends Component
46
  * @extends Component
21
  */
47
  */
22
-class Filmstrip extends Component<*> {
48
+class Filmstrip extends Component <Props> {
23
     _isHovered: boolean;
49
     _isHovered: boolean;
24
 
50
 
25
     _notifyOfHoveredStateUpdate: Function;
51
     _notifyOfHoveredStateUpdate: Function;
28
 
54
 
29
     _onMouseOver: Function;
55
     _onMouseOver: Function;
30
 
56
 
31
-    /**
32
-     * {@code Filmstrip} component's property types.
33
-     *
34
-     * @static
35
-     */
36
-    static propTypes = {
37
-        /**
38
-         * Whether the UI/UX is filmstrip-only.
39
-         */
40
-        _filmstripOnly: PropTypes.bool,
41
-
42
-        /**
43
-         * Whether or not remote videos are currently being hovered over.
44
-         */
45
-        _hovered: PropTypes.bool,
46
-
47
-        /**
48
-         * Whether or not the remote videos should be visible. Will toggle
49
-         * a class for hiding the videos.
50
-         */
51
-        _remoteVideosVisible: PropTypes.bool,
52
-
53
-        /**
54
-         * Whether or not the toolbox is visible. The height of the vertical
55
-         * filmstrip needs to adjust to accommodate the horizontal toolbox.
56
-         */
57
-        _toolboxVisible: PropTypes.bool,
58
-
59
-        /**
60
-         * The redux {@code dispatch} function.
61
-         */
62
-        dispatch: PropTypes.func
63
-    };
64
-
65
     /**
57
     /**
66
      * Initializes a new {@code Filmstrip} instance.
58
      * Initializes a new {@code Filmstrip} instance.
67
      *
59
      *
68
      * @param {Object} props - The read-only properties with which the new
60
      * @param {Object} props - The read-only properties with which the new
69
      * instance is to be initialized.
61
      * instance is to be initialized.
70
      */
62
      */
71
-    constructor(props) {
63
+    constructor(props: Props) {
72
         super(props);
64
         super(props);
73
 
65
 
74
         // Debounce the method for dispatching the new filmstrip handled state
66
         // Debounce the method for dispatching the new filmstrip handled state
95
      * @returns {ReactElement}
87
      * @returns {ReactElement}
96
      */
88
      */
97
     render() {
89
     render() {
98
-        const {
99
-            _filmstripOnly,
100
-            _remoteVideosVisible,
101
-            _toolboxVisible
102
-        } = this.props;
103
-
104
         // Note: Appending of {@code RemoteVideo} views is handled through
90
         // Note: Appending of {@code RemoteVideo} views is handled through
105
         // VideoLayout. The views do not get blown away on render() because
91
         // VideoLayout. The views do not get blown away on render() because
106
         // ReactDOMComponent is only aware of the given JSX and not new appended
92
         // ReactDOMComponent is only aware of the given JSX and not new appended
107
         // DOM. As such, when updateDOMProperties gets called, only attributes
93
         // DOM. As such, when updateDOMProperties gets called, only attributes
108
         // will get updated without replacing the DOM. If the known DOM gets
94
         // will get updated without replacing the DOM. If the known DOM gets
109
         // modified, then the views will get blown away.
95
         // modified, then the views will get blown away.
110
-        const reduceHeight
111
-            = !_filmstripOnly
112
-            && _toolboxVisible
113
-            && interfaceConfig.TOOLBAR_BUTTONS.length;
114
-        const classNames
115
-            = `filmstrip ${
116
-                _remoteVideosVisible ? '' : 'hide-videos'} ${
117
-                reduceHeight ? 'reduce-height' : ''}`;
118
 
96
 
119
         return (
97
         return (
120
-            <div className = { classNames }>
121
-                { _filmstripOnly && <Toolbar /> }
98
+            <div className = { `filmstrip ${this.props._className}` }>
99
+                { this.props._filmstripOnly && <Toolbar /> }
122
                 <div
100
                 <div
123
                     className = 'filmstrip__videos'
101
                     className = 'filmstrip__videos'
124
                     id = 'remoteVideos'>
102
                     id = 'remoteVideos'>
193
  * @param {Object} state - The Redux state.
171
  * @param {Object} state - The Redux state.
194
  * @private
172
  * @private
195
  * @returns {{
173
  * @returns {{
196
- *     _filmstripOnly: boolean,
174
+ *     _className: string,
197
  *     _hovered: boolean,
175
  *     _hovered: boolean,
198
- *     _remoteVideosVisible: boolean,
199
- *     _toolboxVisible: boolean
176
+ *     _filmstripOnly: boolean
200
  * }}
177
  * }}
201
  */
178
  */
202
 function _mapStateToProps(state) {
179
 function _mapStateToProps(state) {
203
     const { hovered } = state['features/filmstrip'];
180
     const { hovered } = state['features/filmstrip'];
181
+    const isFilmstripOnly = Boolean(interfaceConfig.filmStripOnly);
182
+    const reduceHeight = !isFilmstripOnly
183
+        && state['features/toolbox'].visible
184
+        && interfaceConfig.TOOLBAR_BUTTONS.length;
185
+    const remoteVideosVisible = shouldRemoteVideosBeVisible(state);
186
+
187
+    const className = `${remoteVideosVisible ? '' : 'hide-videos'} ${
188
+        reduceHeight ? 'reduce-height' : ''}`;
204
 
189
 
205
     return {
190
     return {
206
-        _filmstripOnly: Boolean(interfaceConfig.filmStripOnly),
207
-        _hovered: hovered,
208
-        _remoteVideosVisible: shouldRemoteVideosBeVisible(state),
209
-        _toolboxVisible: state['features/toolbox'].visible
191
+        _className: className,
192
+        _filmstripOnly: isFilmstripOnly,
193
+        _hovered: hovered
210
     };
194
     };
211
 }
195
 }
212
 
196
 

正在加载...
取消
保存