Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/components/fields/MarkerColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,21 @@ class UnconnectedMarkerColor extends Component {
renderConstantControls() {
const _ = this.context.localize;
return (
<div className="markercolor-constantcontrols__container">
<MultiColorPicker
attr="marker.color"
multiColorMessage={_(
'Each trace will be colored according to the selected colorscale.'
)}
singleColorMessage={_(
'All traces will be colored in the the same color.'
)}
setColor={this.setColor}
setColorScale={this.setColorScale}
onConstantColorOptionChange={this.onConstantColorOptionChange}
parentSelectedConstantColorOption={
this.state.selectedConstantColorOption
}
/>
</div>
<MultiColorPicker
attr="marker.color"
multiColorMessage={_(
'Each trace will be colored according to the selected colorscale.'
)}
singleColorMessage={_(
'All traces will be colored in the the same color.'
)}
setColor={this.setColor}
setColorScale={this.setColorScale}
onConstantColorOptionChange={this.onConstantColorOptionChange}
parentSelectedConstantColorOption={
this.state.selectedConstantColorOption
}
/>
);
}

Expand Down
99 changes: 32 additions & 67 deletions src/components/widgets/ColorPicker.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import Fields from 'react-color/lib/components/sketch/SketchFields';
import PresetColors from 'react-color/lib/components/sketch/SketchPresetColors';
import React, {Component} from 'react';
import React, {Component, Fragment} from 'react';
import PropTypes from 'prop-types';
import tinycolor from 'tinycolor2';
import {
Alpha,
Hue,
Saturation,
Checkboard,
} from 'react-color/lib/components/common';
import {Hue, Saturation} from 'react-color/lib/components/common';
import {CustomPicker as customPicker} from 'react-color';
import {DEFAULT_COLORS} from 'lib/constants';

// Utility functions for converting ColorPicker color objects or raw strings
// into TinyColor objects.
Expand All @@ -20,55 +13,28 @@ const toTinyColor = c => tinycolor(getColorSource(c));

class Custom extends Component {
render() {
const {rgb, onChangeComplete} = this.props;
const {r, g, b, a} = rgb;

const activeColor = {
backgroundColor: `rgba(${r}, ${g}, ${b}, ${a})`,
};

const _ = this.context.localize;
const {onChangeComplete} = this.props;

return (
<div>
<div>
<p className="colorpicker__title">{_('Custom Color')}</p>
<div className="colorpicker__saturation">
<Saturation {...this.props} />
</div>
<div className="colorpicker__controls +flex">
<div className="colorpicker__sliders">
<div className="colorpicker__slider">
<Hue {...this.props} />
</div>
<div className="colorpicker__slider">
<Alpha {...this.props} />
</div>
</div>
<div className="colorpicker__active">
<Checkboard />
<div style={activeColor} className="colorpicker__active-swatch" />
<div className="colorpicker__outer">
<div className="colorpicker__controls +flex">
<div className="colorpicker__sliders">
<div className="colorpicker__slider">
<Hue {...this.props} />
</div>
</div>
<div className="colorpicker__custom-input">
<Fields {...this.props} onChange={onChangeComplete} />
</div>
</div>
<div>
<p className="colorpicker__title">{_('Default Colors')}</p>
<div className="colorpicker__preset-colors">
<PresetColors colors={DEFAULT_COLORS} onClick={onChangeComplete} />
</div>
<div className="colorpicker__saturation">
<Saturation {...this.props} />
</div>
<div className="colorpicker__custom-input">
<Fields {...this.props} onChange={onChangeComplete} />
</div>
</div>
);
}
}

Custom.contextTypes = {
localize: PropTypes.func,
};

Custom.propTypes = {
rgb: PropTypes.object,
onChangeComplete: PropTypes.func,
Expand Down Expand Up @@ -120,32 +86,31 @@ class ColorPicker extends Component {
const swatchStyle = {backgroundColor: rgbString};

return (
<div className="colorpicker__container">
<div className="colorpicker">
<Fragment>
<div className="colorpicker__container">
<div className="colorpicker">
<div
className="colorpicker__swatch +cursor-clickable"
style={swatchStyle}
onClick={this.toggleVisible}
/>
</div>

<div
className="colorpicker__swatch +cursor-clickable"
style={swatchStyle}
className="colorpicker__selected-color +hover-grey"
onClick={this.toggleVisible}
/>
</div>

<div
className="colorpicker__selected-color +hover-grey"
onClick={this.toggleVisible}
>
{colorText}
>
{colorText}
</div>
</div>

{this.state.isVisible && (
<div className="colorpicker__popover">
<div className="colorpicker__cover" onClick={this.toggleVisible} />
<CustomColorPicker
color={rgbString}
onChangeComplete={this.onSelectedColorChange}
/>
</div>
<CustomColorPicker
color={rgbString}
onChangeComplete={this.onSelectedColorChange}
/>
)}
</div>
</Fragment>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/widgets/ColorscalePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Scale extends Component {
const _ = this.context.localize;

return (
<Fragment>
<div className="customPickerContainer__outer">
<Colorscale colorscale={selected} onClick={this.onClick} />

{showColorscalePicker ? (
Expand Down Expand Up @@ -73,7 +73,7 @@ class Scale extends Component {
) : null}
</div>
) : null}
</Fragment>
</div>
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/styles/components/fields/_field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
&__widget {
display: flex;
flex-wrap: wrap;
flex-basis: 0;
padding-right: var(--spacing-half-unit);
padding-left: var(--spacing-half-unit);
align-self: center;
Expand Down
1 change: 0 additions & 1 deletion src/styles/components/fields/_main.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@import 'field';
@import 'symbolselector';
@import 'markercolor';
3 changes: 0 additions & 3 deletions src/styles/components/fields/_markercolor.scss

This file was deleted.

49 changes: 7 additions & 42 deletions src/styles/components/widgets/_colorpicker.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
$swatch-size: 20px;
$colorpicker-width: 250px;
$saturation-picker-height: 160px;
$saturation-picker-height: 100px;
$slider-picker-height: 10px;
$colorpicker-width: 185px;

%colorpicker__component {
position: relative;
overflow: hidden;
margin: 0 var(--spacing-half-unit);
border: var(--border-default);
border-radius: var(--border-radius-small);
cursor: pointer;
Expand All @@ -21,32 +20,15 @@ $slider-picker-height: 10px;
border: var(--border-default);
padding: var(--spacing-eighth-unit);

&__popover {
left: -60px;
position: absolute;
top: 100%;
margin: var(--spacing-quarter-unit) 0 var(--spacing-base-unit);
&__outer {
width: $colorpicker-width;
background-color: var(--color-background-top);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow-base);
border: var(--border-default);
@include z-index('cloud');
}
&__cover {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
@include z-index('underground');
}

&__container {
display: flex;
align-items: center;
line-height: 2;
position: relative;
width: $colorpicker-width;
}
&__selected-color {
margin-left: var(--spacing-half-unit);
Expand All @@ -70,7 +52,7 @@ $slider-picker-height: 10px;
height: $saturation-picker-height;
}
&__custom-input {
padding: var(--spacing-quarter-unit) var(--spacing-half-unit);
padding-top: var(--spacing-eighth-unit);
input {
border: var(--border-default) !important;
box-shadow: none !important;
Expand All @@ -84,16 +66,14 @@ $slider-picker-height: 10px;

/* Wrapper style for Hue and Alpha sliders and swatch */
&__controls {
margin: 0 var(--spacing-half-unit);

.colorpicker__sliders {
width: 200px;
width: 100%;

.colorpicker__slider {
@extend %colorpicker__component;
margin: auto 0;
height: $slider-picker-height;
margin-top: var(--spacing-eighth-unit);
margin: var(--spacing-eighth-unit) 0;
}
}

Expand All @@ -114,19 +94,4 @@ $slider-picker-height: 10px;
}
}
}

&__preset-colors {
margin: 0 var(--spacing-half-unit);
& > div {
border-top: var(--border-light) !important; // inline style override
padding: var(--spacing-half-unit) !important;
padding-bottom: var(--spacing-quarter-unit) !important;
}
}
&__title {
margin: var(--spacing-eighth-unit) var(--spacing-half-unit);
font-size: var(--font-size-medium);
font-weight: var(--font-weight-semibold);
color: var(--color-text-section-header);
}
}
9 changes: 8 additions & 1 deletion src/styles/components/widgets/_colorscalepicker.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$colorscalepicker-width: 215px;

.colorscalePickerContainer {
min-width: 215px;
min-width: $colorscalepicker-width;
position: relative;
padding: 0;
resize: none;
Expand All @@ -25,4 +27,9 @@

.customPickerContainer {
margin-top: var(--spacing-quarter-unit);

&__outer {
width: $colorscalepicker-width;
text-align: center;
}
}