Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Chore] Fix more style components warnings (#3047)

Shan He864dbe5c6410
diff --git a/examples/demo-app/src/cloud-providers/foursquare/foursquare-provider.js b/examples/demo-app/src/cloud-providers/foursquare/foursquare-provider.js
index e62a314e2..58b62401c 100644
--- a/examples/demo-app/src/cloud-providers/foursquare/foursquare-provider.js
+++ b/examples/demo-app/src/cloud-providers/foursquare/foursquare-provider.js
@@ -113,10 +113,10 @@ export default class FoursquareProvider extends Provider {
const {map, thumbnail} = mapData;
const {title = '', description = '', loadParams} = map.info;
-
+
const mapIdToOverwrite = options.mapIdToOverwrite || loadParams?.id;
- if(options.overwrite && !mapIdToOverwrite){
- throw new Error("Foursquare storage provider: no map id to overwrite");
+ if (options.overwrite && !mapIdToOverwrite) {
+ throw new Error('Foursquare storage provider: no map id to overwrite');
}
const headers = await this.getHeaders();
@@ -129,12 +129,10 @@ export default class FoursquareProvider extends Provider {
}
};
-
-
// To overwrite map.latestState we have to fetch the map first
- if(options.overwrite){
+ if (options.overwrite) {
const response = await fetch(`${this.apiURL}/v1/maps/${mapIdToOverwrite}`, {
- method: "GET",
+ method: 'GET',
headers
});
@@ -154,16 +152,16 @@ export default class FoursquareProvider extends Provider {
const createdMap = await mapResponse.json();
- if(!options.overwrite){
- await fetch(`${this.apiURL}/v1/maps/${createdMap.id}/thumbnail`, {
- method: 'PUT',
- headers: {
- ...headers,
- 'Content-Type': 'image/png'
- },
- body: thumbnail
- });
- }
+ if (!options.overwrite) {
+ await fetch(`${this.apiURL}/v1/maps/${createdMap.id}/thumbnail`, {
+ method: 'PUT',
+ headers: {
+ ...headers,
+ 'Content-Type': 'image/png'
+ },
+ body: thumbnail
+ });
+ }
// pass through fsq map id
const newMapData = extractMapFromFSQResponse(createdMap);
diff --git a/package.json b/package.json
index 74f2de24f..82dd2c689 100644
--- a/package.json
+++ b/package.json
@@ -85,7 +85,7 @@
"docs": "babel-node ./scripts/documentation.js",
"typedoc": "typedoc --theme markdown --out typedoc --inputFiles ./src/reducers --inputFiles ./src/actions --excludeExternals --excludeNotExported --excludePrivate",
"example-version": "babel-node ./scripts/edit-version.js",
- "prettier-all": "prettier --write '{src,examples,test}/**/*.{js,tsx,ts}'",
+ "prettier-all": "prettier --write '{examples,src}/**/src/**/*.{js,tsx,ts}' 'test/**/*.{js,ts,tsx}'",
"lint": "yarn typescript && eslint src test webpack examples website --fix --ignore-path .gitignore",
"lint:css": "stylelint './src/**/*.js'",
"typescript": "tsc --noEmit",
diff --git a/src/components/src/common/checkbox.tsx b/src/components/src/common/checkbox.tsx
index f071ef10b..fcfa00c27 100644
--- a/src/components/src/common/checkbox.tsx
+++ b/src/components/src/common/checkbox.tsx
@@ -5,6 +5,7 @@ import classnames from 'classnames';
import pick from 'lodash.pick';
import React, {ChangeEventHandler, Component, FocusEventHandler, ReactNode} from 'react';
import styled from 'styled-components';
+import {shouldForwardProp} from './styled-components';
function noop() {
return;
@@ -14,7 +15,7 @@ interface StyledSwitchInputProps {
secondary?: boolean;
}
-const StyledSwitchInput = styled.label<StyledSwitchInputProps>`
+const StyledSwitchInput = styled.label.withConfig({shouldForwardProp})<StyledSwitchInputProps>`
${props => (props.secondary ? props.theme.secondarySwitch : props.theme.inputSwitch)};
`;
@@ -22,11 +23,11 @@ const StyledCheckboxInput = styled.label`
${props => props.theme.inputCheckbox};
`;
-const StyledRadiuInput = styled.label<StyledSwitchInputProps>`
+const StyledRadiuInput = styled.label.withConfig({shouldForwardProp})<StyledSwitchInputProps>`
${props => (props.secondary ? props.theme.secondaryRadio : props.theme.inputRadio)};
`;
-const HiddenInput = styled.input`
+const HiddenInput = styled.input.withConfig({shouldForwardProp})`
position: absolute;
opacity: 0;
`;
@@ -36,7 +37,7 @@ interface StyledCheckboxProps {
disabled?: boolean;
}
-const StyledCheckbox = styled.div<StyledCheckboxProps>`
+const StyledCheckbox = styled.div.withConfig({shouldForwardProp})<StyledCheckboxProps>`
display: flex;
min-height: ${props => props.theme.switchHeight}px;
margin-left: ${props => (props.type === 'radio' ? 0 : props.theme.switchLabelMargin)}px;
diff --git a/src/components/src/common/histogram-plot.tsx b/src/components/src/common/histogram-plot.tsx
index df671f920..5e8f3fd33 100644
--- a/src/components/src/common/histogram-plot.tsx
+++ b/src/components/src/common/histogram-plot.tsx
@@ -38,17 +38,18 @@ const HistogramBreakLine = styled.g`
`;
type BarType = {
- inRange: boolean;
- isOverlay: boolean;
+ $inRange: boolean;
+ $isOverlay: boolean;
+ $color?: string;
};
const BarUnmemoized = styled.rect<BarType>(
- ({theme, inRange, isOverlay, color}) => `
+ ({theme, $inRange, $isOverlay, $color}) => `
${
- isOverlay
- ? `fill: ${color ?? theme.histogramOverlayColor};`
- : inRange
- ? `fill: ${color ?? theme.histogramFillInRange};`
- : `fill: ${color ? hcl(color).darker() : theme.histogramFillOutRange};`
+ $isOverlay
+ ? `fill: ${$color ?? theme.histogramOverlayColor};`
+ : $inRange
+ ? `fill: ${$color ?? theme.histogramFillInRange};`
+ : `fill: ${$color ? hcl($color).darker() : theme.histogramFillOutRange};`
}
`
);
@@ -194,9 +195,9 @@ function HistogramPlotFactory() {
: histogramStyle.unHighlightedW;
return (
<Bar
- isOverlay={false}
- inRange={inRange}
- color={HISTOGRAM_MASK_FGCOLOR}
+ $isOverlay={false}
+ $inRange={inRange}
+ $color={HISTOGRAM_MASK_FGCOLOR}
key={`mask-${idx}`}
height={y(bar[countProp])}
width={barWidth * wRatio}
@@ -228,8 +229,8 @@ function HistogramPlotFactory() {
const wRatio = inRange ? histogramStyle.highlightW : histogramStyle.unHighlightedW;
return (
<Bar
- inRange={inRange}
- isOverlay={true}
+ $inRange={inRange}
+ $isOverlay={true}
key={`bar-${idx}`}
height={maskHeight}
width={barWidth * wRatio}
@@ -272,9 +273,9 @@ function HistogramPlotFactory() {
if (startX > 0 && startX + barWidth * histogramStyle.unHighlightedW <= width) {
return (
<Bar
- isOverlay={false}
- inRange={inRange}
- color={colorsByGroup?.[key]}
+ $isOverlay={false}
+ $inRange={inRange}
+ $color={colorsByGroup?.[key]}
key={`bar-${idx}`}
height={y(bar[countProp])}
width={barWidth * wRatio}
diff --git a/src/components/src/common/icons/index.tsx b/src/components/src/common/icons/index.tsx
index 10d06e503..58539e8fc 100644
--- a/src/components/src/common/icons/index.tsx
+++ b/src/components/src/common/icons/index.tsx
@@ -4,7 +4,7 @@
export {default as Base} from './base';
// eslint-disable-next-line prettier/prettier
-export type {BaseProps} from './base'
+export type {BaseProps} from './base';
export {default as Add} from './add';
export {default as AnchorWindow} from './anchor_window';
diff --git a/src/components/src/common/item-selector/chickleted-input.tsx b/src/components/src/common/item-selector/chickleted-input.tsx
index c22e7eecc..7c4f8c647 100644
--- a/src/components/src/common/item-selector/chickleted-input.tsx
+++ b/src/components/src/common/item-selector/chickleted-input.tsx
@@ -11,6 +11,7 @@ import {restrictToParentElement} from '@dnd-kit/modifiers';
import Delete from '../icons/delete';
import {FormattedMessage} from '@kepler.gl/localization';
import {BaseComponentProps} from '../../types';
+import {shouldForwardProp} from '../styled-components';
export type ChickletButtonProps = BaseComponentProps & {
inputTheme?: string;
@@ -77,7 +78,7 @@ export type ChickletedInputContainerProps = BaseComponentProps & {
const ChickletedInputContainer: IStyledComponent<
'web',
ChickletedInputContainerProps
-> = styled.div<ChickletedInputContainerProps>`
+> = styled.div.withConfig({shouldForwardProp})<ChickletedInputContainerProps>`
${props =>
props.inputTheme === 'secondary'
? props.theme.secondaryChickletedInput
diff --git a/src/components/src/common/item-selector/dropdown-list.tsx b/src/components/src/common/item-selector/dropdown-list.tsx
index 7dfc8a249..29b5e11cf 100644
--- a/src/components/src/common/item-selector/dropdown-list.tsx
+++ b/src/components/src/common/item-selector/dropdown-list.tsx
@@ -36,7 +36,7 @@ export const ListItem = ({value, displayOption = defaultDisplay, disabled}: List
};
export type DropdownListWrapperProps = BaseComponentProps & {
- light?: boolean;
+ $light?: boolean;
};
const DropdownListWrapper: IStyledComponent<
@@ -44,11 +44,11 @@ const DropdownListWrapper: IStyledComponent<
DropdownListWrapperProps
> = styled.div<DropdownListWrapperProps>`
background-color: ${props =>
- props.light ? props.theme.dropdownListBgdLT : props.theme.dropdownListBgd};
+ props.$light ? props.theme.dropdownListBgdLT : props.theme.dropdownListBgd};
border-top: 1px solid
${props =>
- props.light ? props.theme.dropdownListBorderTopLT : props.theme.dropdownListBorderTop};
- ${props => (props.light ? props.theme.dropdownListLT : props.theme.dropdownList)};
+ props.$light ? props.theme.dropdownListBorderTopLT : props.theme.dropdownListBorderTop};
+ ${props => (props.$light ? props.theme.dropdownListLT : props.theme.dropdownList)};
`;
const DropdownFooterWrapper = styled.div`
@@ -212,7 +212,7 @@ export default class DropdownList extends Component<DropdownListProps, DropdownL
return (
<DropdownListWrapper
className={classNames(classList.list, this.props.customClasses?.results)}
- light={light}
+ $light={light}
>
{this.props.customListHeaderComponent ? (
<div className={classNames(classList.listHeader, this.props.customClasses?.listHeader)}>
diff --git a/src/components/src/common/item-selector/dropdown-select.tsx b/src/components/src/common/item-selector/dropdown-select.tsx
index c051c8a3e..0c34e8e30 100644
--- a/src/components/src/common/item-selector/dropdown-select.tsx
+++ b/src/components/src/common/item-selector/dropdown-select.tsx
@@ -9,6 +9,7 @@ import {FormattedMessage} from '@kepler.gl/localization';
import {ArrowDown, Delete} from '../icons';
import {ListItem} from './dropdown-list';
+import {shouldForwardProp} from '../styled-components';
export type ListItemProps<Option> = {
value: Option;
@@ -34,9 +35,11 @@ export type DropdownSelectProps<Option> = {
DropDownLineItemRenderComponent?: ComponentType<ListItemProps<Option>>;
};
-export const StyledDropdownSelect = styled.div.attrs<{className?: string}>({
- className: 'item-selector__dropdown'
-})<{
+export const StyledDropdownSelect = styled.div
+ .withConfig({shouldForwardProp})
+ .attrs<{className?: string}>({
+ className: 'item-selector__dropdown'
+ })<{
size: DropdownSelectProps<any>['size'];
inputTheme: DropdownSelectProps<any>['inputTheme'];
}>`
@@ -55,7 +58,7 @@ export const StyledDropdownSelect = styled.div.attrs<{className?: string}>({
}
`;
-export const DropdownSelectValue = styled.span<{
+export const DropdownSelectValue = styled.span.withConfig({shouldForwardProp})<{
inputTheme: DropdownSelectProps<any>['inputTheme'];
hasPlaceholder: boolean;
}>`
diff --git a/src/components/src/common/item-selector/item-selector.tsx b/src/components/src/common/item-selector/item-selector.tsx
index dd62d5213..c6d9ebaea 100644
--- a/src/components/src/common/item-selector/item-selector.tsx
+++ b/src/components/src/common/item-selector/item-selector.tsx
@@ -16,16 +16,16 @@ import {toArray} from '@kepler.gl/common-utils';
import {injectIntl, IntlShape} from 'react-intl';
import {ListItemProps} from './dropdown-select';
import DropdownSelect from './dropdown-select';
+import {shouldForwardProp} from '../styled-components';
export type DropdownWrapperProps = {
placement?: string;
width: number;
};
-const DropdownWrapper: IStyledComponent<
- 'web',
- DropdownWrapperProps
-> = styled.div<DropdownWrapperProps>`
+const DropdownWrapper: IStyledComponent<'web', DropdownWrapperProps> = styled.div.withConfig({
+ shouldForwardProp
+})<DropdownWrapperProps>`
border: 0;
width: 100%;
left: 0;
diff --git a/src/components/src/common/item-selector/typeahead.tsx b/src/components/src/common/item-selector/typeahead.tsx
index 4aacb7f5b..a9d666219 100644
--- a/src/components/src/common/item-selector/typeahead.tsx
+++ b/src/components/src/common/item-selector/typeahead.tsx
@@ -13,7 +13,7 @@ import DropdownList, {ListItem} from './dropdown-list';
import {Search} from '../icons';
import {KeyEvent} from '@kepler.gl/constants';
import {BaseComponentProps} from '../../types';
-
+import {shouldForwardProp} from '../styled-components';
const DEFAULT_CLASS = 'typeahead';
/**
* Copied mostly from 'react-typeahead', an auto-completing text input
@@ -27,10 +27,9 @@ export type TypeaheadWrapperProps = BaseComponentProps & {
ref: React.RefObject<HTMLDivElement>;
};
-const TypeaheadWrapper: IStyledComponent<
- 'web',
- TypeaheadWrapperProps
-> = styled.div<TypeaheadWrapperProps>`
+const TypeaheadWrapper: IStyledComponent<'web', TypeaheadWrapperProps> = styled.div.withConfig({
+ shouldForwardProp
+})<TypeaheadWrapperProps>`
display: flex;
flex-direction: column;
background-color: ${props =>
@@ -57,10 +56,9 @@ export type TypeaheadInputProps = BaseComponentProps & {
placeholder?: string | undefined;
};
-const TypeaheadInput: IStyledComponent<
- 'web',
- TypeaheadInputProps
-> = styled.input<TypeaheadInputProps>`
+const TypeaheadInput: IStyledComponent<'web', TypeaheadInputProps> = styled.input.withConfig({
+ shouldForwardProp
+})<TypeaheadInputProps>`
${props => (props.light ? props.theme.inputLT : props.theme.secondaryInput)}
&:hover {
cursor: pointer;
diff --git a/src/components/src/common/range-brush.tsx b/src/components/src/common/range-brush.tsx
index f0e1a1084..897d6eb9b 100644
--- a/src/components/src/common/range-brush.tsx
+++ b/src/components/src/common/range-brush.tsx
@@ -8,14 +8,14 @@ import {BrushBehavior, brushX} from 'd3-brush';
import {normalizeSliderValue} from '@kepler.gl/utils';
interface StyledGProps {
- isRanged?: boolean;
+ $isRanged?: boolean;
}
const StyledG = styled.g<StyledGProps>`
.selection {
stroke: none;
- fill: ${props => (props.isRanged ? props.theme.rangeBrushBgd : props.theme.BLUE2)};
- fill-opacity: ${props => (props.isRanged ? 0.3 : 1)};
+ fill: ${props => (props.$isRanged ? props.theme.rangeBrushBgd : props.theme.BLUE2)};
+ fill-opacity: ${props => (props.$isRanged ? 0.3 : 1)};
}
.handle {
fill: ${props => props.theme.BLUE2};
@@ -156,7 +156,11 @@ function RangeBrushFactory(): React.ComponentType<RangeBrushProps> {
} = this.props;
const [prevVal0, prevVal1] = prevProps.value;
- if (prevProps.width !== width || prevProps.range[0] !== this.props.range[0] || prevProps.range[1] !== this.props.range[1]) {
+ if (
+ prevProps.width !== width ||
+ prevProps.range[0] !== this.props.range[0] ||
+ prevProps.range[1] !== this.props.range[1]
+ ) {
// dimension change should not trigger this._brushed
this.moving = true;
if (this.brush) this.root?.call(this.brush);
@@ -251,7 +255,7 @@ function RangeBrushFactory(): React.ComponentType<RangeBrushProps> {
render() {
const {isRanged} = this.props;
return (
- <StyledG className="kg-range-slider__brush" isRanged={isRanged} ref={this.rootContainer} />
+ <StyledG className="kg-range-slider__brush" $isRanged={isRanged} ref={this.rootContainer} />
);
}
}
diff --git a/src/components/src/common/range-slider.tsx b/src/components/src/common/range-slider.tsx
index afbfbb4f5..0841f8b7b 100644
--- a/src/components/src/common/range-slider.tsx
+++ b/src/components/src/common/range-slider.tsx
@@ -21,28 +21,28 @@ import {Datasets} from '@kepler.gl/table';
import {ActionHandler, setFilterPlot} from '@kepler.gl/actions';
interface SliderInputProps {
- flush?: boolean;
- inputSize?: string;
+ $flush?: boolean;
+ $inputSize?: string;
}
const noop = () => {
return;
};
const SliderInput = styled(Input)<SliderInputProps>`
width: ${props => props.theme.sliderInputWidth}px;
- margin-left: ${props => (props.flush ? 0 : props.inputSize === 'tiny' ? 12 : 18)}px;
+ margin-left: ${props => (props.$flush ? 0 : props.$inputSize === 'tiny' ? 12 : 18)}px;
font-size: ${props => props.theme.sliderInputFontSize}; // 10px // 12px;
padding: ${props => props.theme.sliderInputPadding}; // 4px 6px; // 6px 12px;
`;
interface SliderWrapperProps {
- isRanged?: boolean;
- showInput?: boolean;
+ $isRanged?: boolean;
+ $showInput?: boolean;
}
const SliderWrapper = styled.div<SliderWrapperProps>`
display: flex;
position: relative;
- align-items: ${props => (!props.isRanged && props.showInput ? 'center' : 'flex-start')};
+ align-items: ${props => (!props.$isRanged && props.$showInput ? 'center' : 'flex-start')};
`;
const RangeInputWrapper = styled.div`
@@ -215,8 +215,8 @@ export default function RangeSliderFactory(
}
}}
onBlur={update}
- flush={key === 'value0'}
- inputSize={this.props.inputSize}
+ $flush={key === 'value0'}
+ $inputSize={this.props.inputSize}
secondary={this.props.inputTheme === 'secondary'}
/>
);
@@ -296,8 +296,8 @@ export default function RangeSliderFactory(
) : null}
<SliderWrapper
className="kg-range-slider__slider"
- isRanged={isRanged}
- showInput={showInput}
+ $isRanged={isRanged}
+ $showInput={showInput}
>
{this.props.xAxis ? (
<div style={{height: '30px'}}>
diff --git a/src/components/src/common/slider/slider-bar-handle.tsx b/src/components/src/common/slider/slider-bar-handle.tsx
index df5eff49d..1d3e301fe 100644
--- a/src/components/src/common/slider/slider-bar-handle.tsx
+++ b/src/components/src/common/slider/slider-bar-handle.tsx
@@ -9,15 +9,15 @@ import {StyleRangeSliderType} from './slider';
import {BaseComponentProps} from '../../types';
export type StyledSliderProps = BaseComponentProps & {
- active?: boolean;
- vertical?: boolean;
+ $active?: boolean;
+ $vertical?: boolean;
};
const StyledSlider: IStyledComponent<'web', StyledSliderProps> = styled.div<StyledSliderProps>`
position: relative;
background-color: ${props =>
- props.active ? props.theme.sliderBarHoverColor : props.theme.sliderBarColor};
- ${props => `${props.vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};
+ props.$active ? props.theme.sliderBarHoverColor : props.theme.sliderBarColor};
+ ${props => `${props.$vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};
border-radius: ${props => props.theme.sliderBarRadius};
&:hover {
cursor: pointer;
@@ -79,7 +79,7 @@ export default class SliderBarHandle extends Component {
return (
<StyledSlider
- active={this.state.mouseOver}
+ $active={this.state.mouseOver}
className={classnames('kg-range-slider__bar', {
'kg-range-slider__bar--active': this.state.mouseOver
})}
diff --git a/src/components/src/common/slider/slider-handle.tsx b/src/components/src/common/slider/slider-handle.tsx
index 4e6b2b9be..e87b367bd 100644
--- a/src/components/src/common/slider/slider-handle.tsx
+++ b/src/components/src/common/slider/slider-handle.tsx
@@ -9,8 +9,8 @@ import {StyleRangeSliderType} from './slider';
import {BaseComponentProps} from '../../types';
export type StyledSliderHandleProps = StyledSliderTooltipProps & {
- vertical?: boolean;
- active?: boolean;
+ $vertical?: boolean;
+ $active?: boolean;
ref: RefObject<Element>;
};
@@ -21,16 +21,16 @@ const StyledSliderHandle: IStyledComponent<'web', StyledSliderHandleProps> = sty
)<StyledSliderHandleProps>`
position: absolute;
z-index: 10;
- ${props => (props.vertical ? 'margin-left' : 'margin-top')}: -${props =>
- (props.sliderHandleWidth - props.theme.sliderBarHeight) / 2}px;
+ ${props => (props.$vertical ? 'margin-left' : 'margin-top')}: -${props =>
+ (props.$sliderHandleWidth - props.theme.sliderBarHeight) / 2}px;
height: ${props =>
- Number.isFinite(props.sliderHandleWidth)
- ? props.sliderHandleWidth
+ Number.isFinite(props.$sliderHandleWidth)
+ ? props.$sliderHandleWidth
: props.theme.sliderHandleHeight}px;
width: ${props =>
- Number.isFinite(props.sliderHandleWidth)
- ? props.sliderHandleWidth
+ Number.isFinite(props.$sliderHandleWidth)
+ ? props.$sliderHandleWidth
: props.theme.sliderHandleHeight}px;
box-shadow: ${props => props.theme.sliderHandleShadow};
background-color: ${props => props.theme.sliderHandleColor};
@@ -40,7 +40,7 @@ const StyledSliderHandle: IStyledComponent<'web', StyledSliderHandleProps> = sty
border-radius: ${props => props.theme.sliderBorderRadius};
border-style: solid;
border-color: ${props =>
- props.active ? props.theme.selectBorderColor : props.theme.sliderInactiveBorderColor};
+ props.$active ? props.theme.selectBorderColor : props.theme.sliderInactiveBorderColor};
&:hover {
background-color: ${props => props.theme.sliderHandleHoverColor};
@@ -57,7 +57,7 @@ const StyledSliderHandle: IStyledComponent<'web', StyledSliderHandleProps> = sty
`;
export type StyledSliderTooltipProps = BaseComponentProps & {
- sliderHandleWidth: number;
+ $sliderHandleWidth: number;
};
const StyledSliderTooltip: IStyledComponent<
@@ -70,7 +70,7 @@ const StyledSliderTooltip: IStyledComponent<
pointer-events: none;
transition: opacity 0.3s ease-out;
z-index: 999;
- margin-left: ${props => props.sliderHandleWidth + 12}px;
+ margin-left: ${props => props.$sliderHandleWidth + 12}px;
font-size: 9.5px;
font-weight: 500;
padding: 7px 10px;
@@ -120,7 +120,7 @@ const SliderTooltip = ({
sliderHandleWidth
}: SliderTooltipProps) => {
return (
- <StyledSliderTooltip sliderHandleWidth={sliderHandleWidth} style={style}>
+ <StyledSliderTooltip $sliderHandleWidth={sliderHandleWidth} style={style}>
{format(value)}
</StyledSliderTooltip>
);
@@ -186,9 +186,9 @@ export default class SliderHandle extends Component {
'kg-range-slider__handle--active': this.state.mouseOver
})}
ref={this.ref}
- sliderHandleWidth={this.props.sliderHandleWidth}
- active={this.state.mouseOver}
- vertical={this.props.vertical}
+ $sliderHandleWidth={this.props.sliderHandleWidth}
+ $active={this.state.mouseOver}
+ $vertical={this.props.vertical}
style={style}
onMouseDown={this.mouseEvent.handleMouseDown}
onTouchStart={this.mouseEvent.handleTouchStart}
diff --git a/src/components/src/common/slider/slider.tsx b/src/components/src/common/slider/slider.tsx
index 309d2d3ca..9d6b9894c 100644
--- a/src/components/src/common/slider/slider.tsx
+++ b/src/components/src/common/slider/slider.tsx
@@ -14,21 +14,21 @@ function noop() {
}
interface StyledRangeSliderProps {
- vertical?: boolean;
+ $vertical?: boolean;
}
const StyledRangeSlider = styled.div<StyledRangeSliderProps>`
position: relative;
background-color: ${props => props.theme.sliderBarBgd};
- ${props => `${props.vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};
- ${props => `${props.vertical ? 'height' : 'width'}: 100%`};
+ ${props => `${props.$vertical ? 'width' : 'height'}: ${props.theme.sliderBarHeight}px`};
+ ${props => `${props.$vertical ? 'height' : 'width'}: 100%`};
`;
export type StyleRangeSliderType = typeof StyledRangeSlider & HTMLDivElement;
interface SliderWrapperProps {
- isRanged?: boolean;
- vertical?: boolean;
+ $isRanged?: boolean;
+ $vertical?: boolean;
}
const SliderWrapper = styled.div<SliderWrapperProps>`
@@ -185,11 +185,11 @@ export default class Slider extends Component<SliderProps> {
<SliderWrapper
className={classnames('kg-slider', {...classSet, disabled}, className)}
ref={this.ref}
- isRanged={isRanged}
- vertical={vertical}
+ $isRanged={isRanged}
+ $vertical={vertical}
style={style}
>
- <StyledRangeSlider className="kg-range-slider" vertical={vertical} ref={this.track}>
+ <StyledRangeSlider className="kg-range-slider" $vertical={vertical} ref={this.track}>
<SliderHandle
left={this.calcHandleLeft0(width, v0Left)}
valueListener={this.slide0Listener}
diff --git a/src/components/src/common/styled-components.tsx b/src/components/src/common/styled-components.tsx
index 133a42820..28c0e74b1 100644
--- a/src/components/src/common/styled-components.tsx
+++ b/src/components/src/common/styled-components.tsx
@@ -8,9 +8,20 @@ import DatePicker from 'react-date-picker';
import TimePicker from 'react-time-picker';
import ReactTooltip, {TooltipProps} from 'react-tooltip';
import styled, {IStyledComponent} from 'styled-components';
+import isPropValid from '@emotion/is-prop-valid';
import {BaseComponentProps} from '../types';
+// This implements the default behavior from styled-components v5
+export function shouldForwardProp(propName, target) {
+ if (typeof target === 'string') {
+ // For HTML elements, forward the prop if it is a valid HTML attribute
+ return isPropValid(propName);
+ }
+ // For other elements, forward all props
+ return true;
+}
+
export const SelectText = styled.span`
color: ${props => props.theme.labelColor};
font-size: ${props => props.theme.selectFontSize};
@@ -209,7 +220,7 @@ export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
};
// this needs to be an actual button to be able to set disabled attribute correctly
-export const Button = styled.button.attrs(props => ({
+export const Button = styled.button.withConfig({shouldForwardProp}).attrs(props => ({
className: classnames('button', props.className)
}))<ButtonProps>`
align-items: center;
@@ -308,18 +319,18 @@ interface InputProps {
secondary?: boolean;
}
-export const Input = styled.input<InputProps>`
+export const Input = styled.input.withConfig({shouldForwardProp})<InputProps>`
${props => (props.secondary ? props.theme.secondaryInput : props.theme.input)};
`;
-export const InputLight = styled.input`
+export const InputLight = styled.input.withConfig({shouldForwardProp})`
${props => props.theme.inputLT};
`;
-export const TextArea = styled.textarea<InputProps>`
+export const TextArea = styled.textarea.withConfig({shouldForwardProp})<InputProps>`
${props => (props.secondary ? props.theme.secondaryInput : props.theme.input)};
`;
-export const TextAreaLight = styled.textarea`
+export const TextAreaLight = styled.textarea.withConfig({shouldForwardProp})`
${props => props.theme.inputLT} height: auto;
white-space: pre-wrap;
`;
@@ -335,7 +346,7 @@ export interface StyledPanelHeaderProps {
isValid?: boolean;
}
-export const StyledPanelHeader = styled.div<StyledPanelHeaderProps>`
+export const StyledPanelHeader = styled.div.withConfig({shouldForwardProp})<StyledPanelHeaderProps>`
background-color: ${props =>
props.active ? props.theme.panelBackgroundHover : props.theme.panelBackground};
border-left: 3px solid
@@ -388,7 +399,7 @@ interface DatasetSquareProps {
backgroundColor: RGBColor;
}
-export const DatasetSquare = styled.div<DatasetSquareProps>`
+export const DatasetSquare = styled.div.withConfig({shouldForwardProp})<DatasetSquareProps>`
display: inline-block;
width: 10px;
height: 10px;
@@ -400,7 +411,7 @@ interface SelectionButtonProps {
selected?: boolean;
}
-export const SelectionButton = styled.div<SelectionButtonProps>`
+export const SelectionButton = styled.div.withConfig({shouldForwardProp})<SelectionButtonProps>`
position: relative;
border-radius: 2px;
border: 1px solid
diff --git a/src/components/src/kepler-gl.tsx b/src/components/src/kepler-gl.tsx
index 70e2dc874..3749e8dd8 100644
--- a/src/components/src/kepler-gl.tsx
+++ b/src/components/src/kepler-gl.tsx
@@ -4,7 +4,6 @@
import React, {Component, createRef, Dispatch} from 'react';
import Console from 'global/console';
import {bindActionCreators} from 'redux';
-import isPropValid from '@emotion/is-prop-valid';
import styled, {withTheme, StyleSheetManager, ThemeProvider} from 'styled-components';
import {createSelector} from 'reselect';
import {connect as keplerGlConnect} from './connect/keplergl-connect';
@@ -29,6 +28,8 @@ import {
import {generateHashId} from '@kepler.gl/common-utils';
+import {shouldForwardProp} from './common/styled-components';
+
type KeplerGlActions = {
visStateActions: typeof VisStateActions;
mapStateActions: typeof MapStateActions;
@@ -73,16 +74,6 @@ import {theme as basicTheme, themeLT, themeBS, breakPointValues} from '@kepler.g
import {KeplerGlState} from '@kepler.gl/reducers';
import {Provider} from '@kepler.gl/cloud-providers';
-// This implements the default behavior from styled-components v5
-function shouldForwardProp(propName, target) {
- if (typeof target === 'string') {
- // For HTML elements, forward the prop if it is a valid HTML attribute
- return isPropValid(propName);
- }
- // For other elements, forward all props
- return true;
-}
-
// Maybe we should think about exporting this or creating a variable
// as part of the base.js theme
const GlobalStyle = styled.div`
diff --git a/src/components/src/side-panel/common/dataset-title.tsx b/src/components/src/side-panel/common/dataset-title.tsx
index 185d9d8c0..b35cb9c99 100644
--- a/src/components/src/side-panel/common/dataset-title.tsx
+++ b/src/components/src/side-panel/common/dataset-title.tsx
@@ -25,10 +25,10 @@ const StyledDatasetTitle = styled.div<StyledDatasetTitleProps>`
height: 16px;
}
&:hover {
- cursor: ${props => (props.clickable ? 'pointer' : 'auto')};
+ cursor: ${props => (props.$clickable ? 'pointer' : 'auto')};
.dataset-name {
- color: ${props => (props.clickable ? props.theme.textColorHl : props.theme.textColor)};
+ color: ${props => (props.$clickable ? props.theme.textColorHl : props.theme.textColor)};
}
.dataset-action {
@@ -149,7 +149,7 @@ export default function DatasetTitleFactory(
<div className="custom-palette-panel" ref={root}>
<StyledDatasetTitle
className="source-data-title"
- clickable={Boolean(showDatasetTable || onTitleClick)}
+ $clickable={Boolean(showDatasetTable || onTitleClick)}
>
<DatasetTag
dataset={dataset}
diff --git a/src/components/src/side-panel/common/types.ts b/src/components/src/side-panel/common/types.ts
index 0ac41ab2a..3ddcdf0c0 100644
--- a/src/components/src/side-panel/common/types.ts
+++ b/src/components/src/side-panel/common/types.ts
@@ -29,7 +29,7 @@ export type RemoveDatasetProps = {
};
export type StyledDatasetTitleProps = {
- clickable: boolean;
+ $clickable: boolean;
};
export type DatasetItemProps = {
diff --git a/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx b/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
index 88561f093..8a6e5f217 100644
--- a/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
+++ b/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
@@ -61,31 +61,31 @@ const hashStyles = {
};
export type IconDivProps = BaseComponentProps & {
- status?: 'SHOW' | 'ACTIVE' | null;
+ $status?: 'SHOW' | 'ACTIVE' | null;
};
const IconDiv: IStyledComponent<'web', IconDivProps> = styled.div.attrs({
className: 'tooltip-chicklet__icon'
})<IconDivProps>`
color: ${props =>
- props.status === hashStyles.SHOW
+ props.$status === hashStyles.SHOW
? props.theme.subtextColorActive
- : props.status === hashStyles.ACTIVE
+ : props.$status === hashStyles.ACTIVE
? props.theme.activeColor
: props.theme.textColor};
`;
export type SortableStyledItemProps = BaseComponentProps & {
- transition?: CSSProperties['transition'];
- transform?: CSSProperties['transform'];
+ $transition?: CSSProperties['transition'];
+ $transform?: CSSProperties['transform'];
ref: (node: HTMLElement | null) => void;
};
const SortableStyledItem: IStyledComponent<
'web',
SortableStyledItemProps
> = styled.div<SortableStyledItemProps>`
- transition: ${props => props.transition};
- transform: ${props => props.transform};
+ transition: ${props => props.$transition};
+ transform: ${props => props.$transform};
&.sorting {
opacity: 0.3;
pointer-events: none;
@@ -174,8 +174,8 @@ function TooltipChickletFactory(
<SortableStyledItem
ref={setNodeRef}
className={classnames('sortable-layer-items', {sorting: isDragging})}
- transform={CSS.Translate.toString(transform)}
- transition={transition || ''}
+ $transform={CSS.Translate.toString(transform)}
+ $transition={transition || ''}
{...attributes}
>
<ChickletButton>
@@ -198,7 +198,7 @@ function TooltipChickletFactory(
)}
>
<ChickletAddon>
- <IconDiv status={hashStyle}>
+ <IconDiv $status={hashStyle}>
<Hash
height="8px"
onClick={e => {
diff --git a/src/components/src/side-panel/layer-manager.tsx b/src/components/src/side-panel/layer-manager.tsx
index 53acaa7df..ffbc340c7 100644
--- a/src/components/src/side-panel/layer-manager.tsx
+++ b/src/components/src/side-panel/layer-manager.tsx
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component, useCallback} from 'react';
+import React, {useCallback} from 'react';
import {injectIntl, WrappedComponentProps} from 'react-intl';
import styled from 'styled-components';
@@ -153,111 +153,112 @@ function LayerManagerFactory(
AddLayerButton: ReturnType<typeof AddLayerButtonFactory>,
InfoHelper: ReturnType<typeof InfoHelperFactory>
) {
- class LayerManager extends Component<LayerManagerProps> {
- _addLayer = (dataset: string) => {
- const {visStateActions} = this.props;
- visStateActions.addLayer(undefined, dataset);
- };
-
- _togglePanelListView = (listView: string) => {
- const {uiStateActions} = this.props;
- uiStateActions.togglePanelListView({panelId: 'layer', listView});
- };
+ const LayerManager: React.FC<LayerManagerProps> = ({
+ layers,
+ datasets,
+ intl,
+ layerOrder,
+ panelListView,
+ panelMetadata,
+ layerClasses,
+ layerBlending,
+ overlayBlending,
+ showAddDataModal,
+ updateTableColor,
+ showDatasetTable,
+ removeDataset,
+ uiStateActions,
+ visStateActions,
+ mapStateActions
+ }) => {
+ const {addLayer} = visStateActions;
+ const {togglePanelListView} = uiStateActions;
+ const onAddLayer = useCallback(
+ (dataset: string) => {
+ addLayer(undefined, dataset);
+ },
+ [addLayer]
+ );
- render() {
- const {
- layers,
- datasets,
- intl,
- layerOrder,
- showAddDataModal,
- updateTableColor,
- showDatasetTable,
- removeDataset,
- uiStateActions,
- visStateActions,
- mapStateActions,
- panelListView,
- panelMetadata
- } = this.props;
+ const onTogglePanelListView = useCallback(
+ (listView: string) => {
+ togglePanelListView({panelId: 'layer', listView});
+ },
+ [togglePanelListView]
+ );
- const isSortByDatasetMode = panelListView === PANEL_VIEW_TOGGLES.byDataset;
+ const isSortByDatasetMode = panelListView === PANEL_VIEW_TOGGLES.byDataset;
- return (
- <div className="layer-manager">
- <SidePanelSection>
- <PanelViewListToggle
- togglePanelListView={this._togglePanelListView}
- mode={panelListView}
+ return (
+ <div className="layer-manager">
+ <SidePanelSection>
+ <PanelViewListToggle togglePanelListView={onTogglePanelListView} mode={panelListView} />
+ </SidePanelSection>
+ <DatasetSection
+ datasets={datasets}
+ showDatasetTable={showDatasetTable}
+ updateTableColor={updateTableColor}
+ removeDataset={removeDataset}
+ showDeleteDataset
+ showDatasetList={!isSortByDatasetMode}
+ showAddDataModal={showAddDataModal}
+ />
+ <SidePanelDivider />
+ <SidePanelSection>
+ <PanelTitle
+ className="layer-manager-title"
+ title={intl.formatMessage({id: panelMetadata.label})}
+ >
+ <AddLayerButton datasets={datasets} onAdd={onAddLayer} />
+ </PanelTitle>
+ </SidePanelSection>
+ <SidePanelSection>
+ {isSortByDatasetMode ? (
+ <DatasetLayerGroup
+ datasets={datasets}
+ showDatasetTable={showDatasetTable}
+ layers={layers}
+ updateTableColor={updateTableColor}
+ removeDataset={removeDataset}
+ layerOrder={layerOrder}
+ layerClasses={layerClasses}
+ uiStateActions={uiStateActions}
+ visStateActions={visStateActions}
+ mapStateActions={mapStateActions}
+ showDeleteDataset
/>
- </SidePanelSection>
- <DatasetSection
- datasets={datasets}
- showDatasetTable={showDatasetTable}
- updateTableColor={updateTableColor}
- removeDataset={removeDataset}
- showDeleteDataset
- showDatasetList={!isSortByDatasetMode}
- showAddDataModal={showAddDataModal}
- />
- <SidePanelDivider />
- <SidePanelSection>
- <PanelTitle
- className="layer-manager-title"
- title={intl.formatMessage({id: panelMetadata.label})}
- >
- <AddLayerButton datasets={datasets} onAdd={this._addLayer} />
- </PanelTitle>
- </SidePanelSection>
- <SidePanelSection>
- {isSortByDatasetMode ? (
- <DatasetLayerGroup
- datasets={datasets}
- showDatasetTable={showDatasetTable}
- layers={layers}
- updateTableColor={updateTableColor}
- removeDataset={removeDataset}
- layerOrder={layerOrder}
- layerClasses={this.props.layerClasses}
- uiStateActions={uiStateActions}
- visStateActions={visStateActions}
- mapStateActions={mapStateActions}
- showDeleteDataset
- />
- ) : (
- // TODO replace ignore
- // @ts-ignore
- <LayerList
- layers={layers}
- datasets={datasets}
- layerOrder={layerOrder}
- uiStateActions={uiStateActions}
- visStateActions={visStateActions}
- mapStateActions={mapStateActions}
- layerClasses={this.props.layerClasses}
- />
- )}
- </SidePanelSection>
- <LayerBlendingSelector
- layerBlending={this.props.layerBlending}
- updateLayerBlending={visStateActions.updateLayerBlending}
- intl={intl}
- />
- <OverlayBlendingSelector
- overlayBlending={this.props.overlayBlending}
- updateOverlayBlending={visStateActions.updateOverlayBlending}
- intl={intl}
- infoHelper={
- <InfoHelper
- id={`overlayBlending-description`}
- description={'overlayBlending.description'}
- />
- }
- />
- </div>
- );
- }
- }
+ ) : (
+ <LayerList
+ layers={layers}
+ datasets={datasets}
+ layerOrder={layerOrder}
+ uiStateActions={uiStateActions}
+ visStateActions={visStateActions}
+ mapStateActions={mapStateActions}
+ layerClasses={layerClasses}
+ />
+ )}
+ </SidePanelSection>
+ <LayerBlendingSelector
+ layerBlending={layerBlending}
+ updateLayerBlending={visStateActions.updateLayerBlending}
+ intl={intl}
+ />
+ <OverlayBlendingSelector
+ overlayBlending={overlayBlending}
+ updateOverlayBlending={visStateActions.updateOverlayBlending}
+ intl={intl}
+ infoHelper={
+ <InfoHelper
+ id={`overlayBlending-description`}
+ description={'overlayBlending.description'}
+ />
+ }
+ />
+ </div>
+ );
+ };
+
return injectIntl(LayerManager);
}
diff --git a/src/components/src/side-panel/layer-panel/color-palette.tsx b/src/components/src/side-panel/layer-panel/color-palette.tsx
index ea8c9ce55..59d85d1b5 100644
--- a/src/components/src/side-panel/layer-panel/color-palette.tsx
+++ b/src/components/src/side-panel/layer-panel/color-palette.tsx
@@ -28,8 +28,8 @@ const PaletteWrapper = styled.div.attrs({
`;
export type PaletteContainerProps = BaseComponentProps & {
- isColorChart?: boolean;
- isSelected?: boolean;
+ $isColorChart?: boolean;
+ $isSelected?: boolean;
};
const PaletteContainer: IStyledComponent<'web', PaletteContainerProps> = styled.div.attrs(
@@ -39,10 +39,10 @@ const PaletteContainer: IStyledComponent<'web', PaletteContainerProps> = styled.
)<PaletteContainerProps>`
display: flex;
flex-grow: 1;
- border-width: ${props => (props.isColorChart ? '0px' : '1px')};
+ border-width: ${props => (props.$isColorChart ? '0px' : '1px')};
border-style: solid;
- border-color: ${props => (props.isSelected ? '#FFFFFF' : 'transparent')};
- padding: ${props => (props.isColorChart ? '0px' : '4px')};
+ border-color: ${props => (props.$isSelected ? '#FFFFFF' : 'transparent')};
+ padding: ${props => (props.$isColorChart ? '0px' : '4px')};
border-radius: 4px;
`;
@@ -67,8 +67,8 @@ const ColorPalette = ({
return (
<PaletteContainer
className={className}
- isSelected={isSelected}
- isColorChart={Boolean(colorWidths)}
+ $isSelected={isSelected}
+ $isColorChart={Boolean(colorWidths)}
>
<PaletteWrapper style={paletteWrapperStyle}>
{colors.map((color: number | string, index: number) =>
diff --git a/src/components/src/side-panel/layer-panel/color-selector.tsx b/src/components/src/side-panel/layer-panel/color-selector.tsx
index 67ade3915..64bc5d05c 100644
--- a/src/components/src/side-panel/layer-panel/color-selector.tsx
+++ b/src/components/src/side-panel/layer-panel/color-selector.tsx
@@ -11,7 +11,7 @@ import {ColorUI, NestedPartial, RGBAColor, RGBColor} from '@kepler.gl/types';
import {rgbToHex} from '@kepler.gl/utils';
import RangeSliderFactory from '../../common/range-slider';
-import {PanelLabel, StyledPanelDropdown} from '../../common/styled-components';
+import {PanelLabel, shouldForwardProp, StyledPanelDropdown} from '../../common/styled-components';
import ColorPalette from './color-palette';
import ColorRangeSelectorFactory from './color-range-selector';
import SingleColorPalette from './single-color-palette';
@@ -52,7 +52,9 @@ const OPACITY_SLIDER_PROPS = {
showInput: true
};
-export const ColorBlock = styled.div<{backgroundcolor: RGBColor}>`
+export const ColorBlock = styled.div.withConfig({
+ shouldForwardProp
+})<{backgroundcolor: RGBColor}>`
width: 32px;
height: 18px;
border-radius: 1px;
@@ -68,7 +70,9 @@ const StyledColorSelectorWrapper = styled.div`
}
`;
-export const ColorSelectorInput = styled.div<ColorSelectorInputProps>`
+export const ColorSelectorInput = styled.div.withConfig({
+ shouldForwardProp
+})<ColorSelectorInputProps>`
${props => (props.inputTheme === 'secondary' ? props.theme.secondaryInput : props.theme.input)};
height: ${props => props.theme.inputBoxHeight};
diff --git a/src/components/src/side-panel/layer-panel/custom-palette.tsx b/src/components/src/side-panel/layer-panel/custom-palette.tsx
index e67c35739..e08200676 100644
--- a/src/components/src/side-panel/layer-panel/custom-palette.tsx
+++ b/src/components/src/side-panel/layer-panel/custom-palette.tsx
@@ -25,7 +25,7 @@ import {Tooltip} from '../../common/styled-components';
import Typeahead from '../../common/item-selector/typeahead';
import ChickletedInput from '../../common/item-selector/chickleted-input';
import DropdownList, {ListItem} from '../../common/item-selector/dropdown-list';
-
+import {shouldForwardProp} from '../../common/styled-components';
import {toArray} from '@kepler.gl/common-utils';
import {KeyEvent} from '@kepler.gl/constants';
import {ColorMap, ColorUI, HexColor, NestedPartial} from '@kepler.gl/types';
@@ -197,13 +197,16 @@ const StyledAddStepContainer = styled.div`
}
`;
-const StyledInput = styled(Input)<{width: string; textAlign: string}>`
+const StyledInput = styled(Input).withConfig({shouldForwardProp})<{
+ width: string;
+ textAlign: string;
+}>`
width: ${props => props.width ?? '100%'};
text-align: ${props => props.textAlign ?? 'end'};
pointer-events: ${props => (props.disabled ? 'none' : 'all')};
`;
-const InputText = styled.div<{width: string; textAlign: string}>`
+const InputText = styled.div.withConfig({shouldForwardProp})<{width: string; textAlign: string}>`
${props => props.theme.input};
background-color: transparent;
border-color: transparent;
diff --git a/src/components/src/side-panel/layer-panel/dataset-section.tsx b/src/components/src/side-panel/layer-panel/dataset-section.tsx
index 2d7fb509b..173417e87 100644
--- a/src/components/src/side-panel/layer-panel/dataset-section.tsx
+++ b/src/components/src/side-panel/layer-panel/dataset-section.tsx
@@ -26,7 +26,7 @@ type DatasetSectionProps = {
showAddDataModal: () => void;
};
-const StyledDatasetTitle = styled.div<{showDatasetList?: boolean}>`
+const StyledDatasetTitle = styled.div<{$showDatasetList?: boolean}>`
line-height: ${props => props.theme.sidePanelTitleLineHeight};
font-weight: 400;
letter-spacing: 1.25px;
@@ -35,7 +35,7 @@ const StyledDatasetTitle = styled.div<{showDatasetList?: boolean}>`
display: flex;
justify-content: space-between;
align-items: center;
- margin-bottom: ${props => (props.showDatasetList ? '16px' : '4px')};
+ margin-bottom: ${props => (props.$showDatasetList ? '16px' : '4px')};
`;
const StyledDatasetSection = styled.div`
@@ -79,7 +79,7 @@ function DatasetSectionFactory(
return (
<StyledDatasetSection>
- <StyledDatasetTitle showDatasetList={showDatasetList}>
+ <StyledDatasetTitle $showDatasetList={showDatasetList}>
<span>Datasets{datasetCount ? `(${datasetCount})` : ''}</span>
<AddDataButton onClick={showAddDataModal} isInactive={!datasetCount} />
</StyledDatasetTitle>
diff --git a/src/components/src/side-panel/layer-panel/layer-config-group.tsx b/src/components/src/side-panel/layer-panel/layer-config-group.tsx
index dc88847a5..1081b43e5 100644
--- a/src/components/src/side-panel/layer-panel/layer-config-group.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-config-group.tsx
@@ -8,6 +8,7 @@ import {FormattedMessage} from 'react-intl';
import Switch from '../../common/switch';
import InfoHelperFactory from '../../common/info-helper';
import {VertThreeDots} from '../../common/icons';
+import {shouldForwardProp} from '../../common/styled-components';
import {Layer} from '@kepler.gl/layers';
import {LayerVisConfig} from '@kepler.gl/types';
@@ -79,7 +80,7 @@ interface StyledConfigGroupHeaderProps {
collapsible?: boolean;
}
-export const StyledConfigGroupHeader = styled.div.attrs({
+export const StyledConfigGroupHeader = styled.div.withConfig({shouldForwardProp}).attrs({
className: 'layer-config-group__header'
})<StyledConfigGroupHeaderProps>`
display: flex;
diff --git a/src/components/src/side-panel/layer-panel/layer-list.tsx b/src/components/src/side-panel/layer-panel/layer-list.tsx
index c4e5350c7..d774a58d3 100644
--- a/src/components/src/side-panel/layer-panel/layer-list.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-list.tsx
@@ -40,14 +40,14 @@ const Container = styled.div`
`;
interface SortableStyledItemProps {
- transition?: string;
- transform?: string;
+ $transition?: string;
+ $transform?: string;
}
const SortableStyledItem = styled.div<SortableStyledItemProps>`
z-index: ${props => props.theme.dropdownWrapperZ + 1};
- transition: ${props => props.transition};
- transform: ${props => props.transform};
+ transition: ${props => props.$transition};
+ transform: ${props => props.$transform};
&.sorting {
opacity: 0.3;
pointer-events: none;
@@ -96,8 +96,8 @@ function LayerListFactory(LayerPanel: ReturnType<typeof LayerPanelFactory>) {
{sorting: isDragging}
)}
data-testid={disabled ? dataTestIds.staticLayerItem : dataTestIds.sortableLayerItem}
- transform={CSS.Transform.toString(transform)}
- transition={transition}
+ $transform={CSS.Transform.toString(transform)}
+ $transition={transition}
{...attributes}
>
<LayerPanel
diff --git a/src/components/src/side-panel/layer-panel/layer-panel-header.tsx b/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
index 91b663157..cab91db89 100644
--- a/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
@@ -11,7 +11,7 @@ import React, {
import classnames from 'classnames';
import styled, {css} from 'styled-components';
import PanelHeaderActionFactory from '../panel-header-action';
-import {Tooltip} from '../../common/styled-components';
+import {Tooltip, shouldForwardProp} from '../../common/styled-components';
import {
Copy,
ArrowDown,
@@ -84,12 +84,11 @@ type HeaderActionSectionProps = {
export type LayerPanelHeaderActionSectionProps = LayerPanelHeaderProps & HeaderActionSectionProps;
-const getBorderCss = status =>
- css`
- border-top: 2px solid ${({theme}) => theme.notificationColors[status]};
- border-bottom: 2px solid ${({theme}) => theme.notificationColors[status]};
- border-right: 2px solid ${({theme}) => theme.notificationColors[status]};
- `;
+const getBorderCss = status => css`
+ border-top: 2px solid ${({theme}) => theme.notificationColors[status]};
+ border-bottom: 2px solid ${({theme}) => theme.notificationColors[status]};
+ border-right: 2px solid ${({theme}) => theme.notificationColors[status]};
+`;
const StyledLayerPanelHeader = styled(StyledPanelHeader)`
height: ${props => props.theme.layerPanelHeaderHeight}px;
@@ -130,7 +129,7 @@ const HeaderLabelSection = styled.div`
padding-right: 50px;
`;
-const HeaderActionSection = styled.div<HeaderActionSectionProps>`
+const HeaderActionSection = styled.div.withConfig({shouldForwardProp})<HeaderActionSectionProps>`
display: flex;
position: absolute;
height: 100%;
@@ -150,7 +149,7 @@ type StyledPanelHeaderHiddenActionsProps = {
};
// Hiden actions only show up on hover
-const StyledPanelHeaderHiddenActions = styled.div.attrs({
+const StyledPanelHeaderHiddenActions = styled.div.withConfig({shouldForwardProp}).attrs({
className: 'layer-panel__header__actions__hidden'
})<StyledPanelHeaderHiddenActionsProps>`
opacity: 0;
@@ -158,7 +157,9 @@ const StyledPanelHeaderHiddenActions = styled.div.attrs({
align-items: center;
background-color: ${props =>
props.isConfigActive ? props.theme.panelBackgroundHover : props.theme.panelBackground};
- transition: opacity 0.4s ease, background-color 0.4s ease;
+ transition:
+ opacity 0.4s ease,
+ background-color 0.4s ease;
&:hover {
opacity: 1;
diff --git a/src/components/src/side-panel/map-manager.tsx b/src/components/src/side-panel/map-manager.tsx
index 859550794..9bb8818bd 100644
--- a/src/components/src/side-panel/map-manager.tsx
+++ b/src/components/src/side-panel/map-manager.tsx
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component} from 'react';
-import {createSelector} from 'reselect';
+import React, {useState, useMemo, useCallback} from 'react';
import {Button} from '../common/styled-components';
import MapStyleSelectorFactory from './map-style-panel/map-style-selector';
@@ -15,7 +14,6 @@ import {injectIntl, WrappedComponentProps} from 'react-intl';
import {FormattedMessage} from '@kepler.gl/localization';
import {MapStyle} from '@kepler.gl/reducers';
import {MapStyleActions} from '@kepler.gl/actions';
-import {MapStyles} from '@kepler.gl/types';
export type MapManagerProps = {
mapStyle: MapStyle;
@@ -37,87 +35,86 @@ function MapManagerFactory(
LayerGroupSelector: ReturnType<typeof LayerGroupSelectorFactory>,
PanelTitle: ReturnType<typeof PanelTitleFactory>
) {
- class MapManager extends Component<MapManagerProps> {
- state = {
- isSelecting: false
- };
+ const MapManager: React.FC<MapManagerProps> = ({
+ mapStyle,
+ intl,
+ mapStyleActions,
+ showAddMapStyleModal,
+ panelMetadata
+ }) => {
+ const [isSelecting, setIsSelecting] = useState(false);
+ const {mapStyleChange, removeCustomMapStyle} = mapStyleActions;
+ const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};
+ const editableLayers = currentStyle.layerGroups || [];
- _toggleSelecting = () => {
- this.setState({isSelecting: !this.state.isSelecting});
- };
+ const toggleSelecting = useCallback(() => {
+ setIsSelecting(prev => !prev);
+ }, [setIsSelecting]);
- _selectStyle = (val: string) => {
- const {mapStyleActions} = this.props;
- const {mapStyleChange} = mapStyleActions;
- mapStyleChange(val);
- this._toggleSelecting();
- };
-
- getCustomMapStylesActions = createSelector(
- (props: MapManagerProps) => props.mapStyle.mapStyles,
- (props: MapManagerProps) => props.mapStyleActions,
- (mapStyles: MapStyles, mapStyleActions) => {
- const actionsPerCustomStyle = {};
- Object.values(mapStyles)
- .filter(mapStyle => {
- return Boolean(mapStyle.custom);
- })
- .forEach(({id}) => {
- actionsPerCustomStyle[id] = [
- {
- id: `remove-map-style-${id}`,
- IconComponent: Trash,
- tooltip: 'tooltip.removeBaseMapStyle',
- onClick: () => mapStyleActions.removeCustomMapStyle({id})
- }
- ];
- });
- return actionsPerCustomStyle;
- }
+ const mapStyles = mapStyle.mapStyles;
+ const selectStyle = useCallback(
+ (val: string) => {
+ mapStyleChange(val);
+ setIsSelecting(false);
+ },
+ [mapStyleChange, setIsSelecting]
);
- render() {
- const {mapStyle, intl, mapStyleActions, showAddMapStyleModal, panelMetadata} = this.props;
- const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};
- const editableLayers = currentStyle.layerGroups || [];
- const customMapStylesActions = this.getCustomMapStylesActions(this.props);
+ const customMapStylesActions = useMemo(() => {
+ const actionsPerCustomStyle = {};
+ Object.values(mapStyles)
+ .filter(mapStyle => {
+ return Boolean(mapStyle.custom);
+ })
+ .forEach(({id}) => {
+ actionsPerCustomStyle[id] = [
+ {
+ id: `remove-map-style-${id}`,
+ IconComponent: Trash,
+ tooltip: 'tooltip.removeBaseMapStyle',
+ onClick: () => removeCustomMapStyle({id})
+ }
+ ];
+ });
+ return actionsPerCustomStyle;
+ }, [mapStyles, removeCustomMapStyle]);
- return (
- <div className="map-style-panel">
- <PanelTitle
- className="map-manager-title"
- title={intl.formatMessage({id: panelMetadata.label})}
- >
- <Button className="add-map-style-button" onClick={showAddMapStyleModal}>
- <Add height="12px" />
- <FormattedMessage id={'mapManager.addMapStyle'} />
- </Button>
- </PanelTitle>
- <div>
- <MapStyleSelector
- mapStyle={mapStyle}
- isSelecting={this.state.isSelecting}
- onChange={this._selectStyle}
- toggleActive={this._toggleSelecting}
- customMapStylesActions={customMapStylesActions}
+ return (
+ <div className="map-style-panel">
+ <PanelTitle
+ className="map-manager-title"
+ title={intl.formatMessage({id: panelMetadata.label})}
+ >
+ <Button className="add-map-style-button" onClick={showAddMapStyleModal}>
+ <Add height="12px" />
+ <FormattedMessage id={'mapManager.addMapStyle'} />
+ </Button>
+ </PanelTitle>
+ <div>
+ <MapStyleSelector
+ mapStyle={mapStyle}
+ isSelecting={isSelecting}
+ onChange={selectStyle}
+ toggleActive={toggleSelecting}
+ customMapStylesActions={customMapStylesActions}
+ />
+ {editableLayers.length ? (
+ <LayerGroupSelector
+ layers={mapStyle.visibleLayerGroups}
+ editableLayers={editableLayers}
+ topLayers={mapStyle.topLayerGroups}
+ onChange={mapStyleActions.mapConfigChange}
+ threeDBuildingColor={mapStyle.threeDBuildingColor}
+ on3dBuildingColorChange={mapStyleActions.set3dBuildingColor}
+ backgroundColor={mapStyle.backgroundColor}
+ onBackgroundColorChange={mapStyleActions.setBackgroundColor}
/>
- {editableLayers.length ? (
- <LayerGroupSelector
- layers={mapStyle.visibleLayerGroups}
- editableLayers={editableLayers}
- topLayers={mapStyle.topLayerGroups}
- onChange={mapStyleActions.mapConfigChange}
- threeDBuildingColor={mapStyle.threeDBuildingColor}
- on3dBuildingColorChange={mapStyleActions.set3dBuildingColor}
- backgroundColor={mapStyle.backgroundColor}
- onBackgroundColorChange={mapStyleActions.setBackgroundColor}
- />
- ) : null}
- </div>
+ ) : null}
</div>
- );
- }
- }
+ </div>
+ );
+ };
+
return injectIntl(MapManager);
}
diff --git a/src/components/src/side-panel/map-style-panel/map-layer-group-color-picker.tsx b/src/components/src/side-panel/map-style-panel/map-layer-group-color-picker.tsx
index 5c558773a..940b2d19b 100644
--- a/src/components/src/side-panel/map-style-panel/map-layer-group-color-picker.tsx
+++ b/src/components/src/side-panel/map-style-panel/map-layer-group-color-picker.tsx
@@ -13,8 +13,8 @@ import {Tooltip} from '../../common/styled-components';
import CustomPicker from '../layer-panel/custom-picker';
import {ColorBlock} from '../layer-panel/color-selector';
-const LayerGroupColorPickerWrapper = styled.div<{extraMarginRight?: boolean; disabled?: boolean}>`
- margin-right: ${props => (props.extraMarginRight ? 0 : 24)}px;
+const LayerGroupColorPickerWrapper = styled.div<{$extraMarginRight?: boolean; disabled?: boolean}>`
+ margin-right: ${props => (props.$extraMarginRight ? 0 : 24)}px;
cursor: pointer;
${props =>
props.disabled &&
@@ -61,7 +61,7 @@ function LayerGroupColorPickerFactory() {
);
return (
- <LayerGroupColorPickerWrapper extraMarginRight={extraMarginRight} disabled={disabled}>
+ <LayerGroupColorPickerWrapper $extraMarginRight={extraMarginRight} disabled={disabled}>
<ColorBlock
backgroundcolor={color}
onClick={onColorBlockClick}
diff --git a/src/components/src/side-panel/map-style-panel/map-layer-group-item.tsx b/src/components/src/side-panel/map-style-panel/map-layer-group-item.tsx
index fda647f53..700304391 100644
--- a/src/components/src/side-panel/map-style-panel/map-layer-group-item.tsx
+++ b/src/components/src/side-panel/map-style-panel/map-layer-group-item.tsx
@@ -28,8 +28,8 @@ const StyledLayerGroupItem = styled.div`
}
`;
-const LayerLabel = styled(PanelLabelBold)<{active: boolean}>`
- color: ${props => (props.active ? props.theme.textColor : props.theme.labelColor)};
+const LayerLabel = styled(PanelLabelBold)<{$active: boolean}>`
+ color: ${props => (props.$active ? props.theme.textColor : props.theme.labelColor)};
`;
export type LayerGroupItemActionIcons = {
@@ -99,13 +99,13 @@ function LayerGroupItemFactory(LayerGroupColorPicker) {
active={layers[slug]}
flush
/>
- <LayerLabel active={layers[slug]}>
+ <LayerLabel $active={layers[slug]}>
<FormattedMessage id={`mapLayers.${camelize(slug)}`} />
</LayerLabel>
</PanelLabelWrapper>
) : (
<CenterFlexbox>
- <LayerLabel style={{marginLeft: '28px'}} active={true}>
+ <LayerLabel style={{marginLeft: '28px'}} $active={true}>
<FormattedMessage id={`mapLayers.${camelize(slug)}`} />
</LayerLabel>
</CenterFlexbox>
diff --git a/src/components/src/side-panel/panel-header-action.tsx b/src/components/src/side-panel/panel-header-action.tsx
index 04ed860c6..fe09a70ff 100644
--- a/src/components/src/side-panel/panel-header-action.tsx
+++ b/src/components/src/side-panel/panel-header-action.tsx
@@ -27,29 +27,29 @@ export interface PanelHeaderActionProps {
}
type HeaderActionWrapperProps = {
- flush?: boolean;
- active?: boolean;
- hoverColor?: string | null;
- dataTestId?: any;
+ $flush?: boolean;
+ $active?: boolean;
+ $hoverColor?: string | null;
+ $dataTestId?: any;
};
-type HeaderActionWrapperCssProps = {testId?: string} & HeaderActionWrapperProps &
+type HeaderActionWrapperCssProps = {$testId?: string} & HeaderActionWrapperProps &
BaseComponentProps;
const HeaderActionWrapper = styled.div.attrs<HeaderActionWrapperCssProps>(props => ({
- dataTestId: props.testId
+ $dataTestId: props.$testId
}))<HeaderActionWrapperProps>`
- margin-left: ${props => (props.flush ? 0 : 8)}px;
+ margin-left: ${props => (props.$flush ? 0 : 8)}px;
display: flex;
align-items: center;
color: ${props =>
- props.active ? props.theme.panelHeaderIconActive : props.theme.panelHeaderIcon};
+ props.$active ? props.theme.panelHeaderIconActive : props.theme.panelHeaderIcon};
cursor: pointer;
&:hover {
color: ${props =>
- props.hoverColor ? props.theme[props.hoverColor] : props.theme.panelHeaderIconHover};
+ props.$hoverColor ? props.theme[props.$hoverColor] : props.theme.panelHeaderIconHover};
}
&.disabled {
@@ -81,9 +81,9 @@ export default function PanelHeaderActionFactory(): React.FC<PanelHeaderActionPr
disabled,
...(className ? {[className]: true} : {})
})}
- active={active}
- hoverColor={hoverColor}
- flush={flush}
+ $active={active}
+ $hoverColor={hoverColor}
+ $flush={flush}
>
{IconComponent ? (
<IconComponent
diff --git a/src/components/src/side-panel/panel-view-list-toggle.tsx b/src/components/src/side-panel/panel-view-list-toggle.tsx
index c6ca8c962..c5124e065 100644
--- a/src/components/src/side-panel/panel-view-list-toggle.tsx
+++ b/src/components/src/side-panel/panel-view-list-toggle.tsx
@@ -36,8 +36,8 @@ const PanelViewListToggleWrapper = styled.div.attrs({
export const StyledToggleOption = styled.div.attrs({
className: 'layer-panel-toggle-option'
-})<{active: boolean}>`
- color: ${props => (props.active ? props.theme.subtextColorActive : props.theme.panelTabColor)};
+})<{$active: boolean}>`
+ color: ${props => (props.$active ? props.theme.subtextColorActive : props.theme.panelTabColor)};
&:hover {
cursor: pointer;
color: ${props => props.theme.subtextColorActive};
@@ -49,7 +49,7 @@ function ToggleOptionFactory() {
<StyledToggleOption
data-tip
data-for={`${option.id}-toggle-option`}
- active={isActive}
+ $active={isActive}
onClick={onClick}
>
<option.iconComponent height="20px" />
diff --git a/src/layers/src/geojson-layer/geojson-utils.ts b/src/layers/src/geojson-layer/geojson-utils.ts
index 6f926bfed..47704f51b 100644
--- a/src/layers/src/geojson-layer/geojson-utils.ts
+++ b/src/layers/src/geojson-layer/geojson-utils.ts
@@ -272,7 +272,8 @@ export function getGeojsonBounds(features: GeojsonDataMaps = []): BBox | null {
const samples = features.length > maxCount ? getSampleData(features, maxCount) : features;
const validSingleGeometry = geom => geom.coordinates && geom.coordinates.length;
- const validGeometryCollection = geom => geom.geometries && geom.geometries.length && geom.geometries.every(validSingleGeometry);
+ const validGeometryCollection = geom =>
+ geom.geometries && geom.geometries.length && geom.geometries.every(validSingleGeometry);
const nonEmpty = samples.filter(
d => d && d.geometry && (validSingleGeometry(d.geometry) || validGeometryCollection(d.geometry))
);
diff --git a/src/layers/src/icon-layer/icon-layer.ts b/src/layers/src/icon-layer/icon-layer.ts
index 472ba8594..ac8cccad6 100644
--- a/src/layers/src/icon-layer/icon-layer.ts
+++ b/src/layers/src/icon-layer/icon-layer.ts
@@ -65,11 +65,12 @@ export const SVG_ICON_URL = `${KEPLER_UNFOLDED_BUCKET}/icons/svg-icons.json`;
export const iconPosAccessor =
({lat, lng, altitude}: IconLayerColumnsConfig) =>
(dc: DataContainerInterface) =>
- d => [
- dc.valueAt(d.index, lng.fieldIdx),
- dc.valueAt(d.index, lat.fieldIdx),
- altitude?.fieldIdx > -1 ? dc.valueAt(d.index, altitude.fieldIdx) : 0
- ];
+ d =>
+ [
+ dc.valueAt(d.index, lng.fieldIdx),
+ dc.valueAt(d.index, lat.fieldIdx),
+ altitude?.fieldIdx > -1 ? dc.valueAt(d.index, altitude.fieldIdx) : 0
+ ];
export const iconAccessor =
({icon}: IconLayerColumnsConfig) =>
@@ -197,7 +198,7 @@ export default class IconLayer extends Layer {
};
}
- getZoomFactor({zoom, zoomOffset = 0}: {zoom: number, zoomOffset?: number}) {
+ getZoomFactor({zoom, zoomOffset = 0}: {zoom: number; zoomOffset?: number}) {
return Math.pow(2, 14 - zoom + zoomOffset);
}
@@ -229,7 +230,10 @@ export default class IconLayer extends Layer {
this._layerInfoModal = IconInfoModalFactory(svgIcons);
}
- static findDefaultLayerProps({fieldPairs = [], fields = []}: KeplerTable): FindDefaultLayerPropsReturnValue {
+ static findDefaultLayerProps({
+ fieldPairs = [],
+ fields = []
+ }: KeplerTable): FindDefaultLayerPropsReturnValue {
const notFound: FindDefaultLayerPropsReturnValue = {props: []};
if (!fieldPairs.length || !fields.length) {
return notFound;
diff --git a/src/utils/src/utils.ts b/src/utils/src/utils.ts
index 3afc3ecd7..f9646d563 100644
--- a/src/utils/src/utils.ts
+++ b/src/utils/src/utils.ts
@@ -160,10 +160,10 @@ export function getError(
return Object.prototype.hasOwnProperty.call(err, 'message')
? getError(err.message)
: Object.prototype.hasOwnProperty.call(err, 'error')
- ? getError(err.error)
- : Object.prototype.hasOwnProperty.call(err, 'err')
- ? getError(err.err)
- : JSON.stringify(err);
+ ? getError(err.error)
+ : Object.prototype.hasOwnProperty.call(err, 'err')
+ ? getError(err.err)
+ : JSON.stringify(err);
}
return defaultMessage;