Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, { Component } from 'react';
import './App.css';
import timelineData from './data/timeline.json';

import Timeline from './components/Timeline';

const postEvents = () => {
return <Timeline events={timelineData["events"]} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great separation of your logic!

};

class App extends Component {
render() {
console.log(timelineData);

// Customize the code below

return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Application title</h1>
</header>
<main className="App-main">
{ postEvents() }
</main>
</div>
);
Expand Down
19 changes: 15 additions & 4 deletions src/components/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ import React from 'react';
import './Timeline.css';
import TimelineEvent from './TimelineEvent';

const Timeline = () => {
// Fill in your code here
return;
}
const postData = (events) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section of code is very clean and readable!

return events.map((post) => {
return (
<TimelineEvent person={ post.person } status={ post.status } timestamp={ post.timeStamp } />
)
})
}
const Timeline = (props) => {
return (
<section>
{ postData(props.events) }
</section>
)
}

export default Timeline;
/* <p>key={i}</p> */
23 changes: 19 additions & 4 deletions src/components/TimelineEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ import React from 'react';
import './TimelineEvent.css';
import Timestamp from './Timestamp';

const TimelineEvent = () => {
// Fill in your code here
return;
const postTimestamp = (props) => {
return <Timestamp time={props} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome separation of logic again!

}

export default TimelineEvent;
const TimelineEvent = (props) => {
return(
<section>
<h3>
Person: {props.person}
</h3>
<p>
Status: {props.status}
</p>
<p>
Timestamp: { postTimestamp(props.timestamp) }
</p>
</section>
)
}

export default TimelineEvent;
1 change: 1 addition & 0 deletions src/components/Timestamp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import moment from 'moment';
import './TimelineEvent.js';

const Timestamp = (props) => {
const time = moment(props.time);
Expand Down