squash: pass class name into filmstrip

This commit is contained in:
Leonard Kim 2018-06-25 08:33:08 -07:00
parent c958c64ba8
commit 880d3525db
1 changed files with 44 additions and 60 deletions

View File

@ -1,7 +1,6 @@
/* @flow */ /* @flow */
import _ from 'lodash'; import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@ -13,13 +12,40 @@ import Toolbar from './Toolbar';
declare var interfaceConfig: Object; declare var interfaceConfig: Object;
/**
* The type of the React {@code Component} props of {@link Filmstrip}.
*/
type Props = {
/**
* Additional CSS class names top add to the root.
*/
_className: string,
/**
* Whether the UI/UX is filmstrip-only.
*/
_filmstripOnly: boolean,
/**
* Whether or not remote videos are currently being hovered over. Hover
* handling is currently being handled detected outside of react.
*/
_hovered: boolean,
/**
* The redux {@code dispatch} function.
*/
dispatch: Dispatch<*>
};
/** /**
* Implements a React {@link Component} which represents the filmstrip on * Implements a React {@link Component} which represents the filmstrip on
* Web/React. * Web/React.
* *
* @extends Component * @extends Component
*/ */
class Filmstrip extends Component<*> { class Filmstrip extends Component <Props> {
_isHovered: boolean; _isHovered: boolean;
_notifyOfHoveredStateUpdate: Function; _notifyOfHoveredStateUpdate: Function;
@ -28,47 +54,13 @@ class Filmstrip extends Component<*> {
_onMouseOver: Function; _onMouseOver: Function;
/**
* {@code Filmstrip} component's property types.
*
* @static
*/
static propTypes = {
/**
* Whether the UI/UX is filmstrip-only.
*/
_filmstripOnly: PropTypes.bool,
/**
* Whether or not remote videos are currently being hovered over.
*/
_hovered: PropTypes.bool,
/**
* Whether or not the remote videos should be visible. Will toggle
* a class for hiding the videos.
*/
_remoteVideosVisible: PropTypes.bool,
/**
* Whether or not the toolbox is visible. The height of the vertical
* filmstrip needs to adjust to accommodate the horizontal toolbox.
*/
_toolboxVisible: PropTypes.bool,
/**
* The redux {@code dispatch} function.
*/
dispatch: PropTypes.func
};
/** /**
* Initializes a new {@code Filmstrip} instance. * Initializes a new {@code Filmstrip} instance.
* *
* @param {Object} props - The read-only properties with which the new * @param {Object} props - The read-only properties with which the new
* instance is to be initialized. * instance is to be initialized.
*/ */
constructor(props) { constructor(props: Props) {
super(props); super(props);
// Debounce the method for dispatching the new filmstrip handled state // Debounce the method for dispatching the new filmstrip handled state
@ -95,30 +87,16 @@ class Filmstrip extends Component<*> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const {
_filmstripOnly,
_remoteVideosVisible,
_toolboxVisible
} = this.props;
// Note: Appending of {@code RemoteVideo} views is handled through // Note: Appending of {@code RemoteVideo} views is handled through
// VideoLayout. The views do not get blown away on render() because // VideoLayout. The views do not get blown away on render() because
// ReactDOMComponent is only aware of the given JSX and not new appended // ReactDOMComponent is only aware of the given JSX and not new appended
// DOM. As such, when updateDOMProperties gets called, only attributes // DOM. As such, when updateDOMProperties gets called, only attributes
// will get updated without replacing the DOM. If the known DOM gets // will get updated without replacing the DOM. If the known DOM gets
// modified, then the views will get blown away. // modified, then the views will get blown away.
const reduceHeight
= !_filmstripOnly
&& _toolboxVisible
&& interfaceConfig.TOOLBAR_BUTTONS.length;
const classNames
= `filmstrip ${
_remoteVideosVisible ? '' : 'hide-videos'} ${
reduceHeight ? 'reduce-height' : ''}`;
return ( return (
<div className = { classNames }> <div className = { `filmstrip ${this.props._className}` }>
{ _filmstripOnly && <Toolbar /> } { this.props._filmstripOnly && <Toolbar /> }
<div <div
className = 'filmstrip__videos' className = 'filmstrip__videos'
id = 'remoteVideos'> id = 'remoteVideos'>
@ -193,20 +171,26 @@ class Filmstrip extends Component<*> {
* @param {Object} state - The Redux state. * @param {Object} state - The Redux state.
* @private * @private
* @returns {{ * @returns {{
* _filmstripOnly: boolean, * _className: string,
* _hovered: boolean, * _hovered: boolean,
* _remoteVideosVisible: boolean, * _filmstripOnly: boolean
* _toolboxVisible: boolean
* }} * }}
*/ */
function _mapStateToProps(state) { function _mapStateToProps(state) {
const { hovered } = state['features/filmstrip']; const { hovered } = state['features/filmstrip'];
const isFilmstripOnly = Boolean(interfaceConfig.filmStripOnly);
const reduceHeight = !isFilmstripOnly
&& state['features/toolbox'].visible
&& interfaceConfig.TOOLBAR_BUTTONS.length;
const remoteVideosVisible = shouldRemoteVideosBeVisible(state);
const className = `${remoteVideosVisible ? '' : 'hide-videos'} ${
reduceHeight ? 'reduce-height' : ''}`;
return { return {
_filmstripOnly: Boolean(interfaceConfig.filmStripOnly), _className: className,
_hovered: hovered, _filmstripOnly: isFilmstripOnly,
_remoteVideosVisible: shouldRemoteVideosBeVisible(state), _hovered: hovered
_toolboxVisible: state['features/toolbox'].visible
}; };
} }