@@ -2,7 +2,9 @@ import ColorscalePicker, {Colorscale, COLOR_PICKER_CONSTANTS} from 'react-colors
2
2
import Dropdown from './Dropdown' ;
3
3
import Info from '../fields/Info' ;
4
4
import 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 ;
6
8
7
9
class Scale extends Component {
8
10
constructor ( props ) {
@@ -28,7 +30,7 @@ class Scale extends Component {
28
30
}
29
31
30
32
render ( ) {
31
- const { onColorscaleChange, selected} = this . props ;
33
+ const { onColorscaleChange, selected, disableCategorySwitch } = this . props ;
32
34
const { selectedColorscaleType, showColorscalePicker} = this . state ;
33
35
const description = COLOR_PICKER_CONSTANTS . COLORSCALE_DESCRIPTIONS [ selectedColorscaleType ] ;
34
36
const colorscaleOptions = COLOR_PICKER_CONSTANTS . COLORSCALE_TYPES . filter (
@@ -40,33 +42,36 @@ class Scale extends Component {
40
42
const _ = this . context . localize ;
41
43
42
44
return (
43
- < div className = "customPickerContainer__outer " >
44
- < div className = "customPickerContainer__inner " >
45
+ < div className = "customPickerContainer " >
46
+ < div className = "customPickerContainer__clickable " >
45
47
< Colorscale colorscale = { selected } onClick = { this . onClick } />
46
48
</ div >
47
49
{ 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
+ ) }
57
62
{ description ? (
58
- < Fragment >
63
+ < div className = "customPickerContainer__palettes" >
59
64
< ColorscalePicker
60
65
onChange = { onColorscaleChange }
61
66
colorscale = { selected }
62
- width = { 215 }
67
+ width = { colorscalepickerContainerWidth }
63
68
colorscaleType = { this . state . selectedColorscaleType }
64
69
onColorscaleTypeChange = { this . onColorscaleTypeChange }
65
70
disableSwatchControls
66
71
scaleLength = { 7 }
67
72
/>
68
- < Info > { description } </ Info >
69
- </ Fragment >
73
+ < Info className = "customPickerContainer__info" > { description } </ Info >
74
+ </ div >
70
75
) : null }
71
76
</ div >
72
77
) : null }
@@ -80,6 +85,7 @@ Scale.propTypes = {
80
85
selected : PropTypes . array ,
81
86
label : PropTypes . string ,
82
87
initialCategory : PropTypes . string ,
88
+ disableCategorySwitch : PropTypes . bool ,
83
89
} ;
84
90
85
91
Scale . contextTypes = {
0 commit comments