-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "add layer" UI component (#51) Signed-off-by: Junqiu Lei <[email protected]>
- Loading branch information
1 parent
97b9b3a
commit 74f01cb
Showing
6 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.addLayer__button { | ||
padding: $euiSizeM $euiSizeM | ||
} |
94 changes: 94 additions & 0 deletions
94
src/plugins/maps_dashboards/public/components/add_layer_panel/add_layer_panel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<EuiFlexItem key={index}> | ||
<EuiKeyPadMenuItem label={`${layerItem}`} aria-label={`${layerItem}`}> | ||
<EuiIcon type="visMapRegion" size="xxl" color="primary" /> | ||
</EuiKeyPadMenuItem> | ||
</EuiFlexItem> | ||
); | ||
}); | ||
|
||
const [isModalVisible, setIsModalVisible] = useState(false); | ||
|
||
const closeModal = () => setIsModalVisible(false); | ||
const showModal = () => setIsModalVisible(true); | ||
|
||
const tabs = [ | ||
{ | ||
id: 'select-layer-id', | ||
name: 'Select layer', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiFlexGroup gutterSize="l">{selectLayers}</EuiFlexGroup> | ||
</Fragment> | ||
), | ||
}, | ||
{ | ||
id: 'import-id', | ||
name: 'Import', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle> | ||
<h3>Import GeoJSON or JSON</h3> | ||
</EuiTitle> | ||
</Fragment> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<div className="addLayer"> | ||
<EuiFlexItem className="addLayer__button"> | ||
<EuiButton size="s" fill onClick={showModal} aria-label="Add layer"> | ||
+ Add layer | ||
</EuiButton> | ||
</EuiFlexItem> | ||
{isModalVisible && ( | ||
<EuiModal onClose={closeModal}> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
<h1>Add layer</h1> | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
|
||
<EuiModalBody> | ||
<EuiTabbedContent | ||
tabs={tabs} | ||
initialSelectedTab={tabs[0]} | ||
autoFocus="selected" | ||
aria-label="Add layer tabs" | ||
/> | ||
</EuiModalBody> | ||
</EuiModal> | ||
)} | ||
</div> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
src/plugins/maps_dashboards/public/components/add_layer_panel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { AddLayerPanel } from './add_layer_panel'; |
15 changes: 11 additions & 4 deletions
15
src/plugins/maps_dashboards/public/components/layer_control_panel/layer_control_panel.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters