Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[website] Update Video Content; Rotate videos once done playing (#51)

Wesam Manassra3f3c048f9f67
diff --git a/website/src/components/common/swipeable.js b/website/src/components/common/swipeable.js
index 384341d98..f302adb85 100644
--- a/website/src/components/common/swipeable.js
+++ b/website/src/components/common/swipeable.js
@@ -55,29 +55,20 @@ const Pagination = ({items, selectedIndex, onChange}) => (
);
export default class Swipeable extends PureComponent {
- state = {
- selectedIndex: 0
- };
-
- _onChange = index => {
- this.setState({selectedIndex: index});
- };
-
render() {
- const {children} = this.props;
- const {selectedIndex} = this.state;
+ const {children, onChange, selectedIndex} = this.props;
return (
<div>
<SwipeableViews
enableMouseEvents
index={selectedIndex}
- onChange={this._onChange}>
+ onChange={onChange}>
{children}
</SwipeableViews>
<Pagination
items={children}
selectedIndex={selectedIndex}
- onChange={this._onChange}
+ onChange={onChange}
/>
</div>
);
diff --git a/website/src/components/common/youtube-video.js b/website/src/components/common/youtube-video.js
deleted file mode 100644
index 90d194fc2..000000000
--- a/website/src/components/common/youtube-video.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2018 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import React, {PureComponent} from 'react';
-
-export default class YoutubeVideo extends PureComponent {
- render() {
- const {src} = this.props;
- return (
- <iframe
- src={src}
- style={{
- border: 'none',
- width: '100%',
- height: '100%'
- }}
- />
- );
- }
-}
diff --git a/website/src/components/walkthrough.js b/website/src/components/walkthrough.js
index 54b1598e3..8b088a24e 100644
--- a/website/src/components/walkthrough.js
+++ b/website/src/components/walkthrough.js
@@ -23,10 +23,9 @@ import styled from 'styled-components';
import {WALKTHROUGH_ITEMS} from '../content';
import {media} from '../styles';
-import YoutubeVideo from './common/youtube-video';
import Swipeable from './common/swipeable';
-const ItemWrapper = styled.div`
+const WalkthroughItem = styled.div`
display: flex;
flex-direction: column;
align-items: center;
@@ -39,33 +38,96 @@ const ItemWrapper = styled.div`
const VideoContainer = styled.div`
width: 640px;
- height: 420px;
-
${media.portable`
width: 500px;
- height: 330px;
- `} ${media.palm`
+ `}
+ ${media.palm`
width: 100%;
- height: 250px;
`};
+
+ video {
+ width: 100%;
+ }
`;
-const ItemDescription = styled.div`
+const VideoDescription = styled.div`
margin-top: 16px;
`;
+const VideoWrapperHeader = styled.div`
+ height: 15px;
+ background: #E5E5E4;
+ border-radius: 3px 3px 0px 0px;
+ display: flex;
+ align-items: center;
+ padding: 0px 5px;
+`;
+
+const VideoWrapperHeaderCircle = styled.div`
+ width: 6px;
+ height: 6px;
+ border-radius: 10px;
+ background: ${props => props.color};
+ margin-left: 5px;
+`;
+
+const VideoWrapper = ({children}) => (
+ <div>
+ <VideoWrapperHeader>
+ <VideoWrapperHeaderCircle color="#12BB00" />
+ <VideoWrapperHeaderCircle color="#D3AE00" />
+ <VideoWrapperHeaderCircle color="#DE3131" />
+ </VideoWrapperHeader>
+ {children}
+ </div>
+);
+
class Walkthrough extends PureComponent {
+ constructor(props) {
+ super(props);
+ this.videoElements = {};
+ }
+ state = {
+ selectedIndex: 0
+ };
+
+ _onChange = (index) => {
+ this.setState({selectedIndex: index});
+ const videoElement = this.videoElements[index];
+ videoElement.load();
+ videoElement.play();
+ };
+
+ _onVideoEnded = () => {
+ const {selectedIndex} = this.state;
+ const newIndex = (selectedIndex + 1) % WALKTHROUGH_ITEMS.length;
+ this._onChange(newIndex);
+ };
+
+ _assignVideoRef = (element, index) => {
+ this.videoElements[index] = element;
+ };
+
render() {
+ const {selectedIndex} = this.state;
return (
<div>
- <Swipeable>
- {WALKTHROUGH_ITEMS.map(({videoUrl, description}) => (
- <ItemWrapper>
- <VideoContainer>
- <YoutubeVideo src={videoUrl} width="100%" height />
- </VideoContainer>
- <ItemDescription>{description}</ItemDescription>
- </ItemWrapper>
+ <Swipeable onChange={this._onChange} selectedIndex={selectedIndex}>
+ {WALKTHROUGH_ITEMS.map(({videoUrl, imageUrl, description}, i) => (
+ <WalkthroughItem>
+ <VideoWrapper key={videoUrl}>
+ <VideoContainer>
+ <video
+ src={videoUrl}
+ poster={imageUrl}
+ autoPlay={i === selectedIndex}
+ ref={(elt) => this._assignVideoRef(elt, i)}
+ onEnded={this._onVideoEnded}
+ />
+ </VideoContainer>
+ </VideoWrapper>
+ <VideoDescription>{description}</VideoDescription>
+ </WalkthroughItem>
))}
</Swipeable>
</div>
diff --git a/website/src/constants.js b/website/src/constants.js
index 25c35f16d..dc5792dc3 100644
--- a/website/src/constants.js
+++ b/website/src/constants.js
@@ -21,7 +21,3 @@
export const CLOUDFRONT = 'https://d1a3f4spazzrp4.cloudfront.net';
export const KEPLER_GL_BUCKET = 'kepler.gl';
export const WEBSITE_ASSET_FOLDER = 'website';
-
-export const VIDEO_TYPES = {
- YOUTUBE: 'YOUTUBE'
-};
diff --git a/website/src/content.js b/website/src/content.js
index ebb9bb179..071c4f4b8 100644
--- a/website/src/content.js
+++ b/website/src/content.js
@@ -19,7 +19,6 @@
// THE SOFTWARE.
import {cdnUrl} from './utils';
-import {VIDEO_TYPES} from './constants';
export const SECTIONS = [
{
@@ -115,20 +114,20 @@ export const SHOWCASE_ITEMS = [
export const WALKTHROUGH_ITEMS = [
{
- videoUrl: 'https://www.youtube.com/embed/nLy3OQYsXWA',
- videoType: VIDEO_TYPES.YOUTUBE,
+ videoUrl: cdnUrl('videos/0.upload_file.mp4'),
+ imageUrl: cdnUrl('videos/0.upload_file.png'),
description:
'Easily import various formats of data by simplily drag and drop'
},
{
- videoUrl: 'https://www.youtube.com/embed/pjzCMQBqjFw',
- videoType: VIDEO_TYPES.YOUTUBE,
+ videoUrl: cdnUrl('videos/1.time_filter.mp4'),
+ imageUrl: cdnUrl('videos/1.time_filter.png'),
description:
'Easily import various formats of data by simplily drag and drop'
},
{
- videoUrl: 'https://www.youtube.com/embed/LPQGHJldEvU',
- videoType: VIDEO_TYPES.YOUTUBE,
+ videoUrl: cdnUrl('videos/2.aggregation.mp4'),
+ imageUrl: cdnUrl('videos/2.aggregation.png'),
description:
'Easily import various formats of data by simplily drag and drop'
}