Skip to content

Commit

Permalink
Fixed maps tooltip display when at dark mode (#564) (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
opensearch-trigger-bot[bot] committed Dec 1, 2023
1 parent 4b36fb5 commit c091de5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Features
### Enhancements
### Bug Fixes
* Fixed maps tooltip display at dark mode[#564](https://github.com/opensearch-project/dashboards-maps/pull/564)
### Infrastructure
### Documentation
### Maintenance
Expand Down
35 changes: 35 additions & 0 deletions public/components/tooltip/create_tooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

.mapTooltip {
div.maplibregl-popup-content.mapboxgl-popup-content {
padding: 0;
background: none;
}
}

.maplibregl-popup-anchor-top {
.maplibregl-popup-tip {
border-bottom-color:lightOrDarkTheme($ouiColorEmptyShade, $ouiColorLightestShade) !important;
}
}

.maplibregl-popup-anchor-bottom {
.maplibregl-popup-tip {
border-top-color:lightOrDarkTheme($ouiColorEmptyShade, $ouiColorLightestShade) !important;
}
}

.maplibregl-popup-anchor-left {
.maplibregl-popup-tip {
border-right-color:lightOrDarkTheme($ouiColorEmptyShade, $ouiColorLightestShade) !important;
}
}

.maplibregl-popup-anchor-right {
.maplibregl-popup-tip {
border-left-color:lightOrDarkTheme($ouiColorEmptyShade, $ouiColorLightestShade) !important;
}
}
2 changes: 2 additions & 0 deletions public/components/tooltip/create_tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Popup, MapGeoJSONFeature, LngLat } from 'maplibre-gl';
import { MapLayerSpecification, DocumentLayerSpecification } from '../../model/mapLayerType';
import { FeatureGroupItem, TooltipContainer } from './tooltipContainer';
import { MAX_LONGITUDE } from '../../../common';
import './create_tooltip.scss';

interface Options {
features: MapGeoJSONFeature[];
Expand Down Expand Up @@ -76,6 +77,7 @@ export function createPopup({
closeButton: false,
closeOnClick: false,
maxWidth: 'max-content',
className: 'mapTooltip',
});

const featureGroup = groupFeaturesByLayers(features, layers);
Expand Down
15 changes: 9 additions & 6 deletions public/components/tooltip/tooltipTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import {
} from '@elastic/eui';
import React, { useState, Fragment, useCallback, useEffect, useMemo } from 'react';

export type RowData = {
export interface RowData {
key: string;
value: string;
};
}
export type PageData = RowData[];
export type TableData = PageData[];
type Table = { table: TableData; layer: string };
interface Table {
table: TableData;
layer: string;
}

export const ALL_LAYERS = -1;

Expand Down Expand Up @@ -66,7 +69,7 @@ const TooltipTable = ({
showPagination = true,
showLayerSelection = true,
}: Props) => {
const [selectedLayers, setSelectedLayers] = useState<EuiComboBoxOptionOption<number>[]>([
const [selectedLayers, setSelectedLayers] = useState<Array<EuiComboBoxOptionOption<number>>>([
{
label: tables[0]?.layer ?? '',
value: 0,
Expand Down Expand Up @@ -103,7 +106,7 @@ const TooltipTable = ({
};

const handleLayerChange = useCallback(
(layerSelections: EuiComboBoxOptionOption<number>[]) => {
(layerSelections: Array<EuiComboBoxOptionOption<number>>) => {
if (tables.length === 0) {
return;
}
Expand Down Expand Up @@ -152,7 +155,7 @@ const TooltipTable = ({
return (
<Fragment>
<EuiFlexGroup responsive={false}>
<EuiFlexItem style={{ overflow: 'scroll', maxHeight: 300 }}>
<EuiFlexItem style={{ overflow: 'auto', maxHeight: 300 }}>
<EuiBasicTable
isSelectable={false}
items={pageItems}
Expand Down

0 comments on commit c091de5

Please sign in to comment.