From 5c026f12d885ab467a727d2d067ea19f3996e5e5 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Tue, 4 Dec 2018 11:26:21 +0000 Subject: [PATCH] move zoomLevels to redux --- src/components/Timeline.jsx | 6 +++++- src/js/timeline/timeline.js | 37 +------------------------------------ src/store/initial.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/components/Timeline.jsx b/src/components/Timeline.jsx index eaf6548..7451109 100644 --- a/src/components/Timeline.jsx +++ b/src/components/Timeline.jsx @@ -8,7 +8,9 @@ import TimelineLogic from '../js/timeline/timeline.js'; class Timeline extends React.Component { constructor(props) { super(props); - this.state = {isFolded: false}; + this.state = { + isFolded: false + }; } componentDidMount() { @@ -18,6 +20,7 @@ class Timeline extends React.Component { categories: this.props.categories } const app = { + zoomLevels: this.props.zoomLevels, timerange: this.props.timerange, selected: this.props.selected, language: this.props.language, @@ -106,6 +109,7 @@ function mapStateToProps(state) { language: state.app.language, tools: state.ui.tools, timerange: selectors.getTimeRange(state), + zoomLevels: state.app.zoomLevels, dom: state.ui.dom, selected: state.app.selected } diff --git a/src/js/timeline/timeline.js b/src/js/timeline/timeline.js index ba1d7df..82340ce 100644 --- a/src/js/timeline/timeline.js +++ b/src/js/timeline/timeline.js @@ -14,42 +14,7 @@ export default function(app, ui, methods) { d3.timeFormatDefaultLocale(esLocale); const formatterWithYear = ui.tools.formatterWithYear; const parser = ui.tools.parser; - const zoomLevels = [{ - label: '3 años', - duration: 1576800, - active: false - }, - { - label: '3 meses', - duration: 129600, - active: false - }, - { - label: '3 días', - duration: 4320, - active: true - }, - { - label: '12 horas', - duration: 720, - active: false - }, - { - label: '2 horas', - duration: 120, - active: false - }, - { - label: '30 min', - duration: 30, - active: false - }, - { - label: '10 min', - duration: 10, - active: false - }, - ]; + const zoomLevels = app.zoomLevels; let events = []; let categories = []; let selected = []; diff --git a/src/store/initial.js b/src/store/initial.js index 42197fc..635721e 100644 --- a/src/store/initial.js +++ b/src/store/initial.js @@ -46,6 +46,41 @@ const initial = { isMobile: (/Mobi/.test(navigator.userAgent)), language: 'en-US', mapAnchor: process.env.MAP_ANCHOR, + zoomLevels: [{ + label: '3 años', + duration: 1576800, + active: false + }, + { + label: '3 meses', + duration: 129600, + active: false + }, + { + label: '3 días', + duration: 4320, + active: true + }, + { + label: '12 horas', + duration: 720, + active: false + }, + { + label: '2 horas', + duration: 120, + active: false + }, + { + label: '30 min', + duration: 30, + active: false + }, + { + label: '10 min', + duration: 10, + active: false + }], features: { USE_TAGS: process.env.features.USE_TAGS, USE_SEARCH: process.env.features.USE_SEARCH