[Maps] background color map setting (#83822)

* [Maps] background color map setting

* tslint and jest tests

* get eui theme from kbn/ui-shared-deps/theme
This commit is contained in:
Nathan Reese 2020-11-20 10:02:36 -07:00 committed by GitHub
parent fcb83dad86
commit ac2c16d8e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 2 deletions

View file

@ -1,5 +1,4 @@
.mapMapWrapper {
background-color: $euiColorEmptyShade;
position: relative;
}

View file

@ -14,6 +14,7 @@ import {
areLayersLoaded,
getRefreshConfig,
getMapInitError,
getMapSettings,
getQueryableUniqueIndexPatternIds,
isToolbarOverlayHidden,
} from '../../selectors/map_selectors';
@ -29,6 +30,7 @@ function mapStateToProps(state: MapStoreState) {
mapInitError: getMapInitError(state),
indexPatternIds: getQueryableUniqueIndexPatternIds(state),
hideToolbarOverlay: isToolbarOverlayHidden(state),
backgroundColor: getMapSettings(state).backgroundColor,
};
}

View file

@ -37,6 +37,7 @@ const RENDER_COMPLETE_EVENT = 'renderComplete';
interface Props {
addFilters: ((filters: Filter[]) => Promise<void>) | null;
backgroundColor: string;
getFilterActions?: () => Promise<Action[]>;
getActionContext?: () => ActionExecutionContext;
areLayersLoaded: boolean;
@ -241,7 +242,10 @@ export class MapContainer extends Component<Props, State> {
data-title={this.props.title}
data-description={this.props.description}
>
<EuiFlexItem className="mapMapWrapper">
<EuiFlexItem
className="mapMapWrapper"
style={{ backgroundColor: this.props.backgroundColor }}
>
<MBMap
addFilters={addFilters}
getFilterActions={getFilterActions}

View file

@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { EuiFormRow, EuiPanel, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { MapSettings } from '../../reducers/map';
import { MbValidatedColorPicker } from '../../classes/styles/vector/components/color/mb_validated_color_picker';
interface Props {
settings: MapSettings;
updateMapSetting: (settingKey: string, settingValue: string | number | boolean) => void;
}
export function MapChromePanel({ settings, updateMapSetting }: Props) {
const onBackgroundColorChange = (color: string) => {
updateMapSetting('backgroundColor', color);
};
return (
<EuiPanel>
<EuiTitle size="xs">
<h5>
<FormattedMessage id="xpack.maps.mapSettingsPanel.mapTitle" defaultMessage="Map" />
</h5>
</EuiTitle>
<EuiFormRow
label={i18n.translate('xpack.maps.mapSettingsPanel.backgroundColorLabel', {
defaultMessage: 'Background color',
})}
display="columnCompressed"
>
<MbValidatedColorPicker
color={settings.backgroundColor}
onChange={onBackgroundColorChange}
/>
</EuiFormRow>
</EuiPanel>
);
}

View file

@ -20,6 +20,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { MapSettings } from '../../reducers/map';
import { NavigationPanel } from './navigation_panel';
import { SpatialFiltersPanel } from './spatial_filters_panel';
import { MapChromePanel } from './map_chrome_panel';
import { MapCenter } from '../../../common/descriptor_types';
interface Props {
@ -65,6 +66,8 @@ export function MapSettingsPanel({
<div className="mapLayerPanel__body">
<div className="mapLayerPanel__bodyOverflow">
<MapChromePanel settings={settings} updateMapSetting={updateMapSetting} />
<EuiSpacer size="s" />
<NavigationPanel
center={center}
settings={settings}

View file

@ -4,12 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { euiThemeVars } from '@kbn/ui-shared-deps/theme';
import { INITIAL_LOCATION, MAX_ZOOM, MIN_ZOOM } from '../../common/constants';
import { MapSettings } from './map';
export function getDefaultMapSettings(): MapSettings {
return {
autoFitToDataBounds: false,
backgroundColor: euiThemeVars.euiColorEmptyShade,
initialLocation: INITIAL_LOCATION.LAST_SAVED_LOCATION,
fixedLocation: { lat: 0, lon: 0, zoom: 2 },
browserLocation: { zoom: 2 },

View file

@ -43,6 +43,7 @@ export type MapContext = {
export type MapSettings = {
autoFitToDataBounds: boolean;
backgroundColor: string;
initialLocation: INITIAL_LOCATION;
fixedLocation: {
lat: number;