From 74f01cb919eba002f3376a5b2923e010cbced676 Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Sun, 25 Sep 2022 17:25:55 -0500 Subject: [PATCH] add "add layer" UI component (#51) add "add layer" UI component (#51) Signed-off-by: Junqiu Lei --- .../add_layer_panel/add_layer_panel.scss | 3 + .../add_layer_panel/add_layer_panel.tsx | 94 +++++++++++++++++++ .../components/add_layer_panel/index.ts | 6 ++ .../layer_control_panel.scss | 15 ++- .../layer_control_panel.tsx | 88 ++++++++++++++--- src/plugins/maps_dashboards/public/index.scss | 10 +- 6 files changed, 191 insertions(+), 25 deletions(-) create mode 100644 src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.scss create mode 100644 src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.tsx create mode 100644 src/plugins/maps_dashboards/public/components/add_layer_panel/index.ts diff --git a/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.scss b/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.scss new file mode 100644 index 00000000..81f40a8e --- /dev/null +++ b/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.scss @@ -0,0 +1,3 @@ +.addLayer__button { + padding: $euiSizeM $euiSizeM +} diff --git a/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.tsx b/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.tsx new file mode 100644 index 00000000..cef14c55 --- /dev/null +++ b/src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.tsx @@ -0,0 +1,94 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { Fragment, useState } from 'react'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiModal, + EuiModalBody, + EuiModalHeader, + EuiModalHeaderTitle, + EuiSpacer, + EuiTabbedContent, + EuiTitle, + EuiButton, + EuiIcon, + EuiKeyPadMenuItem, +} from '@elastic/eui'; +import './add_layer_panel.scss'; + +export const AddLayerPanel = () => { + // TODO: replace it once layers model ready + const layers = ['Base maps', 'Region', 'Coordinate', 'WMS']; + + const selectLayers = layers.map((layerItem, index) => { + return ( + + + + + + ); + }); + + const [isModalVisible, setIsModalVisible] = useState(false); + + const closeModal = () => setIsModalVisible(false); + const showModal = () => setIsModalVisible(true); + + const tabs = [ + { + id: 'select-layer-id', + name: 'Select layer', + content: ( + + + {selectLayers} + + ), + }, + { + id: 'import-id', + name: 'Import', + content: ( + + + +

Import GeoJSON or JSON

+
+
+ ), + }, + ]; + + return ( +
+ + + + Add layer + + + {isModalVisible && ( + + + +

Add layer

+
+
+ + + + +
+ )} +
+ ); +}; diff --git a/src/plugins/maps_dashboards/public/components/add_layer_panel/index.ts b/src/plugins/maps_dashboards/public/components/add_layer_panel/index.ts new file mode 100644 index 00000000..d892657c --- /dev/null +++ b/src/plugins/maps_dashboards/public/components/add_layer_panel/index.ts @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { AddLayerPanel } from './add_layer_panel'; diff --git a/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.scss b/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.scss index d31ca335..94080b2c 100644 --- a/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.scss +++ b/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.scss @@ -1,7 +1,14 @@ -.maplibre-control-layer { - min-width: 15rem; +.layerControlPanel { + pointer-events: auto; - .maplibre-control-layer-title { - padding-left: 0.5rem; + width: $euiSizeL * 10; + + .layerControlPanel__title { + padding: $euiSizeM $euiSizeM + } + + .layerControlPanel__layerFunctionButton { + height: $euiSizeL; + width: $euiSizeL; } } diff --git a/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.tsx b/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.tsx index 164cb296..1fa34746 100644 --- a/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.tsx +++ b/src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.tsx @@ -4,25 +4,85 @@ */ import React from 'react'; -import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui'; -import { FormattedMessage, I18nProvider } from '@osd/i18n/react'; +import { + EuiPanel, + EuiTitle, + EuiFlexGroup, + EuiFlexItem, + EuiListGroupItem, + EuiButtonEmpty, + EuiHorizontalRule, +} from '@elastic/eui'; +import { I18nProvider } from '@osd/i18n/react'; import './layer_control_panel.scss'; +import { AddLayerPanel } from '../add_layer_panel'; const LayerControlPanel = () => { + // TODO: replace it once layers model ready + const demoLayers = [ + { + label: 'Base Map', + iconType: 'visMapRegion', + }, + { + label: 'GeoJson Layer', + iconType: 'visMapRegion', + }, + ]; + return ( - - -

- -

-
- -
Roadmap
- + + + + +

Map Layers

+
+
+ + {demoLayers.map((layer) => ( +
+ + + + + + + window.alert('Hidden button clicked')} + aria-label="Hide or show layer" + color="text" + /> + + + window.alert('Delete button clicked')} + aria-label="Delete layer" + color="text" + /> + + + + +
+ ))} + +
); diff --git a/src/plugins/maps_dashboards/public/index.scss b/src/plugins/maps_dashboards/public/index.scss index d4c6d87c..4288e690 100644 --- a/src/plugins/maps_dashboards/public/index.scss +++ b/src/plugins/maps_dashboards/public/index.scss @@ -11,11 +11,7 @@ min-height: calc(100vh - 98px); } -.mapboxgl-ctrl-top-left, .maplibregl-ctrl-top-left { - left: 10px; - top: 10px; -} - -.maplibre-control-layer{ - pointer-events: auto; +.maplibregl-ctrl-top-left { + left: $euiSizeS; + top: $euiSizeS; }