diff --git a/package.json b/package.json index c5d556e..45e07bd 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "marked": "^0.6.0", "normalizr": "^3.2.3", "object-hash": "^1.3.0", + "ramda": "^0.26.1", "react": "^16.6.3", "react-dom": "^16.6.3", "react-image": "^1.5.1", diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index e0a59aa..5b97b57 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -60,8 +60,8 @@ class Dashboard extends React.Component { } } - getCategoryColor(category='other') { - return this.props.ui.style.categories[category] || this.props.ui.style.categories['other'] + getCategoryColor(category) { + return this.props.ui.style.categories[category] || this.props.ui.style.categories['default'] } getNarrativeLinks(event) { diff --git a/src/components/Timeline.jsx b/src/components/Timeline.jsx index 5c42e17..8d7104b 100644 --- a/src/components/Timeline.jsx +++ b/src/components/Timeline.jsx @@ -20,6 +20,7 @@ class Timeline extends React.Component { super(props); this.styleDatetime = this.styleDatetime.bind(this) this.getDatetimeX = this.getDatetimeX.bind(this) + this.onApplyZoom = this.onApplyZoom.bind(this) this.svgRef = React.createRef() this.state = { isFolded: false, @@ -99,6 +100,7 @@ class Timeline extends React.Component { * Returns the time scale (x) extent in minutes */ getTimeScaleExtent() { + if (!this.state.scaleX) return 0 const timeDomain = this.state.scaleX.domain(); return (timeDomain[1].getTime() - timeDomain[0].getTime()) / 60000; } @@ -153,7 +155,7 @@ class Timeline extends React.Component { this.setState({ timerange: [domain0, domainF] }, () => { this.props.methods.onUpdateTimerange(this.state.timerange); - }); + }); } /** @@ -284,9 +286,10 @@ class Timeline extends React.Component { onMoveTime={(dir) => { this.onMoveTime(dir) }} /> { this.onApplyZoom(zoom); }} + onApplyZoom={this.onApplyZoom} /> - + ); } } -export default TimelineAxis; \ No newline at end of file +export default TimelineAxis; diff --git a/src/components/TimelineCategories.jsx b/src/components/TimelineCategories.jsx index c90697c..25dce29 100644 --- a/src/components/TimelineCategories.jsx +++ b/src/components/TimelineCategories.jsx @@ -59,4 +59,4 @@ class TimelineCategories extends React.Component { } } -export default TimelineCategories; \ No newline at end of file +export default TimelineCategories; diff --git a/src/components/presentational/TimelineZoomControls.js b/src/components/presentational/TimelineZoomControls.js index 9b4f6c2..3c0a564 100644 --- a/src/components/presentational/TimelineZoomControls.js +++ b/src/components/presentational/TimelineZoomControls.js @@ -1,11 +1,11 @@ import React from 'react'; -const TimelineZoomControls = ({ zoomLevels, dims, onApplyZoom }) => { - +const TimelineZoomControls = ({ extent, zoomLevels, dims, onApplyZoom }) => { function renderZoom(zoom, idx) { + const isActive = (zoom.duration === extent) return ( onApplyZoom(zoom)} @@ -22,4 +22,4 @@ const TimelineZoomControls = ({ zoomLevels, dims, onApplyZoom }) => { ); } -export default TimelineZoomControls; \ No newline at end of file +export default TimelineZoomControls; diff --git a/src/store/initial.js b/src/store/initial.js index dbfbd19..e517108 100644 --- a/src/store/initial.js +++ b/src/store/initial.js @@ -1,3 +1,5 @@ +import { mergeDeepLeft } from 'ramda' + const initial = { /* * The Domain or 'domain' of this state refers to the tree of data @@ -51,45 +53,18 @@ const initial = { sites: true }, }, - base_uri: 'http://127.0.0.1:8000/', // Modify accordingly on production setup. isMobile: (/Mobi/.test(navigator.userAgent)), language: 'en-US', - mapAnchor: process.env.MAP_ANCHOR, - zoomLevels: [{ - label: '3 years', - duration: 1576800, - active: false - }, - { - label: '3 months', - duration: 129600, - active: false - }, - { - label: '3 days', - duration: 4320, - active: false - }, - { - label: '12 hours', - duration: 720, - active: false - }, - { - label: '2 hours', - duration: 120, - active: false - }, - { - label: '30 min', - duration: 30, - active: false - }, - { - label: '10 min', - duration: 10, - active: false - }], + mapAnchor: [31.356397, 34.784818], + zoomLevels: [ + { label: '3 years', duration: 1576800 }, + { label: '3 months', duration: 129600 }, + { label: '3 days', duration: 4320 }, + { label: '12 hours', duration: 720 }, + { label: '2 hours', duration: 120 }, + { label: '30 min', duration: 30 }, + { label: '10 min', duration: 10 } + ], flags: { isFetchingDomain: false, isFetchingSources: false, @@ -108,30 +83,13 @@ const initial = { ui: { style: { categories: { - default: 'yellow', - // Add here other categories to differentiate by color, like: - alpha: '#00ff00', - beta: '#ff0000', - other: '#f3de2c' + default: '#f3de2c', }, narratives: { default: { opacity: 0.9, stroke: 'red', strokeWidth: 3 - }, - narrative_1: { - opacity: 0.4, - stroke: '#f18f01', - strokeWidth: 3 - }, - // process.env.features.NARRATIVE_STEP_STYLES - stepStyles: { - Physical: { - stroke: 'yellow', - strokeWidth: 3, - opacity: 0.9, - } } } }, @@ -143,4 +101,10 @@ const initial = { } }; -export default initial; +let appStore; +if (process.env.store) { + appStore = mergeDeepLeft(process.env.store, initial); +} else { + appStore = initial +} +export default appStore diff --git a/yarn.lock b/yarn.lock index 9f5e536..7b7a92e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5059,6 +5059,10 @@ quick-lru@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" +ramda@^0.26.1: + version "0.26.1" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06" + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: version "2.0.6" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.0.6.tgz#d302c522948588848a8d300c932b44c24231da80"