diff --git a/dev/App.js b/dev/App.js index 51260be8e..593f6aec8 100644 --- a/dev/App.js +++ b/dev/App.js @@ -11,7 +11,6 @@ import Inspector from 'react-inspector'; import tips from './tips'; import 'brace/mode/json'; import 'brace/theme/textmate'; -import {categoryLayout, traceTypes, chartCategory} from 'lib/traceTypes'; // https://github.com/plotly/react-chart-editor#mapbox-access-tokens import ACCESS_TOKENS from '../accessTokens'; diff --git a/package.json b/package.json index e788bdc44..fe263c5b2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "prop-types": "^15.5.10", "raf": "^3.4.0", "react-color": "^2.13.8", - "react-colorscales": "^0.4.2", + "react-colorscales": "0.5.7", "react-dropzone": "^4.2.9", "react-plotly.js": "^2.2.0", "react-rangeslider": "^2.2.0", diff --git a/src/components/fields/Field.js b/src/components/fields/Field.js index e7eca2d95..749ec2895 100644 --- a/src/components/fields/Field.js +++ b/src/components/fields/Field.js @@ -27,6 +27,7 @@ class Field extends Component { suppressMultiValuedMessage, units, extraComponent, + fieldContainerClassName, } = this.props; const {localize: _} = this.context; @@ -48,8 +49,12 @@ class Field extends Component { ' – ' + this.context.description.replace(/`/g, '"').replace(/\*/g, '"'); } + const containerClassName = classnames(bem('field'), { + [fieldContainerClassName]: Boolean(fieldContainerClassName), + }); + return ( -
+
{label ? (
{this.context.showFieldTooltips ? ( @@ -98,6 +103,7 @@ Field.propTypes = { suppressMultiValuedMessage: PropTypes.bool, children: PropTypes.node, extraComponent: PropTypes.any, + fieldContainerClassName: PropTypes.string, }; Field.contextTypes = { diff --git a/src/components/widgets/ColorscalePicker.js b/src/components/widgets/ColorscalePicker.js index dcf303850..37f344538 100644 --- a/src/components/widgets/ColorscalePicker.js +++ b/src/components/widgets/ColorscalePicker.js @@ -1,34 +1,79 @@ -import ColorscalePicker, {Colorscale} from 'react-colorscales'; +import ColorscalePicker, { + Colorscale, + COLOR_PICKER_CONSTANTS, +} from 'react-colorscales'; +import Dropdown from './Dropdown'; +import Info from '../fields/Info'; import PropTypes from 'prop-types'; -import React, {Component} from 'react'; +import React, {Component, Fragment} from 'react'; class Scale extends Component { - constructor(props) { - super(props); + constructor() { + super(); + this.state = { + selectedColorscaleType: 'sequential', showColorscalePicker: false, }; - this.toggle = this.toggle.bind(this); + + this.onChange = this.onChange.bind(this); + this.onClick = this.onClick.bind(this); } - toggle() { + onClick() { this.setState({ showColorscalePicker: !this.state.showColorscalePicker, }); } + onChange(selectedColorscaleType) { + this.setState({selectedColorscaleType}); + } + render() { - const {selected, onColorscaleChange} = this.props; + const {onColorscaleChange, selected} = this.props; + const {selectedColorscaleType, showColorscalePicker} = this.state; + const description = + COLOR_PICKER_CONSTANTS.COLORSCALE_DESCRIPTIONS[selectedColorscaleType]; + const colorscaleOptions = COLOR_PICKER_CONSTANTS.COLORSCALE_TYPES.map( + type => ({ + label: type + ' scales', + value: type, + }) + ); + const _ = this.context.localize; + return ( -
- - {this.state.showColorscalePicker ? ( - + + + + {showColorscalePicker ? ( +
+ + {description ? ( + + + {description} + + ) : null} +
) : null} -
+ ); } } @@ -36,6 +81,15 @@ class Scale extends Component { Scale.propTypes = { onColorscaleChange: PropTypes.func, selected: PropTypes.array, + label: PropTypes.string, +}; + +Scale.contextTypes = { + localize: PropTypes.func, +}; + +Scale.contextTypes = { + localize: PropTypes.func, }; export default Scale; diff --git a/src/styles/components/widgets/_colorscalepicker.scss b/src/styles/components/widgets/_colorscalepicker.scss index f845259dd..a6ac60709 100644 --- a/src/styles/components/widgets/_colorscalepicker.scss +++ b/src/styles/components/widgets/_colorscalepicker.scss @@ -1,26 +1,28 @@ .colorscalePickerContainer { + min-width: 215px; position: relative; - width: 300px; - margin-left: -76px; + padding: 0; + resize: none; + border: none; + background: none; } .colorscalePickerContainer::-webkit-scrollbar { width: 5px; } -.colorscale-selected { +.colorscalePickerTopContainer { display: none; } -.rc-slider { - width: 254px !important; +.colorscaleDescription { + display: none; } -.colorscaleControlPanel { - padding: 6px; - width: 94%; +.colorscalePickerContainer input:focus { + outline: none; } -.colorscale-block { - margin: 0 20px !important; +.customPickerContainer { + margin-top: 10px; }