mirror of
https://github.com/strapi/strapi.git
synced 2025-10-18 19:43:22 +00:00
commit
798c6d1d5d
@ -15,7 +15,14 @@ import injectReducer from 'utils/injectReducer';
|
|||||||
|
|
||||||
import OnboardingVideo from 'components/OnboardingVideo';
|
import OnboardingVideo from 'components/OnboardingVideo';
|
||||||
|
|
||||||
import { getVideos, onClick, removeVideos, setVideoDuration, setVideoEnd, updateVideoStartTime } from './actions';
|
import {
|
||||||
|
getVideos,
|
||||||
|
onClick,
|
||||||
|
removeVideos,
|
||||||
|
setVideoDuration,
|
||||||
|
setVideoEnd,
|
||||||
|
updateVideoStartTime,
|
||||||
|
} from './actions';
|
||||||
import makeSelectOnboarding from './selectors';
|
import makeSelectOnboarding from './selectors';
|
||||||
import reducer from './reducer';
|
import reducer from './reducer';
|
||||||
import saga from './saga';
|
import saga from './saga';
|
||||||
@ -43,17 +50,17 @@ export class Onboarding extends React.Component {
|
|||||||
|
|
||||||
setVideoEnd = () => {
|
setVideoEnd = () => {
|
||||||
this.setVideoEnd();
|
this.setVideoEnd();
|
||||||
}
|
};
|
||||||
|
|
||||||
didPlayVideo = (index, currTime) => {
|
didPlayVideo = (index, currTime) => {
|
||||||
const eventName = `didPlay${index}GetStartedVideo`;
|
const eventName = `didPlay${index}GetStartedVideo`;
|
||||||
this.context.emitEvent(eventName, {timestamp: currTime});
|
this.context.emitEvent(eventName, { timestamp: currTime });
|
||||||
}
|
};
|
||||||
|
|
||||||
didStopVideo = (index, currTime) => {
|
didStopVideo = (index, currTime) => {
|
||||||
const eventName = `didStop${index}Video`;
|
const eventName = `didStop${index}Video`;
|
||||||
this.context.emitEvent(eventName, {timestamp: currTime});
|
this.context.emitEvent(eventName, { timestamp: currTime });
|
||||||
}
|
};
|
||||||
|
|
||||||
handleOpenModal = () => this.setState({ showVideos: true });
|
handleOpenModal = () => this.setState({ showVideos: true });
|
||||||
|
|
||||||
@ -67,10 +74,9 @@ export class Onboarding extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateCurrentTime = (index, current, duration) => {
|
updateCurrentTime = (index, current, duration) => {
|
||||||
|
|
||||||
this.props.updateVideoStartTime(index, current);
|
this.props.updateVideoStartTime(index, current);
|
||||||
|
|
||||||
const percent = current * 100 / duration;
|
const percent = (current * 100) / duration;
|
||||||
const video = this.props.videos[index];
|
const video = this.props.videos[index];
|
||||||
|
|
||||||
if (percent >= 80) {
|
if (percent >= 80) {
|
||||||
@ -80,21 +86,35 @@ export class Onboarding extends React.Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
updateEnd = (index) => {
|
updateEnd = index => {
|
||||||
this.props.setVideoEnd(index, true);
|
this.props.setVideoEnd(index, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-line jsx-handler-names
|
// eslint-disable-line jsx-handler-names
|
||||||
render() {
|
render() {
|
||||||
const { videos, onClick, setVideoDuration } = this.props;
|
const { videos, onClick, setVideoDuration } = this.props;
|
||||||
|
const { showVideos } = this.state;
|
||||||
|
|
||||||
|
const style = showVideos ? {} : { maxWidth: 0 };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(styles.videosWrapper, videos.length > 0 ? styles.visible : styles.hidden)}>
|
<div
|
||||||
<div className={cn(styles.videosContent, this.state.showVideos ? styles.shown : styles.hide)}>
|
style={style}
|
||||||
|
className={cn(styles.videosWrapper, videos.length > 0 ? styles.visible : styles.hidden)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={style}
|
||||||
|
className={cn(styles.videosContent, this.state.showVideos ? styles.shown : styles.hide)}
|
||||||
|
>
|
||||||
<div className={styles.videosHeader}>
|
<div className={styles.videosHeader}>
|
||||||
<p><FormattedMessage id="app.components.Onboarding.title" /></p>
|
<p>
|
||||||
|
<FormattedMessage id="app.components.Onboarding.title" />
|
||||||
|
</p>
|
||||||
{videos.length && (
|
{videos.length && (
|
||||||
<p>{Math.floor((videos.filter(v => v.end).length)*100/videos.length)}<FormattedMessage id="app.components.Onboarding.label.completed" /></p>
|
<p>
|
||||||
|
{Math.floor((videos.filter(v => v.end).length * 100) / videos.length)}
|
||||||
|
<FormattedMessage id="app.components.Onboarding.label.completed" />
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ul className={styles.onboardingList}>
|
<ul className={styles.onboardingList}>
|
||||||
@ -116,10 +136,7 @@ export class Onboarding extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.openBtn}>
|
<div className={styles.openBtn}>
|
||||||
<button
|
<button onClick={this.handleVideosToggle} className={this.state.showVideos ? styles.active : ''}>
|
||||||
onClick={this.handleVideosToggle}
|
|
||||||
className={this.state.showVideos ? styles.active : ''}
|
|
||||||
>
|
|
||||||
<i className="fa fa-question" />
|
<i className="fa fa-question" />
|
||||||
<i className="fa fa-times" />
|
<i className="fa fa-times" />
|
||||||
<span />
|
<span />
|
||||||
@ -157,7 +174,10 @@ Onboarding.propTypes = {
|
|||||||
const mapStateToProps = makeSelectOnboarding();
|
const mapStateToProps = makeSelectOnboarding();
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
return bindActionCreators({ getVideos, onClick, setVideoDuration, updateVideoStartTime, setVideoEnd, removeVideos }, dispatch);
|
return bindActionCreators(
|
||||||
|
{ getVideos, onClick, setVideoDuration, updateVideoStartTime, setVideoEnd, removeVideos },
|
||||||
|
dispatch,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const withConnect = connect(
|
const withConnect = connect(
|
||||||
|
@ -113,4 +113,4 @@
|
|||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user