@@ -2,7 +2,9 @@ import ColorscalePicker, {Colorscale, COLOR_PICKER_CONSTANTS} from 'react-colors
22import Dropdown from './Dropdown' ;
33import Info from '../fields/Info' ;
44import PropTypes from 'prop-types' ;
5- import React , { Component , Fragment } from 'react' ;
5+ import React , { Component } from 'react' ;
6+ // CAREFUL: needs to be the same value as $colorscalepicker-width in _colorscalepicker.scss
7+ const colorscalepickerContainerWidth = 240 ;
68
79class Scale extends Component {
810 constructor ( props ) {
@@ -28,7 +30,7 @@ class Scale extends Component {
2830 }
2931
3032 render ( ) {
31- const { onColorscaleChange, selected} = this . props ;
33+ const { onColorscaleChange, selected, disableCategorySwitch } = this . props ;
3234 const { selectedColorscaleType, showColorscalePicker} = this . state ;
3335 const description = COLOR_PICKER_CONSTANTS . COLORSCALE_DESCRIPTIONS [ selectedColorscaleType ] ;
3436 const colorscaleOptions = COLOR_PICKER_CONSTANTS . COLORSCALE_TYPES . filter (
@@ -40,33 +42,36 @@ class Scale extends Component {
4042 const _ = this . context . localize ;
4143
4244 return (
43- < div className = "customPickerContainer__outer " >
44- < div className = "customPickerContainer__inner " >
45+ < div className = "customPickerContainer " >
46+ < div className = "customPickerContainer__clickable " >
4547 < Colorscale colorscale = { selected } onClick = { this . onClick } />
4648 </ div >
4749 { showColorscalePicker ? (
48- < div className = "customPickerContainer" >
49- < Dropdown
50- options = { colorscaleOptions }
51- value = { selectedColorscaleType }
52- onChange = { this . onChange }
53- clearable = { false }
54- searchable = { false }
55- placeholder = { _ ( 'Select a Colorscale Type' ) }
56- />
50+ < div className = "customPickerContainer__expanded-content" >
51+ { disableCategorySwitch ? null : (
52+ < Dropdown
53+ options = { colorscaleOptions }
54+ value = { selectedColorscaleType }
55+ onChange = { this . onChange }
56+ clearable = { false }
57+ searchable = { false }
58+ placeholder = { _ ( 'Select a Colorscale Type' ) }
59+ className = "customPickerContainer__category-dropdown"
60+ />
61+ ) }
5762 { description ? (
58- < Fragment >
63+ < div className = "customPickerContainer__palettes" >
5964 < ColorscalePicker
6065 onChange = { onColorscaleChange }
6166 colorscale = { selected }
62- width = { 215 }
67+ width = { colorscalepickerContainerWidth }
6368 colorscaleType = { this . state . selectedColorscaleType }
6469 onColorscaleTypeChange = { this . onColorscaleTypeChange }
6570 disableSwatchControls
6671 scaleLength = { 7 }
6772 />
68- < Info > { description } </ Info >
69- </ Fragment >
73+ < Info className = "customPickerContainer__info" > { description } </ Info >
74+ </ div >
7075 ) : null }
7176 </ div >
7277 ) : null }
@@ -80,6 +85,7 @@ Scale.propTypes = {
8085 selected : PropTypes . array ,
8186 label : PropTypes . string ,
8287 initialCategory : PropTypes . string ,
88+ disableCategorySwitch : PropTypes . bool ,
8389} ;
8490
8591Scale . contextTypes = {
0 commit comments