Skip to content

Commit 5f091b9

Browse files
author
Evan You
committed
complete with more features
1 parent b2cf0c0 commit 5f091b9

File tree

7 files changed

+379
-148
lines changed

7 files changed

+379
-148
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Vue.js HackerNews clone
22

3-
[See it here](http://yyx990803.github.io/vue-hackernews/)
3+
[Live demo](http://yyx990803.github.io/vue-hackernews/)
44

5-
Built with [Vue.js](http://vuejs.org) and the HackerNews Firebase API. Very much a proof of concept hack at the moment - will organize the code a bit when I get time later.
5+
Built with [Vue.js](http://vuejs.org) and the official [HackerNews API](https://github.com/HackerNews/API), with pagination, comments, user profile, realtime updates, responsive layout, totaling ~140 SLOC JavaScript excluding comments.
6+
7+
## Notes
8+
9+
- I've intentionally avoided using build tools because the whole thing is pretty simple.
10+
11+
- The HN API currently only provides the top 100 stories, hence there are only 4 pages available.
12+
13+
- The HN API doesn't provide the recursive comments count for each story, so it's not displayed.
14+
15+
- There's no login functionality, i.e. it's view-only mode.

css/style.css

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ul {
1010
margin: 5px 0;
1111
}
1212
a {
13+
color: #000;
1314
cursor: pointer;
1415
text-decoration: none;
1516
}
@@ -36,9 +37,6 @@ a {
3637
vertical-align: middle;
3738
margin: 0;
3839
}
39-
#header h1 a {
40-
color: #000;
41-
}
4240
#yc {
4341
border: 1px solid #fff;
4442
margin: 2px;
@@ -57,41 +55,41 @@ a {
5755
color: #fff;
5856
margin-right: 10px;
5957
}
60-
li.story {
58+
.story {
6159
padding: 2px 0 2px 40px;
6260
position: relative;
6361
transition: background-color 0.2s ease;
6462
}
65-
li.story p {
63+
.story p {
6664
margin: 2px 0;
6765
}
68-
li.story .title {
69-
color: #000;
70-
}
71-
li.story .title:visited {
66+
.story .title:visited {
7267
color: #828282;
7368
}
74-
li.story .index {
69+
.story .index {
7570
color: #828282;
7671
position: absolute;
7772
width: 30px;
7873
text-align: right;
7974
left: 0;
8075
top: 4px;
8176
}
82-
li.story .domain,
83-
li.story .subtext {
84-
font-size: 0.75em;
77+
.story .domain,
78+
.story .subtext {
79+
font-size: 11px;
8580
color: #828282;
8681
}
87-
li.story .subtext a:hover {
82+
.story .domain a,
83+
.story .subtext a {
84+
color: #828282;
85+
}
86+
.story .subtext a:hover {
8887
text-decoration: underline;
8988
}
90-
li.story.current {
89+
.story.current {
9190
background-color: #ededdf;
9291
}
9392
.sidebar {
94-
color: #828282;
9593
transition: all 0.3s ease;
9694
position: fixed;
9795
right: 0;
@@ -100,7 +98,7 @@ li.story.current {
10098
background-color: #f6f6ef;
10199
box-shadow: 0 0 8px rgba(0,0,0,0.15);
102100
overflow-y: scroll;
103-
width: 500px;
101+
width: 600px;
104102
box-sizing: border-box;
105103
padding: 10px 30px;
106104
}
@@ -109,12 +107,16 @@ li.story.current {
109107
top: 0;
110108
right: 0;
111109
padding: 10px;
110+
font-size: 20px;
112111
}
113112
.sidebar.v-enter,
114113
.sidebar.v-leave {
115114
-webkit-transform: translate3d(100%, 0, 0);
116115
transform: translate3d(100%, 0, 0);
117116
}
117+
.sidebar.user {
118+
color: #828282;
119+
}
118120
.sidebar.user li {
119121
margin: 5px 0;
120122
}
@@ -125,7 +127,36 @@ li.story.current {
125127
.sidebar.user .about {
126128
margin-top: 1em;
127129
}
128-
@media screen and (max-width: 500px) {
130+
.sidebar.user .links a {
131+
text-decoration: underline;
132+
}
133+
.sidebar.comments .story {
134+
padding-left: 0;
135+
margin-bottom: 30px;
136+
}
137+
.sidebar.comments .story .index,
138+
.sidebar.comments .story .comments-link {
139+
display: none;
140+
}
141+
.sidebar.comments .comhead {
142+
color: #828282;
143+
font-size: 11px;
144+
margin-bottom: 8px;
145+
}
146+
.sidebar.comments .comhead a {
147+
color: #828282;
148+
}
149+
.sidebar.comments .comment {
150+
margin-bottom: 20px;
151+
}
152+
.sidebar.comments .comment p {
153+
margin: 8px 0 0;
154+
font-size: 12px;
155+
}
156+
.sidebar.comments .child-comments {
157+
margin: 8px 0 8px 20px;
158+
}
159+
@media screen and (max-width: 600px) {
129160
.sidebar {
130161
width: 100%;
131162
}

css/style.styl

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ul
1212
margin 5px 0
1313

1414
a
15+
color #000
1516
cursor pointer
1617
text-decoration none
1718

@@ -36,8 +37,6 @@ a
3637
display inline-block
3738
vertical-align middle
3839
margin 0
39-
a
40-
color #000
4140

4241
#yc
4342
border 1px solid #fff
@@ -55,15 +54,13 @@ a
5554
color #fff
5655
margin-right 10px
5756

58-
li.story
57+
.story
5958
padding 2px 0 2px 40px
6059
position relative
6160
transition background-color .2s ease
6261
p
6362
margin 2px 0
64-
.title
65-
color #000
66-
&:visited
63+
.title:visited
6764
color $gray
6865
.index
6966
color $gray
@@ -73,15 +70,16 @@ li.story
7370
left 0
7471
top 4px
7572
.domain, .subtext
76-
font-size .75em
73+
font-size 11px
7774
color $gray
75+
a
76+
color $gray
7877
.subtext a:hover
7978
text-decoration underline
8079
&.current
8180
background-color darken($bg, 5%)
8281

8382
.sidebar
84-
color $gray
8583
transition all .3s ease
8684
position fixed
8785
right 0
@@ -90,26 +88,53 @@ li.story
9088
background-color $bg
9189
box-shadow 0 0 8px rgba(0,0,0,.15)
9290
overflow-y scroll
93-
width 500px
91+
width 600px
9492
box-sizing border-box
9593
padding 10px 30px
9694
.close
9795
position absolute
9896
top 0
9997
right 0
10098
padding 10px
99+
font-size 20px
101100
&.v-enter, &.v-leave
102101
-webkit-transform translate3d(100%,0,0)
103102
transform translate3d(100%,0,0)
104-
&.user
105-
li
106-
margin 5px 0
107-
.label
108-
display inline-block
109-
min-width 60px
110-
.about
111-
margin-top 1em
112103

113-
@media screen and (max-width:500px)
104+
.sidebar.user
105+
color $gray
106+
li
107+
margin 5px 0
108+
.label
109+
display inline-block
110+
min-width 60px
111+
.about
112+
margin-top 1em
113+
.links a
114+
text-decoration underline
115+
116+
.sidebar.comments
117+
.story
118+
padding-left 0
119+
margin-bottom 30px
120+
.index, .comments-link
121+
display none
122+
.comhead
123+
color $gray
124+
font-size 11px
125+
margin-bottom 8px
126+
a
127+
color $gray
128+
.comment
129+
margin-bottom 20px
130+
p
131+
margin 8px 0 0
132+
font-size 12px
133+
.child-comments
134+
margin 8px 0 8px 20px
135+
136+
137+
138+
@media screen and (max-width:600px)
114139
.sidebar
115140
width 100%

0 commit comments

Comments
 (0)