Skip to content

Commit

Permalink
[Maps] Improve Layer Style UI (#58406) (#58626)
Browse files Browse the repository at this point in the history
* Improving Layer Style UI

* Removing unnecessary method

* Updating snapshot

* Changing width value to make use of sass variable

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
miukimiu and elasticmachine authored Feb 27, 2020
1 parent 3e491f8 commit 05cad83
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import './layer_panel';
@import './filter_editor/filter_editor';
@import './join_editor/resources/join';
@import './join_editor/resources/join';
@import './style_settings/style_settings';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.mapStyleSettings__fixedBox {
width: $euiSize * 7.5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function StyleSettings({ layer, updateStyleDescriptor }) {

return (
<Fragment>
<EuiPanel>
<EuiPanel className="mapStyleSettings">
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="xs">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.mapColorStop {
position: relative;
padding-right: $euiSizeXL + $euiSizeS;

& + & {
margin-top: $euiSizeS;
Expand All @@ -17,23 +16,3 @@
}
}

.mapColorStop__icons {
flex-shrink: 0;
display: none;
position: absolute;
right: 0;
top: 50%;
margin-right: -$euiSizeS;
margin-top: -$euiSizeM;
}

@keyframes mapColorStopBecomeVisible {

0% {
opacity: 0;
}

100% {
opacity: 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class ColorMapSelect extends Component {
onChange={this._onColorMapSelect}
valueOfSelected={valueOfSelected}
hasDividers={true}
compressed
/>
{this._renderColorStopsInput()}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ import { removeRow, isColorInvalid } from './color_stops_utils';
import { i18n } from '@kbn/i18n';
import { EuiButtonIcon, EuiColorPicker, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';

function getColorStopRow({ index, errors, stopInput, colorInput, deleteButton, onAdd }) {
function getColorStopRow({ index, errors, stopInput, onColorChange, color, deleteButton, onAdd }) {
const colorPickerButtons = (
<div className="mapColorStop__icons">
{deleteButton}
<EuiButtonIcon
iconType="plusInCircle"
color="primary"
aria-label="Add"
title="Add"
onClick={onAdd}
/>
</div>
);
return (
<EuiFormRow
key={index}
Expand All @@ -19,22 +31,19 @@ function getColorStopRow({ index, errors, stopInput, colorInput, deleteButton, o
error={errors}
display="rowCompressed"
>
<div>
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="xs">
<EuiFlexItem>{stopInput}</EuiFlexItem>
<EuiFlexItem>{colorInput}</EuiFlexItem>
</EuiFlexGroup>
<div className="mapColorStop__icons">
{deleteButton}
<EuiButtonIcon
iconType="plusInCircle"
color="primary"
aria-label="Add"
title="Add"
onClick={onAdd}
<EuiFlexGroup alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{stopInput}
</EuiFlexItem>
<EuiFlexItem>
<EuiColorPicker
onChange={onColorChange}
color={color}
compressed
append={colorPickerButtons}
/>
</div>
</div>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFormRow>
);
}
Expand Down Expand Up @@ -80,17 +89,6 @@ export const ColorStops = ({
};
}

function getColorInput(onColorChange, color) {
return {
colorError: isColorInvalid(color)
? i18n.translate('xpack.maps.styles.colorStops.hexWarningLabel', {
defaultMessage: 'Color must provide a valid hex value',
})
: undefined,
colorInput: <EuiColorPicker onChange={onColorChange} color={color} compressed />,
};
}

const rows = colorStops.map((colorStop, index) => {
const onColorChange = color => {
const newColorStops = _.cloneDeep(colorStops);
Expand All @@ -102,7 +100,15 @@ export const ColorStops = ({
};

const { stopError, stopInput } = getStopInput(colorStop.stop, index);
const { colorError, colorInput } = getColorInput(onColorChange, colorStop.color);

const color = colorStop.color;

const colorError = isColorInvalid(color)
? i18n.translate('xpack.maps.styles.colorStops.hexWarningLabel', {
defaultMessage: 'Color must provide a valid hex value',
})
: undefined;

const errors = [];
if (stopError) {
errors.push(stopError);
Expand Down Expand Up @@ -131,7 +137,7 @@ export const ColorStops = ({
deleteButton = getDeleteButton(onRemove);
}

return getColorStopRow({ index, errors, stopInput, colorInput, deleteButton, onAdd });
return getColorStopRow({ index, errors, stopInput, onColorChange, color, deleteButton, onAdd });
});

return <div>{rows}</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ export function DynamicColorForm({

return (
<Fragment>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
fields={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export function StaticColorForm({
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<EuiColorPicker
onChange={onColorChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export function DynamicLabelForm({
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
fields={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export function StaticLabelForm({ onStaticStyleChange, staticDynamicSelect, styl
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<EuiFieldText
placeholder={i18n.translate('xpack.maps.styles.staticLabel.valuePlaceholder', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export function DynamicOrientationForm({
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
fields={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export function StaticOrientationForm({ onStaticStyleChange, staticDynamicSelect
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<ValidatedRange
min={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export function DynamicSizeForm({

return (
<Fragment>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
fields={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export function StaticSizeForm({ onStaticStyleChange, staticDynamicSelect, style
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<ValidatedRange
min={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ export class StylePropEditor extends Component {
anchorClassName="mapStyleFormDisabledTooltip"
content={getDisabledByMessage(this.props.disabledBy)}
>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<EuiFieldText compressed disabled />
</EuiFlexItem>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export function DynamicIconForm({

return (
<Fragment>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
fields={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class IconSelect extends Component {
closePopover={this._closePopover}
anchorPosition="downLeft"
panelPaddingSize="s"
display="block"
>
<EuiFocusTrap clickOutsideDisables={true}>{this._renderIconSelectable()}</EuiFocusTrap>
</EuiPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export function StaticIconForm({
};

return (
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexGroup gutterSize="xs" justifyContent="flexEnd">
<EuiFlexItem grow={false} className="mapStyleSettings__fixedBox">
{staticDynamicSelect}
</EuiFlexItem>
<EuiFlexItem>
<IconSelect
isDarkMode={isDarkMode}
Expand Down

0 comments on commit 05cad83

Please sign in to comment.