Skip to content

Commit 70cd947

Browse files
committed
Added Google Analytics, removed footer, added movies per #2, added keyboard navigation per #3, improved mobile styles
1 parent 391cc20 commit 70cd947

File tree

11 files changed

+133
-102
lines changed

11 files changed

+133
-102
lines changed

harp.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
"title": "Watchlist",
44
"githubURL": "https://github.com/pschfr/watchlist",
55
"movies": {
6+
"The Hills Have Eyes": { "watched": false },
7+
"EuroTrip": { "watched": true },
8+
"The Purge: Anarchy": { "watched": false },
9+
"The Visit": { "watched": false },
10+
"Edward Scissorhands": { "watched": false },
611
"Miss Peregrine's Home for Peculiar Children": { "watched": false },
7-
"Fear.com": { "watched": false },
12+
"FearDotcom": { "watched": false },
813
"The Belko Experiment": { "watched": true },
914
"Logan": { "watched": false },
1015
"Get Out": { "watched": true },
1116
"Beauty and the Beast": { "watched": false },
1217
"The Animatrix": { "watched": true },
1318
"The Matrix": { "watched": false },
14-
"Oliver and Company": { "watched": false },
19+
"Oliver and Company": { "watched": true },
1520
"Dreamgirls": { "watched": false },
1621
"The Five Heartbeats": { "watched": false },
17-
"Blade": { "watched": false },
22+
"Blade": { "watched": true },
1823
"Cats Don't Dance": { "watched": true },
1924
"The Boy in the Striped Pajamas": { "watched": false },
2025
"The Lovely Bones": { "watched": false },
@@ -37,13 +42,13 @@
3742
"Idiocracy": { "watched": true },
3843
"Beetlejuice": { "watched": true },
3944
"Step Brothers": { "watched": true },
40-
"AI": { "watched": true },
45+
"A.I. Artificial Intelligence": { "watched": true },
4146
"Queen of the Damned": { "watched": true },
4247
"Final Destination": { "watched": true },
4348
"Ex Machina": { "watched": true },
4449
"American Hustle": { "watched": true },
4550
"Josie and the Pussycats": { "watched": true },
46-
"Harold and Kumar": { "watched": true },
51+
"Harold and Kumar Go to White Castle": { "watched": true },
4752
"I, Robot": { "watched": true },
4853
"Scary Movie": { "watched": true },
4954
"Hostel II": { "watched": true },

public/_layout.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ html(lang="en")
1111
!= partial("_partials/_header")
1212
!= yield
1313
!= partial("_partials/_modal")
14-
!= partial("_partials/_footer")
1514
script(src=(environment == "production" ? "/watchlist/js/app.js" : "/js/app.js"))
15+
if environment === "production"
16+
!= partial("_partials/analytics")

public/_partials/_analytics.jade

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
script.
2+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
4+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
6+
7+
ga('create', 'UA-76037357-3', 'auto');
8+
ga('send', 'pageview');

public/_partials/_footer.jade

Lines changed: 0 additions & 5 deletions
This file was deleted.

public/_partials/_header.jade

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
header
2-
nav.navbar.navbar-inverse.navbar-fixed-top
3-
.container-fluid
4-
.row
5-
.col-xs-12
6-
h1 #{title}
7-
span.pull-right
8-
a(href="#{githubURL}" target="_blank")
9-
img(src=(environment == 'production' ? '/watchlist/svg/github.svg' : 'svg/github.svg'))
1+
nav.navbar.navbar-inverse.navbar-fixed-top
2+
.container-fluid
3+
.row
4+
.col-xs-12
5+
h1 #{title}
6+
span.pull-right
7+
a(href="https://www.themoviedb.org/" title="Data provided by The Movie Database" target="_blank" tabindex="-1")
8+
img(src=(environment == 'production' ? '/watchlist/svg/tmdb.svg' : 'svg/tmdb.svg'))
9+
|
10+
a(href="#{githubURL}" title="View the source on GitHub" target="_blank" tabindex="-1")
11+
img(src=(environment == 'production' ? '/watchlist/svg/github.svg' : 'svg/github.svg'))

public/js/app.coffee

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ listMovies = () ->
2121
localStorage.removeItem(event.target.name)
2222
event.target.parentElement.title = ''
2323
)
24+
# Press `Enter` when focused on an input to open the modal
25+
input.addEventListener('keyup', (event) ->
26+
if (event.keyCode == 13)
27+
document.querySelector('label[for="' + event.target.id + '"]').click()
28+
)
2429

2530
# Search The Movie Database - https://www.themoviedb.org/
2631
searchTMDb = (query) ->
@@ -37,29 +42,32 @@ searchTMDb = (query) ->
3742
document.getElementById('details').innerHTML = results[0].overview
3843
document.getElementById('rating').innerHTML = results[0].vote_average
3944
# Format date properly
40-
release_date = new Date(results[0].release_date)
45+
release_date = new Date(results[0].release_date.replace(/-/g, "/"))
4146
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
4247
document.getElementById('date').innerHTML = monthNames[release_date.getMonth()] + ' ' + release_date.getDate() + ', ' + release_date.getFullYear()
4348
# Append poster
44-
document.getElementById('poster').src = 'https://image.tmdb.org/t/p/w500/' + results[0].poster_path
49+
document.getElementById('poster').src = 'https://image.tmdb.org/t/p/w500' + results[0].poster_path
4550
# Background image
46-
document.getElementById('panel').style.backgroundImage = 'url("https://image.tmdb.org/t/p/w1280/' + results[0].backdrop_path + '")'
51+
document.getElementById('panel').style.backgroundImage = 'url("https://image.tmdb.org/t/p/w1280' + results[0].backdrop_path + '")'
4752
# Finds genre based on ID
4853
document.getElementById('genres').innerHTML = ''
4954
for genreID in results[0].genre_ids
5055
lookupGenre(genreID)
5156
# Toggles overlay open
5257
document.getElementById('overlay').classList.add('open')
58+
document.body.style.overflow = 'hidden'
5359
else
5460
document.getElementById('title').innerHTML = query
5561
document.getElementById('details').innerHTML = 'No results…'
5662
document.getElementById('rating').innerHTML = ''
5763
document.getElementById('date').innerHTML = ''
5864
document.getElementById('poster').src = ''
5965
document.getElementById('overlay').classList.add('open')
66+
document.body.style.overflow = 'hidden'
6067
# Bind click event to close overlay
6168
document.getElementById('overlay').addEventListener('click', (event) ->
6269
document.getElementById('overlay').classList.remove('open')
70+
document.body.style.overflow = null
6371
)
6472
xhr.send(null)
6573

@@ -82,5 +90,11 @@ findGenres = () ->
8290
lookupGenre = (genreID) ->
8391
document.getElementById('genres').innerHTML += '<span class="genre">' + localStorage.getItem('genre' + genreID) + '</span>'
8492

93+
# Press `Esc` to close modal
94+
document.onkeyup = (event) ->
95+
if (event.keyCode == 27)
96+
document.getElementById('overlay').classList.remove('open')
97+
98+
# Run everything on load
8599
findGenres()
86100
listMovies()

public/main.sass

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,112 @@
1-
@import 'sass/_bootstrap.scss'
21
@import 'sass/_mixins_variables.sass'
3-
4-
html
5-
position: relative
6-
min-height: 100%
2+
@import 'sass/_bootstrap.scss'
73

84
body
9-
font-family: $sans-font-family
10-
color: $dark-color
11-
margin-top: $footer-height * 2
12-
margin-bottom: $footer-height
5+
margin-top: 7rem
136

147
.navbar
158
color: $light-color
16-
margin-bottom: 0
9+
h1
10+
margin: 10px 0
11+
font-size: $medium-margin
1712
span
18-
img
19-
margin-top: -3px
20-
height: 36px
21-
22-
footer
23-
position: absolute
24-
bottom: 0
25-
width: 100%
26-
height: $footer-height
27-
background-color: transparentize($light-color, 0.75)
28-
p
29-
margin-bottom: 0
30-
line-height: $footer-height
31-
a
32-
color: inherit
13+
a
14+
margin-left: $tiny-margin
15+
img
16+
margin-top: -3px
17+
height: $medium-margin
3318

3419
.movie
35-
position: relative
36-
background-color: lighten($dark-color, 85%)
20+
background-color: lighten($text-color, 85%)
3721
display: inline-block
3822
margin: 0 0 7px
3923
padding: 4px 6px 6px 4px
4024
border-radius: 8px
41-
transition: all 0.15s
25+
transition: all 0.25s
4226
input[type="checkbox"], label
4327
vertical-align: middle
4428
cursor: pointer
4529
input[type="checkbox"]
4630
margin: 0 3px 0 0
4731
label
48-
display: inline
4932
margin: 0
5033
font-weight: normal
5134
user-select: none
5235
&[title="watched"]
5336
opacity: 0.5
5437

5538
#overlay
56-
position: absolute
39+
position: fixed
5740
top: 0
58-
left: 0
5941
width: 100%
6042
height: 100%
61-
display: none
43+
display: flex
44+
align-items: center
45+
visibility: hidden
46+
opacity: 0
47+
transition: all 0.75s 0.125s
6248
#modal
63-
flex: none
64-
.panel-body
65-
max-height: 450px
49+
.panel
6650
margin-bottom: 0
67-
color: $light-color
68-
background-size: cover
69-
a
70-
color: inherit
71-
.overlay
72-
position: fixed
73-
top: 0
74-
left: 0
75-
width: 100%
76-
height: 100%
77-
background-color: transparentize($dark-color, 0.25)
78-
#genres
79-
margin-bottom: $medium-margin
80-
.genre
81-
background-color: darken($light-color, 0.5)
82-
color: $dark-color
83-
margin-right: $tiny-margin
84-
padding: $tiny-margin
85-
border-radius: $tiny-margin
86-
font-weight: bold
87-
text-transform: uppercase
88-
img
89-
max-height: 420px
90-
width: 100%
91-
object-fit: contain
92-
&#star
93-
width: 16px
94-
margin-top: -$tiny-margin
95-
margin-right: $tiny-margin
96-
.row
97-
display: flex
98-
align-items: center
99-
p
100-
margin-bottom: $small-margin
101-
&#details
51+
.row
52+
display: flex
53+
align-items: center
54+
p
55+
margin-bottom: 0
56+
&#details
57+
margin-bottom: $medium-margin
58+
.panel-body
59+
max-height: 450px
60+
color: $light-color
61+
background-size: cover
62+
#title
63+
margin-top: 0
64+
a
65+
color: inherit
66+
.overlay
67+
position: fixed
68+
top: 0
69+
left: 0
70+
width: 100%
71+
height: 100%
72+
background-color: transparentize($text-color, 0.25)
73+
#genres
10274
margin-bottom: $medium-margin
75+
.genre
76+
background-color: darken($light-color, 0.5)
77+
color: $text-color
78+
margin-right: $tiny-margin
79+
padding: $tiny-margin
80+
border-radius: $tiny-margin
81+
font-weight: bold
82+
text-transform: uppercase
83+
img
84+
max-height: 420px
85+
width: 100%
86+
object-fit: contain
87+
&#star
88+
width: 16px
89+
margin-top: -$tiny-margin
90+
margin-right: $tiny-margin
10391
&.open
104-
display: flex
105-
align-items: center
92+
visibility: visible
93+
opacity: 1
94+
95+
@include media-query($medium-width)
96+
#overlay
97+
#modal
98+
width: 100%
99+
.panel
100+
.panel-body
101+
max-height: none
102+
img
103+
max-height: 210px
104+
#title
105+
font-size: 24px
106+
margin-top: 20px
107+
#genres, #details
108+
margin-bottom: $medium-margin / 2
109+
.row
110+
display: block
111+
.col-xs-4, .col-xs-8
112+
width: 100%

public/sass/_bootstrap.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*!
1+
/*
22
* Bootstrap v3.3.7 (http://getbootstrap.com)
33
* Copyright 2011-2016 Twitter, Inc.
44
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)

public/sass/_mixins_variables.sass

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
@media screen and (max-width: $width)
77
@content
88

9-
$sans-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif
10-
$serif-font-family: 'Palatino Linotype', 'Georgia', serif
9+
// See https://getbootstrap.com/customize/#less-variables
10+
$font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif
1111

12-
$dark-color: hsl(0, 0%, 05%)
12+
$text-color: hsl(0, 0%, 05%)
1313
$light-color: hsl(0, 0%, 95%)
1414
$muted-color: #777
1515

@@ -18,8 +18,6 @@ $medium-width: 768px
1818
$large-width: 992px
1919
$extra-width: 1200px
2020

21-
$footer-height: 4rem
22-
2321
$tiny-margin: 5px
2422
$small-margin: 15px
2523
$medium-margin: 30px

public/sass/bootstrap/_normalize.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
1+
/* normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
22

33
//
44
// 1. Set default font family to sans-serif.

public/svg/tmdb.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)