Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Chore] support offset in map legend panel (#2130)
Igor Dykhta28c34901a2bd
diff --git a/src/components/src/bottom-widget.tsx b/src/components/src/bottom-widget.tsxindex a5a35e7b9..c019ce577 100644--- a/src/components/src/bottom-widget.tsx+++ b/src/components/src/bottom-widget.tsx@@ -19,9 +19,9 @@// THE SOFTWARE.import React, {forwardRef, useMemo, useCallback} from 'react';-import styled from 'styled-components';+import styled, {withTheme} from 'styled-components';-import {DIMENSIONS, FILTER_VIEW_TYPES} from '@kepler.gl/constants';+import {FILTER_VIEW_TYPES} from '@kepler.gl/constants';import {hasPortableWidth, isSideFilter} from '@kepler.gl/utils';import {media, breakPointValues} from '@kepler.gl/styles';import {TimeRangeFilter} from '@kepler.gl/types';@@ -56,10 +56,14 @@ const BottomWidgetContainer = styled.div<BottomWidgetContainerProps>`${media.portable`padding: 0;`}`;-type BottomWidgetProps = {+export type BottomWidgetProps = {rootRef: React.ForwardedRef<HTMLDivElement>;containerW: number;} & ReturnType<typeof bottomWidgetSelector>;+type ThemeProp = {+ theme: Record<string, any>;+};+type BottomWidgetThemedProps = BottomWidgetProps & ThemeProp;BottomWidgetFactory.deps = [TimeWidgetFactory,@@ -74,12 +78,12 @@ export default function BottomWidgetFactory(AnimationControl: ReturnType<typeof AnimationControlFactory>,FilterAnimationController: ReturnType<typeof FilterAnimationControllerFactory>,LayerAnimationController: ReturnType<typeof LayerAnimationControllerFactory>-): React.FC<BottomWidgetProps> {+): React.FC<BottomWidgetThemedProps> {const LayerAnimationControl = styled(AnimationControl)`background-color: ${props => props.theme.sidePanelBg};`;- const BottomWidget: React.FC<BottomWidgetProps> = (props: BottomWidgetProps) => {+ const BottomWidget: React.FC<BottomWidgetThemedProps> = (props: BottomWidgetThemedProps) => {const {datasets,filters,@@ -89,7 +93,8 @@ export default function BottomWidgetFactory(uiState,sidePanelWidth,layers,- rootRef+ rootRef,+ theme} = props;const {activeSidePanel, readOnly} = uiState;@@ -105,7 +110,9 @@ export default function BottomWidgetFactory(const isLegendPinned =uiState.mapControls?.mapLegend?.show && uiState.mapControls?.mapLegend?.active;const spaceForLegendWidth = isLegendPinned- ? DIMENSIONS.mapControl.width + DIMENSIONS.mapControl.mapLegend.pinned.right+ ? theme.mapControl?.width ++ theme.mapControl?.mapLegend?.pinned?.right * 2 -+ theme.bottomWidgetPaddingRight: 0;const enlargedFilterWidth =@@ -196,8 +203,10 @@ export default function BottomWidgetFactory(};/* eslint-disable react/display-name */- // @ts-ignore- return forwardRef((props: BottomWidgetProps, ref) => <BottomWidget {...props} rootRef={ref} />);+ return withTheme(+ // @ts-ignore+ forwardRef((props: BottomWidgetThemedProps, ref) => <BottomWidget {...props} rootRef={ref} />)+ );/* eslint-enable react/display-name */}/* eslint-enable complexity */diff --git a/src/components/src/kepler-gl.tsx b/src/components/src/kepler-gl.tsxindex a2513c214..d2a5834a2 100644--- a/src/components/src/kepler-gl.tsx+++ b/src/components/src/kepler-gl.tsx@@ -491,6 +491,7 @@ function KeplerGlFactory(rootRef={this.bottomWidgetRef}{...bottomWidgetFields}containerW={dimensions.width}+ theme={theme}/></BottomWidgetOuter><ModalContainerdiff --git a/src/components/src/map/map-control-panel.tsx b/src/components/src/map/map-control-panel.tsxindex df988e62d..d25a0fb8c 100644--- a/src/components/src/map/map-control-panel.tsx+++ b/src/components/src/map/map-control-panel.tsx@@ -40,7 +40,7 @@ const StyledMapControlPanelContent = styled.div.attrs({max-height: 500px;min-height: 100px;min-width: ${props => props.theme.mapControl.width}px;- overflow: auto;+ overflow: overlay;`;const StyledMapControlPanelHeader = styled.div.attrs({diff --git a/src/components/src/map/map-legend-panel.tsx b/src/components/src/map/map-legend-panel.tsxindex fe90bdf14..81380af32 100644--- a/src/components/src/map/map-legend-panel.tsx+++ b/src/components/src/map/map-legend-panel.tsx@@ -35,10 +35,14 @@ import {media} from '@kepler.gl/styles';MapLegendPanelFactory.deps = [MapControlTooltipFactory, MapControlPanelFactory, MapLegendFactory];-const PinToBottom = styled.div`+interface PinToBottomProps {+ offsetRight?: number;+}++const PinToBottom = styled.div<PinToBottomProps>`position: absolute;bottom: ${DIMENSIONS.mapControl.mapLegend.pinned.bottom}px;- right: ${DIMENSIONS.mapControl.mapLegend.pinned.right}px;+ right: ${props => (props.offsetRight || 0) + DIMENSIONS.mapControl.mapLegend.pinned.right}px;${media.portable`bottom: 0px;right: 0px;@@ -63,6 +67,7 @@ export type MapLegendPanelProps = {actionIcons: MapLegendPanelIcons;mapControls: MapControls;mapHeight?: number;+ offsetRight?: number;};function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {@@ -79,7 +84,8 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {isExport,logoComponent,actionIcons = defaultActionIcons,- mapHeight+ mapHeight,+ offsetRight}) => {const mapLegend = mapControls?.mapLegend || ({} as MapControl);const {active: isPinned} = mapLegend || {};@@ -134,7 +140,7 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {if (isExport) {return mapControlPanel;}- const pinnedPanel = <PinToBottom>{mapControlPanel}</PinToBottom>;+ const pinnedPanel = <PinToBottom offsetRight={offsetRight}>{mapControlPanel}</PinToBottom>;return createPortal(pinnedPanel, document.body);}