Skip to content

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

[Enhancement] render warning in layer panel header (#1901)

Igor Dykhtacb76ae0f399b
diff --git a/src/components/common/icons/index.tsx b/src/components/common/icons/index.tsx
index 499a4bd6a..e70a2e739 100644
--- a/src/components/common/icons/index.tsx
+++ b/src/components/common/icons/index.tsx
@@ -89,6 +89,7 @@ export {default as VertThreeDots} from './vert-three-dots';
export {default as IconWrapper} from './base';
export {default as CodeAlt} from './code-alt';
export {default as Warning} from './warning';
+export {default as WarningSign} from './warning-sign';
export {default as DrawPolygon} from './draw-polygon';
export {default as Polygon} from './polygon';
export {default as Rectangle} from './rectangle';
diff --git a/src/components/common/icons/warning-sign.tsx b/src/components/common/icons/warning-sign.tsx
new file mode 100644
index 000000000..17992392d
--- /dev/null
+++ b/src/components/common/icons/warning-sign.tsx
@@ -0,0 +1,52 @@
+// Copyright (c) 2022 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+import React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base, {BaseProps} from './base';
+
+export default class WarningSign extends Component<Partial<BaseProps>> {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-warning-sign',
+ stroke: '#FFF'
+ };
+
+ render() {
+ return (
+ <Base viewBox="0 0 16 16" {...this.props} stroke="none">
+ <path
+ d="M15.6753 12.0189L10.017 1.60205C9.58989 0.88311 8.83564 0.453735 7.99939 0.453735C7.16314 0.453735 6.40889 0.88311 5.98183 1.60205C5.97861 1.60755 5.97589 1.61305 5.97267 1.61855L0.33317 12.0024C-0.103049 12.7365 -0.111299 13.6181 0.310701 14.3604C0.73367 15.1032 1.49567 15.5463 2.35026 15.5463H13.6173C14.4719 15.5463 15.2652 15.1032 15.6881 14.3604C16.1101 13.6181 16.1019 12.7365 15.6753 12.0189ZM7.06095 5.22339C7.06095 4.70508 7.48111 4.28495 7.99939 4.28495C8.5177 4.28495 8.93783 4.70511 8.93783 5.22339V8.97717C8.93783 9.49542 8.51767 9.91561 7.99939 9.91561C7.48111 9.91561 7.06095 9.49539 7.06095 8.97717V5.22339ZM7.99939 13.6694C7.22317 13.6694 6.5917 13.038 6.5917 12.2617C6.5917 11.4855 7.22314 10.8541 7.99939 10.8541C8.77561 10.8541 9.40705 11.4855 9.40705 12.2617C9.40708 13.038 8.77564 13.6694 7.99939 13.6694Z"
+ fill="#F5B766"
+ />
+ <circle cx="8" cy="12.2773" r="1.43359" fill="#121621" />
+ <path
+ d="M8 4.28125C8.51992 4.28125 8.94141 4.70273 8.94141 5.22266V8.97266C8.94141 9.49258 8.51992 9.91406 8 9.91406C7.48008 9.91406 7.05859 9.49258 7.05859 8.97266V5.22266C7.05859 4.70273 7.48008 4.28125 8 4.28125Z"
+ fill="#121621"
+ />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/styled-components.tsx b/src/components/common/styled-components.tsx
index c9dbd73f7..e9a18286d 100644
--- a/src/components/common/styled-components.tsx
+++ b/src/components/common/styled-components.tsx
@@ -329,6 +329,7 @@ export const InlineInput = styled(Input)`
export interface StyledPanelHeaderProps {
active?: boolean;
labelRCGColorValues?: RGBColor | null;
+ warning?: boolean;
}
export const StyledPanelHeader = styled.div<StyledPanelHeaderProps>`
diff --git a/src/components/injector.tsx b/src/components/injector.tsx
index 35ff1c516..12234bcb8 100644
--- a/src/components/injector.tsx
+++ b/src/components/injector.tsx
@@ -21,6 +21,11 @@
import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
+import {
+ MapStateToPropsParam,
+ MapDispatchToPropsParam,
+ InferableComponentEnhancerWithProps
+} from 'react-redux';
import {console as Console} from 'global/window';
import KeplerGlContext from 'components/context';
@@ -136,6 +141,14 @@ export function typeCheckRecipe(recipe) {
return true;
}
+export interface WithState<RootState> {
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = RootState>(
+ lenses: any[],
+ mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
+ mapDispatchToProps?: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
+ ): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
+}
+
const identity = state => state;
// Helper to add reducer state to custom component
export function withState(lenses: any[] = [], mapStateToProps = identity, actions = {}) {
diff --git a/src/components/side-panel/layer-panel/layer-panel-header.tsx b/src/components/side-panel/layer-panel/layer-panel-header.tsx
index e7d341fb5..ea642c3b2 100644
--- a/src/components/side-panel/layer-panel/layer-panel-header.tsx
+++ b/src/components/side-panel/layer-panel/layer-panel-header.tsx
@@ -26,10 +26,19 @@ import React, {
ChangeEventHandler
} from 'react';
import classnames from 'classnames';
-import styled from 'styled-components';
+import styled, {css} from 'styled-components';
import {SortableHandle} from 'react-sortable-hoc';
import PanelHeaderActionFactory from 'components/side-panel/panel-header-action';
-import {Copy, ArrowDown, EyeSeen, EyeUnseen, Trash, VertDots} from 'components/common/icons';
+import {Tooltip} from 'components/common/styled-components';
+import {
+ Copy,
+ ArrowDown,
+ EyeSeen,
+ EyeUnseen,
+ Trash,
+ VertDots,
+ WarningSign
+} from 'components/common/icons';
import {InlineInput, StyledPanelHeader} from 'components/common/styled-components';
import {FormattedMessage} from '@kepler.gl/localization';
@@ -67,6 +76,7 @@ type LayerPanelHeaderProps = {
layerType?: string | null;
allowDuplicate?: boolean;
isDragNDropEnabled?: boolean;
+ warning?: boolean;
labelRCGColorValues?: RGBColor | null;
actionIcons?: {
remove: ComponentType<Partial<BaseProps>>;
@@ -83,6 +93,13 @@ export const defaultProps = {
showRemoveLayer: true
};
+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;
position: relative;
@@ -97,6 +114,8 @@ const StyledLayerPanelHeader = styled(StyledPanelHeader)`
padding: 10px;
}
+ ${props => (props.warning ? getBorderCss('warning') : '')}
+
:hover {
cursor: pointer;
background-color: ${props => props.theme.panelBackgroundHover};
@@ -241,6 +260,21 @@ export function LayerTitleSectionFactory() {
return LayerTitleSection;
}
+const StyledHeaderWaring = styled.div`
+ position: absolute;
+ right: -9px;
+ top: calc(50% - 9px);
+ color: ${({theme}) => theme.notificationColors.warning};
+`;
+
+export const HeaderWarning = ({warning, id}) => (
+ <StyledHeaderWaring>
+ <WarningSign data-tip data-for={`layer-${id}-warning`} height="16px" />
+ <Tooltip id={`layer-${id}-warning`} type="warning" effect="solid" textColor="black">
+ {warning}
+ </Tooltip>
+ </StyledHeaderWaring>
+);
LayerPanelHeaderFactory.deps = [LayerTitleSectionFactory, PanelHeaderActionFactory];
const defaultActionIcons = {
@@ -260,6 +294,7 @@ function LayerPanelHeaderFactory(
allowDuplicate,
isDragNDropEnabled,
isVisible,
+ warning,
label,
layerId,
layerType,
@@ -279,10 +314,12 @@ function LayerPanelHeaderFactory(
className={classnames('layer-panel__header', {
'sort--handle': !isConfigActive
})}
+ warning={warning}
active={isConfigActive}
labelRCGColorValues={labelRCGColorValues}
onClick={onToggleEnableConfig}
>
+ {warning ? <HeaderWarning warning={warning} id={layerId} /> : null}
<HeaderLabelSection className="layer-panel__header__content">
{isDragNDropEnabled ? (
<DragHandle className="layer__drag-handle">