Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Enhancement] Demo app sample info (#758)
Shan Hee35f5ed9b6e9
diff --git a/examples/demo-app/package.json b/examples/demo-app/package.jsonindex ef7c12b31..bb4f318e2 100644--- a/examples/demo-app/package.json+++ b/examples/demo-app/package.json@@ -15,6 +15,7 @@"react": "^16.8.4","react-copy-to-clipboard": "^5.0.1","react-dom": "^16.8.4",+ "react-markdown": "^4.2.2","react-palm": "^1.1.2","react-redux": "^5.1.1","react-router": "^3.0.5",@@ -56,4 +57,4 @@"webpack-hot-middleware": "^2.24.3","webpack-stats-plugin": "^0.2.1"}-}\ No newline at end of file+}diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.jsindex e7901aa5f..4b00c5852 100644--- a/examples/demo-app/src/app.js+++ b/examples/demo-app/src/app.js@@ -29,6 +29,7 @@ import Banner from './components/banner';import Announcement from './components/announcement';import {replaceLoadDataModal} from './factories/load-data-modal';import {replaceSaveMap} from './factories/save-map';+import {replaceMapControl} from './factories/map-control';import ExportUrlModal from './components/sharing/export-url-modal';import {AUTH_TOKENS} from './constants/default-settings';import {@@ -40,7 +41,8 @@ import {const KeplerGl = require('kepler.gl/components').injectComponents([replaceLoadDataModal(),- replaceSaveMap()+ replaceSaveMap(),+ replaceMapControl()]);// Sample datadiff --git a/examples/demo-app/src/components/map-control/map-control.js b/examples/demo-app/src/components/map-control/map-control.jsnew file mode 100644index 000000000..b881738eb--- /dev/null+++ b/examples/demo-app/src/components/map-control/map-control.js@@ -0,0 +1,190 @@+// Copyright (c) 2019 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, {useState} from 'react';+import styled from 'styled-components';+import {+ MapControlFactory,+ Icons,+ IconRoundSmall,+ MapControlButton+} from 'kepler.gl/components';+import ReactMarkdown from 'react-markdown';++const MapControl = MapControlFactory();++const StyledMapControlOverlay = styled.div`+ position: absolute;+ top: 0px;+ right: 0px;+ z-index: 1;+`;++const StyledFloatingPanel = styled.div`+ margin-right: 12px;+ margin-top: 20px;+`;++const StyledProjectPanel = styled.div`+ background: ${props => props.theme.panelBackground};+ padding: 16px 20px;+ width: 280px;+ box-shadow: ${props => props.theme.panelBoxShadow};++ .project-title {+ color: ${props => props.theme.titleTextColor};+ font-size: 13px;+ font-weight: 500;+ display: flex;+ justify-content: space-between;+ }++ .project-description {+ color: ${props => props.theme.textColor};+ font-size: 11px;+ margin-top: 12px;++ a {+ font-weight: 500;+ color: ${props => props.theme.titleTextColor};+ }+ }++ .project-links {+ margin-top: 20px;+ width: 100%;+ display: flex;+ align-items: center;+ justify-content: flex-end;+ }+`;+const StyledPanelAction = styled.div`+ border-radius: 2px;+ margin-left: 4px;+ padding: 5px;+ font-weight: 500;++ a {+ align-items: center;+ justify-content: flex-start;+ display: flex;+ height: 16px;+ padding-right: 10px;+ color: ${props =>+ props.active ? props.theme.textColorHl : props.theme.subtextColor};++ svg {+ margin-right: 8px;+ }+ }++ :hover {+ cursor: pointer;+ a {+ color: ${props => props.theme.textColorHl};+ }+ }+`;++export const LinkButton = props => (+ <StyledPanelAction className="project-link__action">+ <a target="_blank" rel="noopener noreferrer" href={props.href}>+ <props.iconComponent height={props.height || '16px'} />+ <p>{props.label}</p>+ </a>+ </StyledPanelAction>+);++const CloseButton = ({onClick}) => (+ <IconRoundSmall>+ <Icons.Close height="16px" onClick={onClick} />+ </IconRoundSmall>+);++const LinkRenderer = props => {+ return (+ <a href={props.href} target="_blank" rel="noopener noreferrer">+ {props.children}+ </a>+ );+};++// convert https://raw.githubusercontent.com/uber-web/kepler.gl-data/master/nyctrips/config.json+// to https://github.com/uber-web/kepler.gl-data/blob/master/movement_pittsburgh/config.json+function getURL(url) {+ return url+ .replace('https://raw.githubusercontent.com', 'https://github.com')+ .replace('master', 'blob/master');+}++function SampleMapPanel(props) {+ const [isActive, setActive] = useState(true);++ return (+ <StyledFloatingPanel>+ {isActive ? (+ <StyledProjectPanel>+ <div className="project-title">+ <div>{props.currentSample.label}</div>+ <CloseButton onClick={() => setActive(false)}/>+ </div>+ <div className="project-description">+ <ReactMarkdown+ source={props.currentSample.detail || props.currentSample.description}+ renderers={{link: LinkRenderer}}+ />+ </div>+ <div className="project-links">+ <LinkButton+ label="Data"+ href={getURL(props.currentSample.dataUrl)}+ iconComponent={Icons.Files}+ height="15px"+ />+ <LinkButton+ label="Config"+ href={getURL(props.currentSample.configUrl)}+ iconComponent={Icons.CodeAlt}+ height="17px"+ />+ </div>+ </StyledProjectPanel>+ ) : (+ <MapControlButton+ onClick={e => {+ e.preventDefault();+ setActive(true);+ }}+ >+ <Icons.Docs height="18px" />+ </MapControlButton>+ )}+ </StyledFloatingPanel>+ );+}++const CustomMapControl = props => (+ <StyledMapControlOverlay>+ {props.currentSample ? <SampleMapPanel {...props} /> : null}+ <MapControl {...props} />+ </StyledMapControlOverlay>+);++export default CustomMapControl;diff --git a/examples/demo-app/src/factories/map-control.js b/examples/demo-app/src/factories/map-control.jsnew file mode 100644index 000000000..986602108--- /dev/null+++ b/examples/demo-app/src/factories/map-control.js@@ -0,0 +1,33 @@+// Copyright (c) 2019 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 {MapControlFactory} from 'kepler.gl/components';+import CustomMapControl from '../components/map-control/map-control';+import {withState} from 'kepler.gl/components';++export const CustomMapControlFactory = () =>+ withState(+ [],+ state => ({...state.demo.app})+ )(CustomMapControl);++export function replaceMapControl() {+ return [MapControlFactory, CustomMapControlFactory];+}diff --git a/examples/demo-app/src/reducers/index.js b/examples/demo-app/src/reducers/index.jsindex 00c1585a7..c67643767 100644--- a/examples/demo-app/src/reducers/index.js+++ b/examples/demo-app/src/reducers/index.js@@ -149,6 +149,7 @@ export const loadRemoteResourceSuccess = (state, action) => {...state,app: {...state.app,+ currentSample: action.options,isMapLoading: false // we turn of the spinner},keplerGl: {diff --git a/src/components/common/icons/code-alt.js b/src/components/common/icons/code-alt.jsindex 68cd5d175..27ff4cda3 100644--- a/src/components/common/icons/code-alt.js+++ b/src/components/common/icons/code-alt.js@@ -30,7 +30,7 @@ export default class CodeAlt extends Component {static defaultProps = {height: '16px',- predefinedClassName: 'data-ex-icons-crosshairs'+ predefinedClassName: 'data-ex-icons-codealt'};render() {diff --git a/src/components/common/icons/files.js b/src/components/common/icons/files.jsindex 458112744..35d826a1b 100644--- a/src/components/common/icons/files.js+++ b/src/components/common/icons/files.js@@ -29,7 +29,7 @@ export default class Files extends React.Component {};static defaultProps = {height: '16px',- predefinedClassName: 'data-ex-icons-minus'+ predefinedClassName: 'data-ex-icons-files'};render() {diff --git a/src/components/common/modal.js b/src/components/common/modal.jsindex d34a29ed5..d8a6a8ffe 100644--- a/src/components/common/modal.js+++ b/src/components/common/modal.js@@ -30,7 +30,7 @@ import {media} from 'styles/media-breakpoints';const ModalContentWrapper = styled.div`overflow-y: scroll;max-width: 70vw;- max-height: 70vh;+ max-height: 85vh;padding: 24px 72px 40px;position: relative;top: 92px;diff --git a/src/components/common/styled-components.js b/src/components/common/styled-components.jsindex 3f6bdf9ca..e32db798a 100644--- a/src/components/common/styled-components.js+++ b/src/components/common/styled-components.js@@ -508,3 +508,35 @@ export const BottomWidgetInner = styled.div`position: relative;margin-top: ${props => props.theme.bottomPanelGap}px;`;++export const MapControlButton = styled.div.attrs({+ className: 'map-control-button'+})`+ align-items: center;+ background-color: ${props =>+ props.active+ ? props.theme.panelBackgroundHover+ : props.theme.panelBackground};+ border: 0;+ box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.16);+ color: ${props => props.theme.primaryBtnColor};+ cursor: pointer;+ display: flex;+ height: 32px;+ justify-content: center;+ margin: 0;+ outline: none;+ padding: 0;+ transition: ${props => props.theme.transition};+ width: 32px;++ :focus {+ outline: none;+ }++ :hover {+ cursor: pointer;+ background-color: ${props => props.theme.secondaryBtnActBgd};+ color: ${props => props.theme.secondaryBtnActColor};+ }+`;diff --git a/src/components/map/map-control.js b/src/components/map/map-control.jsindex 6576fc6d1..b5447af8a 100644--- a/src/components/map/map-control.js+++ b/src/components/map/map-control.js@@ -23,7 +23,7 @@ import PropTypes from 'prop-types';import {createSelector} from 'reselect';import styled from 'styled-components';-import {Tooltip, IconRoundSmall} from 'components/common/styled-components';+import {Tooltip, IconRoundSmall, MapControlButton} from 'components/common/styled-components';import MapLayerSelector from 'components/common/map-layer-selector';import KeplerGlLogo from 'components/common/logo';import MapLegend from './map-legend';@@ -51,40 +51,6 @@ const StyledMapControlAction = styled.div`justify-content: flex-end;`;-const StyledMapControlButton = styled.div`- align-items: center;- background-color: ${props =>- props.active- ? props.theme.secondaryBtnActBgd- : props.theme.secondaryBtnBgd};- border-radius: 18px;- border: 0;- box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.16);- color: ${props =>- props.active- ? props.theme.secondaryBtnActColor- : props.theme.secondaryBtnColor};- cursor: pointer;- display: flex;- height: 36px;- justify-content: center;- margin: 0;- outline: none;- padding: 0;- transition: ${props => props.theme.transition};- width: 36px;-- :focus {- outline: none;- }-- :hover {- cursor: pointer;- background-color: ${props => props.theme.secondaryBtnActBgd};- color: ${props => props.theme.secondaryBtnActColor};- }-`;-const StyledMapControlPanel = styled.div`background-color: ${props => props.theme.mapPanelBackgroundColor};flex-grow: 1;@@ -132,7 +98,7 @@ const LayerSelectorPanel = ({toggleMenuPanel}) =>!isActive ? (- <StyledMapControlButton+ <MapControlButtonkey={1}onClick={e => {e.preventDefault();@@ -147,7 +113,7 @@ const LayerSelectorPanel = ({id="toggle-layer"message={isActive ? 'Hide layer panel' : 'Show layer panel'}/>- </StyledMapControlButton>+ </MapControlButton>) : (<MapControlPanel header="Visible layers" onClick={toggleMenuPanel}><MapLayerSelector layers={items} onMapToggleLayer={onMapToggleLayer} />@@ -179,7 +145,7 @@ const MapControlPanel = ({children, header, onClick, scale = 1, isExport}) => (const MapLegendPanel = ({layers, isActive, scale, toggleMenuPanel, isExport}) =>!isActive ? (- <StyledMapControlButton+ <MapControlButtonkey={2}data-tipdata-for="show-legend"@@ -191,7 +157,7 @@ const MapLegendPanel = ({layers, isActive, scale, toggleMenuPanel, isExport}) =>><Legend height="22px" /><MapLegendTooltip id="show-legend" message={'show legend'} />- </StyledMapControlButton>+ </MapControlButton>) : (<MapControlPanelscale={scale}@@ -270,14 +236,12 @@ const MapControlFactory = () => {splitMap = {}} = mapControls;- // const items = this.initialDataSelector(this.props);-return (<StyledMapControl className="map-control">{/* Split Map */}{splitMap.show && readOnly !== true ? (<ActionPanel key={0}>- <StyledMapControlButton+ <MapControlButtonactive={isSplit}onClick={e => {e.preventDefault();@@ -295,7 +259,7 @@ const MapControlFactory = () => {isSplit ? 'Close current panel' : 'Switch to dual map view'}/>- </StyledMapControlButton>+ </MapControlButton></ActionPanel>) : null}@@ -314,7 +278,7 @@ const MapControlFactory = () => {{/* 3D Map */}{toggle3d.show ? (<ActionPanel key={2}>- <StyledMapControlButton+ <MapControlButtononClick={e => {e.preventDefault();onTogglePerspective();@@ -329,7 +293,7 @@ const MapControlFactory = () => {id="action-3d"message={dragRotate ? 'Disable 3D Map' : '3D Map'}/>- </StyledMapControlButton>+ </MapControlButton></ActionPanel>) : null}