Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Enhancement] More granular speed control (#500)
Shan He779238435707
diff --git a/src/components/common/icons/index.js b/src/components/common/icons/index.jsindex 403d87a0b..a729d84c5 100644--- a/src/components/common/icons/index.js+++ b/src/components/common/icons/index.js@@ -55,6 +55,7 @@ export {default as Pin} from './pin';export {default as Play} from './play';export {default as Reduce} from './reduce';export {default as Reset} from './reset';+export {default as Rocket} from './rocket';export {default as Save} from './save';export {default as Share} from './share';export {default as SquareSelect} from './square-select';diff --git a/src/components/common/icons/rocket.js b/src/components/common/icons/rocket.jsnew file mode 100644index 000000000..7c063ec54--- /dev/null+++ b/src/components/common/icons/rocket.js@@ -0,0 +1,43 @@+// Copyright (c) 2019 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, {Component} from 'react';+import PropTypes from 'prop-types';+import Base from './base';++export default class Rocket extends Component {+ static propTypes = {+ /** Set the height of the icon, ex. '16px' */+ height: PropTypes.string+ };++ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-rocket'+ };++ render() {+ return (+ <Base {...this.props}>+ <path d="M40.67,13,26.22,27.43H17.56L8.89,39s9.18-2.56,14.53-1.36L8.89,56.32l19-14.81c2.65,6.08-1.71,14.81-1.71,14.81l11.55-8.67V39L52.22,24.54,55.11,10.1Z"/>+ </Base>+ );+ }+};diff --git a/src/components/common/item-selector/item-selector.js b/src/components/common/item-selector/item-selector.jsindex fc7f80878..2291e8b4d 100644--- a/src/components/common/item-selector/item-selector.js+++ b/src/components/common/item-selector/item-selector.js@@ -277,7 +277,7 @@ class ItemSelector extends Component {/>) : (<StyledDropdownSelect {...dropdownSelectProps}>- <DropdownSelectValue hasPlaceholder={!hasValue}>+ <DropdownSelectValue hasPlaceholder={!hasValue} className="item-selector__dropdown__value">{hasValue ? (<this.props.DropDownLineItemRenderComponentdisplayOption={displayOption}diff --git a/src/components/common/range-slider.js b/src/components/common/range-slider.jsindex b6b35f190..e9da2735c 100644--- a/src/components/common/range-slider.js+++ b/src/components/common/range-slider.js@@ -230,12 +230,7 @@ export default class RangeSlider extends Component {onSlider0Change={this._setRangeVal0}onSlider1Change={this._setRangeVal1}onSliderBarChange={(val0, val1) => {- if (this._isVal1InRange(val1) && this._isVal0InRange(val0)) {- onChange([- this._roundValToStep(val0),- this._roundValToStep(val1)- ]);- }+ onChange([val0, val1]);}}enableBarDrag/>diff --git a/src/components/common/slider/mouse-event.js b/src/components/common/slider/mouse-event.jsindex 0c4991501..e11221613 100644--- a/src/components/common/slider/mouse-event.js+++ b/src/components/common/slider/mouse-event.js@@ -18,10 +18,80 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-export function getMouseDeltaX(e, prevX) {+import document from 'global/document';- // movementX might not be supported in some browser- // https://stackoverflow.com/questions/41774726/mouseevent-movementx-property-apparently-not-supported-in-internet-explorer- const deltaX = e.movementX === 0 ? e.clientX - prevX : e.movementX;- return {deltaX, prevX: e.clientX};+function nope() {}++export default class MouseEventHandler {+ constructor({+ vertical = false,+ valueListener = nope,+ toggleMouseOver = nope+ }) {+ this._vertical = vertical;+ this._valueListener = valueListener;+ this._toggleMouseOver = toggleMouseOver;++ this._prev = 0;+ }++ handleMouseDown = (e) => {+ document.addEventListener('mouseup', this._mouseup);+ document.addEventListener('mousemove', this._mousemove);+ this._prev = this._getMousePos(e);+ this._toggleMouseOver();+ };++ _getMousePos(e) {+ return this._vertical ? e.clientY : e.pageX;+ }+ _getTouchPosition(e) {+ return this._vertical ? e.touches[0].clientY : e.touches[0].pageX;+ }++ _getMouseDelta(e) {++ // movementX might not be supported in some browser+ // https://stackoverflow.com/questions/41774726/mouseevent-movementx-property-apparently-not-supported-in-internet-explorer+ const mouseCoord = this._vertical ? e.movementY : e.movementX;+ const clientCoord = this._getMousePos(e)++ const delta = mouseCoord === 0 ? clientCoord - this._prev : mouseCoord;++ return delta;+ };++ _mouseup = () => {+ document.removeEventListener('mouseup', this._mouseup);+ document.removeEventListener('mousemove', this._mousemove);+ this._toggleMouseOver();+ };++ _mousemove = e => {+ e.preventDefault();++ const delta = this._getMouseDelta(e);+ this._prev = this._getMousePos(e);++ this._valueListener(delta);+ };++ handleTouchStart = e => {+ document.addEventListener('touchend', this._touchend);+ document.addEventListener('touchmove', this._touchmove);+ this._prev = this._getTouchPosition(e);+ this._toggleMouseOver();+ };++ _touchmove = e => {+ const delta = this._getTouchPosition(e) - this._prev;+ this._prev = this._getTouchPosition(e);+ this.props._valueListener(delta);+ };++ _touchend = () => {+ document.removeEventListener('touchend', this._touchend);+ document.removeEventListener('touchmove', this._touchmove);+ this._toggleMouseOver();+ };}diff --git a/src/components/common/slider/slider-bar-handle.js b/src/components/common/slider/slider-bar-handle.jsindex c9a93b1ed..daed2f610 100644--- a/src/components/common/slider/slider-bar-handle.js+++ b/src/components/common/slider/slider-bar-handle.js@@ -18,12 +18,11 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-import document from 'global/document';import React, {Component} from 'react';import PropTypes from 'prop-types';import classnames from 'classnames';import styled from 'styled-components';-import {getMouseDeltaX} from './mouse-event';+import MouseEventHandler from './mouse-event';const StyledSlider = styled.div`position: relative;@@ -31,91 +30,67 @@ const StyledSlider = styled.div`props.active? props.theme.sliderBarHoverColor: props.theme.sliderBarColor};- height: ${props => props.theme.sliderBarHeight};+ ${props => `${props.vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};border-radius: ${props => props.theme.sliderBarRadius};:hover {cursor: pointer;}`;-/**- *- * props:- * width : default 23- * height : default 23- * left- * onMove- * sliderBarListener- */-export default class SliderHandle extends Component {++function nope() {}++export default class SliderBarHandle extends Component {+static propTypes = {width: PropTypes.number,left: PropTypes.string,sliderBarListener: PropTypes.func,- enableBarDrag: PropTypes.bool+ enableBarDrag: PropTypes.bool,+ vertical: PropTypes.bool};static defaultProps = {- sliderBarListener: function sliderBarListenerTn() {},- enableBarDrag: false- };-- state = {mouseOver: false};- prevX = 0;-- handleMouseDown = (e) => {- document.addEventListener('mouseup', this.mouseup);- document.addEventListener('mousemove', this.mousemove);- this.prevX = e.clientX;- this.setState({mouseOver: true});- };-- mouseup = () => {- document.removeEventListener('mouseup', this.mouseup);- document.removeEventListener('mousemove', this.mousemove);- this.setState({mouseOver: false});+ sliderBarListener: nope,+ enableBarDrag: false,+ vertical: false};- mousemove = e => {- e.preventDefault();+ constructor(props) {+ super(props);+ this.mouseEvent = new MouseEventHandler({+ vertical: props.vertical,+ valueListener: props.sliderBarListener,+ toggleMouseOver: this.toggleMouseOver+ });+ }- const {deltaX, prevX} = getMouseDeltaX(e, this.prevX);- this.props.sliderBarListener(deltaX);- this.prevX = prevX;- };+ state = {mouseOver: false};- handleTouchStart = e => {- document.addEventListener('touchend', this.touchend);- document.addEventListener('touchmove', this.touchmove);- this.prevX = e.touches[0].clientX;- this.setState({mouseOver: true});+ toggleMouseOver = () => {+ this.setState({mouseOver: !this.state.mouseOver});};- touchmove = e => {- const deltaX = e.touches[0].clientX - this.prevX;- this.prevX = e.touches[0].clientX;- this.props.sliderBarListener(deltaX);- };+ render() {+ const {width, v0Left} = this.props;- touchend = () => {- document.removeEventListener('touchend', this.touchend);- document.removeEventListener('touchmove', this.touchmove);- this.setState({mouseOver: false});- };+ const style = this.props.vertical ? {+ height: `${width}%`,+ bottom: `${-100 + width + v0Left}%`+ } : {+ width: `${width}%`,+ left: `${v0Left}%`+ };- render() {return (<StyledSlideractive={this.state.mouseOver}className={classnames('kg-range-slider__bar', {'kg-range-slider__bar--active': this.state.mouseOver})}- style={{- width: `${this.props.width}%`,- left: `${this.props.v0Left}%`- }}- onMouseDown={this.props.enableBarDrag && this.handleMouseDown}- onTouchStart={this.props.enableBarDrag && this.handleTouchStart}+ style={style}+ onMouseDown={this.props.enableBarDrag ? this.mouseEvent.handleMouseDown : nope}+ onTouchStart={this.props.enableBarDrag ? this.mouseEvent.handleTouchStart : nope}/>);}diff --git a/src/components/common/slider/slider-handle.js b/src/components/common/slider/slider-handle.jsindex 7402001b8..83b5d3efc 100644--- a/src/components/common/slider/slider-handle.js+++ b/src/components/common/slider/slider-handle.js@@ -18,26 +18,25 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-import document from 'global/document';import React, {Component} from 'react';import PropTypes from 'prop-types';import classnames from 'classnames';import styled from 'styled-components';-import {getMouseDeltaX} from './mouse-event';+import MouseEventHandler from './mouse-event';const StyledSliderHandle = styled.span`position: absolute;z-index: 10;- display: ${props => (props.hidden ? 'none' : 'block')};- margin-top: -4px;+ margin-${props => (props.vertical ? 'left' : 'top')}: -${props =>+ (props.sliderHandleWidth - props.theme.sliderBarHeight) / 2}px;height: ${props =>Number.isFinite(props.sliderHandleWidth)- ? `${props.sliderHandleWidth}px`- : props.theme.sliderHandleHeight};+ ? props.sliderHandleWidth+ : props.theme.sliderHandleHeight}px;width: ${props =>Number.isFinite(props.sliderHandleWidth)- ? `${props.sliderHandleWidth}px`- : props.theme.sliderHandleHeight};+ ? props.sliderHandleWidth+ : props.theme.sliderHandleHeight}px;box-shadow: ${props => props.theme.sliderHandleShadow};background-color: ${props => props.theme.sliderHandleColor};border-width: 1px;@@ -53,87 +52,118 @@ const StyledSliderHandle = styled.span`}`;-/**- *- * props:- * width : default 23- * height : default 23- * display- * left- * onMove- * valueListener- */+const StyledSliderTooltip = styled.div`+ position: absolute;+ border-radius: 3px;+ display: inline-block;+ pointer-events: none;+ transition: opacity 0.3s ease-out;+ z-index: 999;+ margin-left: ${props => props.sliderHandleWidth + 12}px;+ font-size: 9.5px;+ font-weight: 500;+ padding: 7px 10px;+ background-color: ${props => props.theme.tooltipBg};+ color: ${props => props.theme.tooltipColor};+ margin-bottom: -6px;+ width: 50px;++ :before,:after {+ content: '';+ width: 0;+ height: 0;+ position: absolute;+ }++ :before {+ border-top: 6px solid transparent;+ border-bottom: 6px solid transparent;+ left: -8px;+ top: 50%;+ }++ :after {+ border-top: 5px solid transparent;+ border-bottom: 5px solid transparent;+ left: -6px;+ top: 50%;+ margin-top: -4px;+ border-right-color: ${props => props.theme.tooltipBg};+ border-right-style: solid;+ border-right-width: 6px;+ }+`;++const SliderTooltip = ({+ value,+ format = val => val,+ style,+ sliderHandleWidth+}) => {+ return (+ <StyledSliderTooltip+ sliderHandleWidth={sliderHandleWidth}+ style={style}>{format(value)}+ </StyledSliderTooltip>+ )+}+export default class SliderHandle extends Component {static propTypes = {- width: PropTypes.number,- height: PropTypes.number,+ sliderHandleWidth: PropTypes.number,left: PropTypes.string,display: PropTypes.bool,- valueListener: PropTypes.func+ valueListener: PropTypes.func,+ vertical: PropTypes.bool};static defaultProps = {+ sliderHandleWidth: 12,left: '50%',display: true,- valueListener: function valueListenerFn() {}+ vertical: false,+ valueListener: function valueListenerFn() {},+ showTooltip: false};- state = {mouseOver: false};- prevX = 0;+ constructor(props) {+ super(props);- handleMouseDown = (e) => {- document.addEventListener('mouseup', this.mouseup);- document.addEventListener('mousemove', this.mousemove);- this.prevX = e.clientX;- this.setState({mouseOver: true});- };-- mouseup = () => {- document.removeEventListener('mouseup', this.mouseup);- document.removeEventListener('mousemove', this.mousemove);- this.setState({mouseOver: false});- };-- mousemove = e => {- e.preventDefault();-- const {deltaX, prevX} = getMouseDeltaX(e, this.prevX);- this.props.valueListener(deltaX);- this.prevX = prevX;- };-- handleTouchStart = e => {- document.addEventListener('touchend', this.touchend);- document.addEventListener('touchmove', this.touchmove);- this.prevX = e.touches[0].clientX;- this.setState({mouseOver: true});- };+ this.mouseEvent = new MouseEventHandler({+ vertical: props.vertical,+ valueListener: props.valueListener,+ toggleMouseOver: this.toggleMouseOver+ });+ }- touchmove = e => {- const deltaX = e.touches[0].clientX - this.prevX;- this.prevX = e.touches[0].clientX;- this.props.valueListener(deltaX);- };+ state = {mouseOver: false};- touchend = () => {- document.removeEventListener('touchend', this.touchend);- document.removeEventListener('touchmove', this.touchmove);- this.setState({mouseOver: false});+ toggleMouseOver = () => {+ this.setState({mouseOver: !this.state.mouseOver});};render() {+ const style = {[this.props.vertical ? 'bottom' : 'left']: this.props.left};+return (- <StyledSliderHandle- className={classnames('kg-range-slider__handle', {- 'kg-range-slider__handle--active': this.state.mouseOver- })}- sliderHandleWidth={this.props.sliderHandleWidth}- active={this.state.mouseOver}- hidden={!this.props.display}- style={{left: this.props.left}}- onMouseDown={this.handleMouseDown}- onTouchStart={this.handleTouchStart}- />+ <div style={{display: this.props.display ? 'block' : 'none'}}>+ {this.props.showTooltip && this.state.mouseOver ? <SliderTooltip+ style={style}+ sliderHandleWidth={this.props.sliderHandleWidth}+ value={Number.isFinite(this.props.value) ? this.props.value : null}+ /> : null}+ <StyledSliderHandle+ className={classnames('kg-range-slider__handle', {+ 'kg-range-slider__handle--active': this.state.mouseOver+ })}+ sliderHandleWidth={this.props.sliderHandleWidth}+ active={this.state.mouseOver}+ vertical={this.props.vertical}+ style={style}+ onMouseDown={this.mouseEvent.handleMouseDown}+ onTouchStart={this.mouseEvent.handleTouchStart}+ />+ </div>);}-};+}diff --git a/src/components/common/slider/slider.js b/src/components/common/slider/slider.jsindex 8d5e6d416..78635d6b5 100644--- a/src/components/common/slider/slider.js+++ b/src/components/common/slider/slider.js@@ -25,6 +25,7 @@ import styled from 'styled-components';import SliderHandle from './slider-handle';import SliderBarHandle from './slider-bar-handle';+import {roundValToStep} from 'utils/data-utils';function noop() {}@@ -32,12 +33,14 @@ const StyledRangeSlider = styled.div`position: relative;margin-bottom: 12px;background-color: ${props => props.theme.sliderBarBgd};- height: ${props => props.theme.sliderBarHeight};+ ${props =>+ `${props.vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};+ ${props => `${props.vertical ? 'height' : 'width'}: 100%`};`;const SliderWrapper = styled.div`flex-grow: 1;- margin-top: ${props => props.isRanged ? 0 : 10}px;+ margin-top: ${props => (props.isRanged ? 0 : 10)}px;`;export default class Slider extends Component {@@ -55,7 +58,8 @@ export default class Slider extends Component {onInput1Change: PropTypes.func,onSliderBarChange: PropTypes.func,step: PropTypes.number,- enableBarDrag: PropTypes.bool+ enableBarDrag: PropTypes.bool,+ showTooltip: PropTypes.bool};static defaultProps = {@@ -73,7 +77,9 @@ export default class Slider extends Component {onSlider1Change: noop,onInput1Change: noop,onSliderBarChange: noop,- disabled: false+ disabled: false,+ vertical: false,+ showTooltip: false};ref = undefined;@@ -82,32 +88,64 @@ export default class Slider extends Component {this.ref = ref;};- slide0Listener = x => {- const xPercent = x / this.ref.offsetWidth;+ _getBaseDistance() {+ return this.props.vertical ? this.ref.offsetHeight : this.ref.offsetWidth;+ }++ _getValDelta(x) {+ const percent = x / this._getBaseDistance();const maxDelta = this.props.maxValue - this.props.minValue;- const val = xPercent * maxDelta;- this.props.onSlider0Change.call(this, val + this.props.value0);+ return percent * maxDelta;+ }++ _getValue(val, offset) {+ const delta = this._getValDelta(offset);+ const rawValue = this.props.vertical ? val - delta : val + delta;++ return this._roundValToStep(rawValue);+ }++ _isVal0InRange = val => {+ const {value1, minValue} = this.props;+ return Boolean(val >= minValue && val <= value1);+ };++ _isVal1InRange = val => {+ const {maxValue, value0} = this.props;+ return Boolean(val <= maxValue && val >= value0);+ };++ _roundValToStep(val) {+ const {minValue, step} = this.props;+ return roundValToStep(minValue, step, val);+ }++ slide0Listener = x => {+ const val = this._getValue(this.props.value0, x);+ if (this._isVal0InRange(val)) {+ this.props.onSlider0Change(val);+ }};slide1Listener = x => {- const xPercent = x / this.ref.offsetWidth;- const maxDelta = this.props.maxValue - this.props.minValue;- const val = xPercent * maxDelta;- this.props.onSlider1Change(val + this.props.value1);+ const val = this._getValue(this.props.value1, x);+ if (this._isVal1InRange(val)) {+ this.props.onSlider1Change(val);+ }};sliderBarListener = x => {- const xPercent = x / this.ref.offsetWidth;- const maxDelta = this.props.maxValue - this.props.minValue;- const val = xPercent * maxDelta;- const val0 = val + this.props.value0;- const val1 = val + this.props.value1;- this.props.onSliderBarChange(val0, val1);+ const val0 = this._getValue(this.props.value0, x);+ const val1 = this._getValue(this.props.value1, x);+ if (this._isVal1InRange(val1) && this._isVal0InRange(val0)) {+ this.props.onSliderBarChange(val0, val1);+ }};calcHandleLeft0 = (w, l, num) => {- return w === 0 ? `calc(${l}% - ${this.props.sliderHandleWidth / 2}px)` :- `calc(${l}% - ${this.props.sliderHandleWidth / 2}px)`;+ return w === 0+ ? `calc(${l}% - ${this.props.sliderHandleWidth / 2}px)`+ : `calc(${l}% - ${this.props.sliderHandleWidth / 2}px)`;};calcHandleLeft1 = (w, l) => {@@ -116,56 +154,57 @@ export default class Slider extends Component {: `calc(${l + w}% - ${this.props.sliderHandleWidth / 2}px)`;};- createSlider = (width, v0Left) => {+ render() {+ const {+ classSet,+ isRanged,+ maxValue,+ minValue,+ value1,+ vertical,+ sliderHandleWidth,+ showTooltip+ } = this.props;+ const value0 = !isRanged && minValue > 0 ? minValue : this.props.value0;+ const currValDelta = value1 - value0;+ const maxDelta = maxValue - minValue;+ const width = (currValDelta / maxDelta) * 100;+ const v0Left = ((value0 - minValue) / maxDelta) * 100;+return (- <div>- <StyledRangeSlider className="kg-range-slider">+ <SliderWrapper+ className={classnames('kg-slider', {...classSet})}+ ref={this._saveRef}+ isRanged={isRanged}+ vertical={vertical}+ >+ <StyledRangeSlider className="kg-range-slider" vertical={vertical}><SliderHandleclassName="kg-range-slider__handle"left={this.calcHandleLeft0(width, v0Left)}valueListener={this.slide0Listener}- sliderHandleWidth={this.props.sliderHandleWidth}- display={this.props.isRanged}+ sliderHandleWidth={sliderHandleWidth}+ display={isRanged}+ vertical={vertical}+ showTooltip={showTooltip}/><SliderHandleclassName="kg-range-slider__handle"left={this.calcHandleLeft1(width, v0Left)}valueListener={this.slide1Listener}- sliderHandleWidth={this.props.sliderHandleWidth}+ sliderHandleWidth={sliderHandleWidth}+ vertical={vertical}+ value={value1}+ showTooltip={showTooltip}/><SliderBarHandlewidth={width}v0Left={v0Left}enableBarDrag={this.props.enableBarDrag}sliderBarListener={this.sliderBarListener}+ vertical={vertical}/></StyledRangeSlider>- </div>- );- };-- render() {- const {- classSet,- isRanged,- maxValue,- minValue,- value1- } = this.props;- const value0 = !isRanged && minValue > 0 ? minValue : this.props.value0;- const currValDelta = value1 - value0;- const maxDelta = maxValue - minValue;- const width = currValDelta / maxDelta * 100;-- const v0Left = (value0 - minValue) / maxDelta * 100;-- return (- <SliderWrapper- className={classnames('kg-slider', {...classSet})}- ref={this._saveRef}- isRanged={isRanged}- >- {this.createSlider(width, v0Left)}</SliderWrapper>);}diff --git a/src/components/common/time-range-slider.js b/src/components/common/time-range-slider.jsindex 877e51a82..18a3d9547 100644--- a/src/components/common/time-range-slider.js+++ b/src/components/common/time-range-slider.js@@ -163,11 +163,11 @@ export default class TimeRangeSlider extends Component {const TimeValueWrapper = styled.div`display: flex;- height: ${props => props.theme.secondaryInputHeight};+ height: 32px;align-items: center;font-size: 11px;justify-content: ${props => props.isEnlarged ? 'center' : 'space-between'};- color: ${props => props.theme.labelColor};+ color: ${props => props.theme.textColorHl};.horizontal-bar {padding: 0 12px;diff --git a/src/components/filters/animation-speed-toggle.js b/src/components/filters/animation-speed-toggle.jsnew file mode 100644index 000000000..edf4263a3--- /dev/null+++ b/src/components/filters/animation-speed-toggle.js@@ -0,0 +1,68 @@+// Copyright (c) 2019 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, {Component} from 'react';+import styled from 'styled-components';+import Slider from 'components/common/slider/slider';+import onClickOutside from 'react-onclickoutside';++const SliderWrapper = styled.div`+ position: relative;+ width: 20px;+ height: 120px;+ flex-direction: column;+ display: flex;+`;++const VerticalSliderContainer = styled.div`+ position: absolute;+ right: 96px;+ bottom: 10px;+ width: 40px;+ padding-left: 18px;+`;++class AnimationSpeedToggle extends Component {+ handleClickOutside = e => {+ this.props.onHide();+ };++ render() {+ const {updateAnimationSpeed, speed} = this.props;+ return (+ <VerticalSliderContainer>+ <SliderWrapper>+ <Slider+ minValue={0}+ maxValue={10}+ step={0.1}+ value1={speed}+ onSlider1Change={updateAnimationSpeed}+ isRanged={false}+ vertical+ showTooltip+ />+ </SliderWrapper>+ </VerticalSliderContainer>+ );+ }+}++export default onClickOutside(AnimationSpeedToggle);diff --git a/src/components/filters/time-widget.js b/src/components/filters/time-widget.jsindex dced1cbfc..826a367f8 100644--- a/src/components/filters/time-widget.js+++ b/src/components/filters/time-widget.js@@ -23,10 +23,11 @@ import styled from 'styled-components';import {createSelector} from 'reselect';import FieldSelector from 'components/common/field-selector';-import {SelectTextBold, IconRoundSmall, CenterFlexbox} from 'components/common/styled-components';+import {Button, SelectTextBold, IconRoundSmall, CenterFlexbox} from 'components/common/styled-components';import TimeRangeFilter from 'components/filters/time-range-filter';-import {Close, Clock, LineChart} from 'components/common/icons';-import {TIME_ANIMATION_SPEED} from 'utils/filter-utils';+import {Close, Clock, LineChart, Rocket} from 'components/common/icons';+import AnimationSpeedToggle from './animation-speed-toggle';+const innerPdSide = 32;const WidgetContainer = styled.div`@@ -34,7 +35,7 @@ const WidgetContainer = styled.div`padding-top: ${props => props.theme.sidePanel.margin.top}px;padding-right: ${props => props.theme.sidePanel.margin.right}px;padding-bottom: ${props => props.theme.sidePanel.margin.bottom}px;- padding-left: ${props => props.theme.sidePanel.margin.left}px;+ padding-left: ${props => props.theme.sidePanel.margin.left}px;bottom: 0;right: 0;z-index: 1;@@ -42,7 +43,7 @@ const WidgetContainer = styled.div`.bottom-widget--inner {background-color: ${props => props.theme.sidePanelBg};- padding: 10px ${innerPdSide}px;+ padding: 6px ${innerPdSide}px 10px ${innerPdSide}px;position: relative;}`;@@ -54,15 +55,41 @@ const TopSectionWrapper = styled.div`width: 100%;padding-right: ${innerPdSide * 2}px;color: ${props => props.theme.labelColor};-+.bottom-widget__y-axis {flex-grow: 1;margin-left: 20px;}-+.bottom-widget__field-select {width: 160px;display: inline-block;++ .item-selector__dropdown {+ background: transparent;+ padding: 4px 10px 4px 4px;+ border-color: transparent;++ :active,+ :focus,+ &.focus,+ &.active {+ background: transparent;+ border-color: transparent;+ }+ }++ .item-selector__dropdown:hover {+ background: transparent;+ border-color: transparent;++ .item-selector__dropdown__value {+ color: ${props =>+ props.hoverColor+ ? props.theme[props.hoverColor]+ : props.theme.textColorHl};+ }+ }}`;@@ -83,7 +110,7 @@ const Tab = styled.div`text-align: center;width: 24px;line-height: 24px;-+:hover {cursor: pointer;}@@ -93,22 +120,25 @@ const Tab = styled.div`const StyledTitle = styled(CenterFlexbox)`flex-grow: 0;color: ${props => props.theme.textColor};+ margin-right: 10px;.bottom-widget__icon {margin-right: 6px;}+ .bottom-widget__icon.speed {+ margin-right: 0;+ }`;-const AnimationSpeedToggle = ({updateAnimationSpeed, speed}) => (- <Tabs>- {TIME_ANIMATION_SPEED.map(({label, value}) => (- <Tab key={value} active={value === speed}- onClick={() => updateAnimationSpeed(value)}>{label}</Tab>- ))}- </Tabs>-);-export class TimeWidget extends Component {+ state = {+ showSpeedControl: false+ };++ _toggleSpeedControl = () => {+ this.setState({showSpeedControl: !this.state.showSpeedControl})+ };+fieldSelector = props => props.fields;yAxisFieldsSelector = createSelector(this.fieldSelector, fields =>fields.filter(f => f.type === 'integer' || f.type === 'real')@@ -127,6 +157,7 @@ export class TimeWidget extends Component {width} = this.props;+ const {showSpeedControl} = this.state;return (<WidgetContainer width={width}><div className="bottom-widget--inner">@@ -149,18 +180,33 @@ export class TimeWidget extends Component {value={filter.yAxis ? filter.yAxis.name : null}onSelect={value => setFilterPlot(enlargedIdx, {yAxis: value})}inputTheme="secondary"- placeholder="Select Y Axis"+ placeholder="Y Axis"erasableshowToken={false}/></div></StyledTitle>- <AnimationSpeedToggle- updateAnimationSpeed={(speed) => updateAnimationSpeed(enlargedIdx, speed)}- speed={filter.speed}/>- <IconRoundSmall>- <Close height="12px" onClick={() => enlargeFilter(enlargedIdx)} />- </IconRoundSmall>+ <StyledTitle className="bottom-widget__speed">+ <Button link width="80px" onClick={this._toggleSpeedControl}>+ <CenterFlexbox className="bottom-widget__icon speed">+ <Rocket height="15px"/>+ </CenterFlexbox>+ <div style={{+ visibility: !showSpeedControl ? 'visible' : 'hidden',+ display: 'inline-block',+ width: '27px'+ }}>{filter.speed}x</div>+ </Button>+ {showSpeedControl ? <AnimationSpeedToggle+ onHide={this._toggleSpeedControl}+ updateAnimationSpeed={(speed) => updateAnimationSpeed(enlargedIdx, speed)}+ speed={filter.speed}/> : null}+ </StyledTitle>+ <CenterFlexbox>+ <IconRoundSmall>+ <Close height="12px" onClick={() => enlargeFilter(enlargedIdx)} />+ </IconRoundSmall>+ </CenterFlexbox></TopSectionWrapper><TimeRangeFilterfilter={filter}diff --git a/src/components/notification-panel.js b/src/components/notification-panel.jsindex 9244f56a8..445203f81 100644--- a/src/components/notification-panel.js+++ b/src/components/notification-panel.js@@ -40,13 +40,9 @@ const NotificationPanelContent = styled.div`box-sizing: border-box;`;-NotificationPanelFactory.deps = [- NotificationItemFactory-];+NotificationPanelFactory.deps = [NotificationItemFactory];-export default function NotificationPanelFactory (- NotificationItem-) {+export default function NotificationPanelFactory(NotificationItem) {return class NotificationPanel extends Component {static propTypes = {removeNotification: PropTypes.func.isRequired,@@ -54,21 +50,23 @@ export default function NotificationPanelFactory (};render() {+ const globalNotifications = this.props.notifications.filter(+ n => n.topic === DEFAULT_NOTIFICATION_TOPICS.global+ );return (- <NotificationPanelContent className="notification-panel">- {this.props.notifications- .filter(n => n.topic === DEFAULT_NOTIFICATION_TOPICS.global)- .map(n => (- <NotificationItem- key={n.id}- notification={n}- removeNotification={this.props.removeNotification}- />- ))- }+ <NotificationPanelContent+ className="notification-panel"+ style={{display: globalNotifications.length ? 'block' : 'none'}}+ >+ {globalNotifications.map(n => (+ <NotificationItem+ key={n.id}+ notification={n}+ removeNotification={this.props.removeNotification}+ />+ ))}</NotificationPanelContent>);}- }+ };}-diff --git a/src/styles/base.js b/src/styles/base.jsindex 0d4532c19..6aecb5dd1 100644--- a/src/styles/base.js+++ b/src/styles/base.js@@ -196,9 +196,9 @@ export const sliderBarColor = '#6A7485';export const sliderBarBgd = '#3A414C';export const sliderBarHoverColor = '#D3D8E0';export const sliderBarRadius = '1px';-export const sliderBarHeight = '4px';-export const sliderHandleHeight = '12px';-export const sliderHandleWidth = '12px';+export const sliderBarHeight = 4;+export const sliderHandleHeight = 12;+export const sliderHandleWidth = 12;export const sliderHandleColor = '#D3D8E0';export const sliderHandleHoverColor = '#FFFFFF';export const sliderHandleShadow = '0 2px 4px 0 rgba(0,0,0,0.40)';