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
12 changes: 9 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import React, { Component } from 'react';
import './App.css';
import timelineData from './data/timeline.json';

import Timeline from './components/Timeline';

class App extends Component {
render() {
console.log(timelineData);
const timelineObjects = timelineData.events.map((timelineObject, i) => {
return {
time: timelineObject.timeStamp,
person: timelineObject.person,
status: timelineObject.status,
};
});

Choose a reason for hiding this comment

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

You might be able to pass the props to Timeline without mapping the data.


// Customize the code below
return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Application title</h1>
<h1 className="App-title">Super Awesome Timeline</h1>
</header>
<main className="App-main">
<Timeline events={timelineObjects} />

Choose a reason for hiding this comment

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

Nice work passing the prop to the Timeline component

</main>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/Timeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
width: 30%;
margin: auto;
text-align: left;

}

ul{
list-style: none;
}
18 changes: 14 additions & 4 deletions src/components/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import React from 'react';
import './Timeline.css';
import TimelineEvent from './TimelineEvent';

const Timeline = () => {
// Fill in your code here
return;
}
const Timeline = events => {
const TimelineEvents = events.events.map(eventObject => {
return (
<li>
<TimelineEvent
person={eventObject.person}
status={eventObject.status}
time={eventObject.time}
/>
</li>
);
});
return <ul className="Timeline">{TimelineEvents}</ul>;
};

export default Timeline;
6 changes: 6 additions & 0 deletions src/components/TimelineEvent.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
padding: 0.5rem;
border-bottom: 1px solid #E6ECF0;
background-color: #FFF;
margin-right: 2.5em;
width: 700px;
}

.timeline-event:hover {
Expand All @@ -25,3 +27,7 @@
margin-top: 0.5rem;
text-align: right;
}

h1 {
font-size: 1em;
}
19 changes: 15 additions & 4 deletions src/components/TimelineEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ import React from 'react';
import './TimelineEvent.css';
import Timestamp from './Timestamp';

const TimelineEvent = () => {
// Fill in your code here
return;
}
const TimelineEvent = prop => {
return (
<section className="timeline-event">
<div className="event-person ">
<h1>{prop.person}</h1>
</div>
<div className="event-status ">
<p>{prop.status}</p>
</div>
<div className="event-time ">
<Timestamp time={prop.time} />
</div>
</section>
);

Choose a reason for hiding this comment

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

Great use of semantic HTML on this component 👍

};

export default TimelineEvent;
6 changes: 2 additions & 4 deletions src/components/Timestamp.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from 'react';
import moment from 'moment';

const Timestamp = (props) => {
const Timestamp = props => {
const time = moment(props.time);
const absolute = time.format('MMMM Do YYYY, h:mm:ss a');
const relative = time.fromNow();

return (
<span title={absolute}>{relative}</span>
);
return <span title={absolute}>{relative}</span>;
};

export default Timestamp;