Skip to content

Commit 6b4f78a

Browse files
committed
Refactor thoughts list to display date, style and sort by date
1 parent d3c8043 commit 6b4f78a

File tree

2 files changed

+50
-22
lines changed

2 files changed

+50
-22
lines changed

components/Thoughts.js

+29-10
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,51 @@ import { thoughts } from '../data/thoughts.json'
88
const Title = styled.h3`
99
cursor: pointer;
1010
margin: 0 auto;
11-
font-size: 32px;
12-
font-weight: 400;
13-
14-
&:hover {
15-
font-weight: 800;
16-
}
17-
11+
font-size: 48px;
12+
font-weight: 700;
13+
line-height: 1.25;
14+
margin-top: 32px;
15+
margin-bottom: 16px;
1816
${media.phone`
1917
padding-left: 50px;
2018
`}
2119
`
2220

21+
const Date = styled.p`
22+
font-family: "SF Mono","Roboto Mono",Menlo,monospace;
23+
color: inherit;
24+
margin-right: 20px;
25+
${media.phone`
26+
margin-top: 10px;
27+
display: flex;
28+
float: right;
29+
`}
30+
`
31+
32+
const Container = styled.div`
33+
margin-bottom: 64px;
34+
`
35+
36+
const thoughtsByDate = thoughts.reverse()
37+
2338
export default () => (
2439
<Wrapper>
2540
{
26-
thoughts.map(({ id, title }) => (
41+
thoughtsByDate.map(({ id, title, date }) => (
2742
<Thoughts
2843
id={id}
2944
key={id}
3045
title={title}
46+
date={date}
3147
/>
3248
))
3349
}
3450
</Wrapper>
3551
)
3652

37-
const Thoughts = ({ id, title }) => (
38-
<Link prefetch href={`/thoughts/${id}`}><Title>{ title }</Title></Link>
53+
const Thoughts = ({ id, title, date }) => (
54+
<Container>
55+
<Link prefetch href={`/thoughts/${id}`}><Title>{ title }</Title></Link>
56+
<Date>{date}</Date>
57+
</Container>
3958
)

data/thoughts.json

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
{
22
"thoughts": [
3-
{
4-
"id": "why-programming",
5-
"title": "Why Programming"
6-
},
73
{
84
"id": "how-to-start-a-project",
9-
"title": "How to Start a Project"
5+
"title": "How to Start a Project",
6+
"date": "Nov 09 2017"
107
},
118
{
129
"id": "behind-the-scenes-a-sinatra-application",
13-
"title": "Behind the Scenes, a Sinatra Application"
10+
"title": "Behind the Scenes, a Sinatra Application",
11+
"date": "Dec 20 2017"
12+
},
13+
{
14+
"id": "why-programming",
15+
"title": "Why Programming",
16+
"date": "Feb 15 2018"
1417
},
1518
{
1619
"id": "friendly-urls-for-your-rails-app-with-friendlyId",
17-
"title": "Friendly URLs for your Rails App with FriendlyId"
20+
"title": "Friendly URLs for your Rails App with FriendlyId",
21+
"date": "Feb 23 2018"
1822
},
1923
{
2024
"id": "acts-as-votable-gem-for-rails-apps",
21-
"title": "Acts As Votable gem for Rails Apps"
25+
"title": "Acts As Votable gem for Rails Apps",
26+
"date": "Feb 23 2018"
2227
},
2328
{
2429
"id": "devise-and-omniauth-authentication-with-rails",
25-
"title": "Devise and OmniAuth Authentication with Rails"
30+
"title": "Devise and OmniAuth Authentication with Rails",
31+
"date": "Feb 23 2018"
2632
},
2733
{
2834
"id": "devit-on-rails",
29-
"title": "Devit on Rails"
35+
"title": "Devit on Rails",
36+
"date": "Feb 24 2018"
3037
},
3138
{
3239
"id": "rails-api-and-javascript",
33-
"title": "Rails API and JavaScript"
40+
"title": "Rails API and JavaScript",
41+
"date": "Mar 10 2018"
3442
},
3543
{
3644
"id": "react-redux-and-rails-api",
37-
"title": "React, Redux and Rails API"
45+
"title": "React, Redux and Rails API",
46+
"date": "May 07 2018"
3847
}
3948
]
4049
}

0 commit comments

Comments
 (0)