diff --git a/src/app/components/App.jsx b/src/app/components/App.jsx
index 7b84e7e..2699c6b 100644
--- a/src/app/components/App.jsx
+++ b/src/app/components/App.jsx
@@ -40,7 +40,8 @@ class App extends Component {
};
this.addActionToView = this.addActionToView.bind(this);
- // this.toTheFuture = this.toTheFuture.bind(this);
+ this.toTheFuture = this.toTheFuture.bind(this);
+ this.toThePast = this.toThePast.bind(this);
}
componentDidMount() {
@@ -74,24 +75,42 @@ class App extends Component {
}
// function to travel to the FUTURE
- // **** not being passed to any children yet
- // toTheFuture(e) {
- // if (this.state.action) {
- // for (let i = 0; i < data.length - 1; i += 1) {
- // // clicking next returns next piece of data
- // if (data[i].id === this.state.id) {
- // const { action, id, payload, state } = data[i + 1];
- // this.setState({action, id, payload, state});
- // }
- // // if we're at the last action stop there
- // // don't let user go any further
- // if (data[i].id === undefined) {
- // const { action, id, payload, state } = data[data.length -1 ];
- // this.setState({action, id, payload, state});
- // }
- // }
- // }
- // }
+ toTheFuture(e) {
+ if (this.state.action) {
+ for (let i = 0; i < data.length - 1; i += 1) {
+ // clicking next returns next piece of data
+ if (data[i].id === this.state.id) {
+ const { action, id, payload, state } = data[i + 1];
+ this.setState({action, id, payload, state});
+ }
+ // if we're at the last action stop there
+ // don't let user go any further
+ if (data[i].id === undefined) {
+ const { action, id, payload, state } = data[data.length -1 ];
+ this.setState({action, id, payload, state});
+ }
+ }
+ }
+ }
+
+ // function to travel to the PAST
+ toThePast(e) {
+ if (this.state.action) {
+ for (let i = data.length - 1; i >= 0; i -= 1) {
+ // clicking next returns next piece of data
+ if (data[i].id === this.state.id) {
+ const { action, id, payload, state } = data[i - 1];
+ this.setState({action, id, payload, state});
+ }
+ // if we're at the last action stop there
+ // don't let user go any further
+ if (this.state.action === undefined) {
+ const { action, id, payload, state } = data[0];
+ this.setState({action, id, payload, state});
+ }
+ }
+ }
+ }
render() {
const {
@@ -102,8 +121,14 @@ class App extends Component {
- }
+ (
+
+ )}
right={
(
);
}
-}
+ }
export default App;
diff --git a/src/app/components/EventCards/EventCreator.jsx b/src/app/components/EventCards/EventCreator.jsx
index b673d83..39da857 100644
--- a/src/app/components/EventCards/EventCreator.jsx
+++ b/src/app/components/EventCards/EventCreator.jsx
@@ -5,7 +5,6 @@ import { EventCard, EventTimeDiv } from '../../styles/Events.jsx';
export default function EventCreator(props) {
// renders individual action
const { action, id, addAction, actionTime } = props;
- console.log(EventCard);
return (
☰ {action}
diff --git a/src/app/components/EventCards/EventsDisplay.jsx b/src/app/components/EventCards/EventsDisplay.jsx
index 3338e84..0e7e180 100644
--- a/src/app/components/EventCards/EventsDisplay.jsx
+++ b/src/app/components/EventCards/EventsDisplay.jsx
@@ -2,14 +2,10 @@ import React, { useContext, useState } from 'react';
// components import
import EventCreator from './EventCreator.jsx';
-import TimeTravel from './TimeTravel.jsx';
// styled components import
import { EventsWrapper } from '../../styles/Events.jsx';
-// data context import
-import { DataContext } from '../../index.js'
-
export default function Events(props) {
return (
@@ -22,7 +18,6 @@ export default function Events(props) {
/>
))}
{/* time travel doesn't work yet */}
-
);
}
diff --git a/src/app/components/EventCards/TimeTravel.jsx b/src/app/components/EventCards/TimeTravel.jsx
index ea85ba0..ddc5b9e 100644
--- a/src/app/components/EventCards/TimeTravel.jsx
+++ b/src/app/components/EventCards/TimeTravel.jsx
@@ -1,10 +1,14 @@
import React from 'react';
+// styled component
+import { TimeTravelContainer, EventTimeDiv } from '../../styles/Events.jsx';
+
export default function TimeTavel(props) {
+ const { toTheFuture, toThePast } = props;
return (
-
- PREVIOUS
- NEXT
-
+
+ PREVIOUS
+ NEXT
+
);
}
diff --git a/src/app/container/Details.jsx b/src/app/container/Details.jsx
index 0e1bd64..28800bb 100644
--- a/src/app/container/Details.jsx
+++ b/src/app/container/Details.jsx
@@ -19,7 +19,7 @@ export default function Details(props) {
// destructuring required info that's being passed down from App.jsx
// passing these props onto children
const {
- action, id, payload, actionState,
+ action, id, actionState,
} = props;
return (
@@ -30,7 +30,7 @@ export default function Details(props) {
{/* routing components and rendering them with props */}
}
+ render={props => }
/>
+
>
);
}
diff --git a/src/app/styles/Events.jsx b/src/app/styles/Events.jsx
index cc7600b..db4ef63 100644
--- a/src/app/styles/Events.jsx
+++ b/src/app/styles/Events.jsx
@@ -5,7 +5,7 @@ export const EventsWrapper = styled.div`
/* margin: 17px 17px; */
/* padding-top: 2%; */
/* padding-bottom: 2%; */
- height: 79%;
+ max-height: 300px;
overflow: auto;
`;
@@ -40,3 +40,10 @@ export const EventTimeDiv = styled.div`
border-radius: 5px;
/* border: 1px solid black; */
`;
+
+export const TimeTravelContainer = styled.div`
+ border-top: 1px solid white;
+ padding-top: 5%;
+ display: flex;
+ justify-content: space-evenly;
+`;