Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed maps tooltip display at dark mode #564

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading