Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-7124): mobile detection based on player.env object #47

Merged
merged 2 commits into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/shell/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import BaseComponent from '../base';
import { connect } from 'preact-redux';
import { bindActions } from '../../utils/bind-actions';
import { actions } from '../../reducers/shell';
import { isMobile } from '../../utils/is-mobile';

/**
* mapping state to props
Expand Down Expand Up @@ -97,7 +96,7 @@ class Shell extends BaseComponent {
* @memberof Shell
*/
componentDidMount() {
this.props.updateIsMobile(isMobile());
this.props.updateIsMobile(!!this.player.env.device.type);
if (document.body) {
this.props.updateDocumentWidth(document.body.clientWidth);
}
Expand All @@ -111,7 +110,7 @@ class Shell extends BaseComponent {
this.props.updateDocumentWidth(document.body.clientWidth);
}
});
if (isMobile()) {
if (this.player.env.device.type) {
this.props.updatePlayerHoverState(true);
}
}
Expand All @@ -127,6 +126,7 @@ class Shell extends BaseComponent {
var playerClasses = 'player skin-default';
playerClasses += ` ${props.playerClasses.join(' ')}`;

if (this.props.isMobile) playerClasses += ` touch`;
if (this.props.playerHover) playerClasses += ` hover`;
if (this.props.metadataLoaded) playerClasses += ` metadata-loaded`;
if (this.props.metadataLoaded) playerClasses += ` state-${this.props.currentState}`;
Expand Down
14 changes: 12 additions & 2 deletions src/components/smart-container/smart-container.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
//@flow
import { h, Component } from 'preact';
import { isMobile } from '../../utils/is-mobile';
import { connect } from 'preact-redux';
import Portal from 'preact-portal';
import Overlay from '../overlay';

/**
* mapping state to props
* @param {*} state - redux store state
* @returns {Object} - mapped state to this component
*/
const mapStateToProps = state => ({
isMobile: state.shell.isMobile
});

@connect(mapStateToProps)
/**
* SmartContainer component
*
Expand All @@ -30,7 +40,7 @@ class SmartContainer extends Component {
* @memberof SmartContainer
*/
render(props: any): React$Element<any> {
return isMobile() ? (
return props.isMobile ? (
<Portal into="#overlay-portal">
<Overlay open onClose={() => props.onClose()}>
<div className='title'>{props.title}</div>
Expand Down
12 changes: 0 additions & 12 deletions src/utils/is-mobile.js

This file was deleted.