From 374f137c5083bc27f47641a8dc284df7a13de112 Mon Sep 17 00:00:00 2001 From: KatvonRivia Date: Tue, 4 Aug 2020 15:40:45 +0200 Subject: [PATCH 1/9] feat(welcomeScreen): add story markers to globe --- assets/images/marker.svg | 27 ++++++ src/scripts/actions/show-markers.ts | 13 +++ src/scripts/components/globe/globe.tsx | 6 ++ .../components/navigation/navigation.tsx | 6 +- src/scripts/custom.d.ts | 5 + src/scripts/hooks/use-markers.ts | 95 +++++++++++++++++++ src/scripts/reducers/index.ts | 4 +- src/scripts/reducers/show-markers.ts | 17 ++++ src/scripts/selectors/show-markers.ts | 5 + src/scripts/types/story-list.d.ts | 1 + storage/stories/stories-de.json | 41 ++++++-- storage/stories/stories-en.json | 41 ++++++-- 12 files changed, 239 insertions(+), 22 deletions(-) create mode 100644 assets/images/marker.svg create mode 100644 src/scripts/actions/show-markers.ts create mode 100644 src/scripts/hooks/use-markers.ts create mode 100644 src/scripts/reducers/show-markers.ts create mode 100644 src/scripts/selectors/show-markers.ts diff --git a/assets/images/marker.svg b/assets/images/marker.svg new file mode 100644 index 000000000..ec08015c4 --- /dev/null +++ b/assets/images/marker.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/scripts/actions/show-markers.ts b/src/scripts/actions/show-markers.ts new file mode 100644 index 000000000..4ff2dec4f --- /dev/null +++ b/src/scripts/actions/show-markers.ts @@ -0,0 +1,13 @@ +export const SHOW_MARKERS = 'SHOW_MARKERS'; + +export interface ShowMarkersAction { + type: typeof SHOW_MARKERS; + showMarkers: boolean; +} + +const showMarkersAction = (showMarkers: boolean): ShowMarkersAction => ({ + type: SHOW_MARKERS, + showMarkers +}); + +export default showMarkersAction; diff --git a/src/scripts/components/globe/globe.tsx b/src/scripts/components/globe/globe.tsx index f6191aff1..13702d593 100644 --- a/src/scripts/components/globe/globe.tsx +++ b/src/scripts/components/globe/globe.tsx @@ -1,4 +1,5 @@ import React, {FunctionComponent, useRef, useEffect, useState} from 'react'; +import {useSelector} from 'react-redux'; import 'cesium/Build/Cesium/Widgets/widgets.css'; import { Viewer, @@ -21,6 +22,8 @@ import {isElectron} from '../../libs/electron/index'; import {GlobeView} from '../../types/globe-view'; import {GlobeProjection} from '../../types/globe-projection'; import config from '../../config/main'; +import {useMarkers} from '../../hooks/use-markers'; +import {storyListSelector} from '../../selectors/story/list'; import {GlobeProjectionState} from '../../types/globe-projection-state'; import {BasemapId} from '../../types/basemap'; @@ -86,6 +89,7 @@ const Globe: FunctionComponent = ({ }) => { const [viewer, setViewer] = useState(null); const ref = useRef(null); + const stories = useSelector(storyListSelector); // make latest "active" value always accessible in camera change handler const isActiveRef = useRef(active); @@ -295,6 +299,8 @@ const Globe: FunctionComponent = ({ flyToGlobeView(viewer, flyTo); }, [viewer, flyTo]); + useMarkers(viewer, stories); + return (
{ const [showMenu, setShowMenu] = useState(false); @@ -27,7 +28,10 @@ const Navigation: FunctionComponent = () => {
{selectedMainLayer && ( diff --git a/src/scripts/components/navigation/navigation.tsx b/src/scripts/components/navigation/navigation.tsx index 535ccdf65..370501f30 100644 --- a/src/scripts/components/navigation/navigation.tsx +++ b/src/scripts/components/navigation/navigation.tsx @@ -9,7 +9,6 @@ import {StoryIcon} from '../icons/story-icon'; import showLayerSelectorAction from '../../actions/show-layer-selector'; import Share from '../share/share'; import {MenuIcon} from '../icons/menu-icon'; -import showMarkersAction from '../../actions/show-markers'; import styles from './navigation.styl'; @@ -28,10 +27,7 @@ const Navigation: FunctionComponent = () => {