Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit abe0f54

Browse files
committed
Add popular
1 parent 5413504 commit abe0f54

File tree

7 files changed

+61
-13
lines changed

7 files changed

+61
-13
lines changed

frontEnd/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<title>Student Saver</title>
8-
<link rel="icon" type="image/png" href="./src/images/favicon.jpg">
98
<link href="https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css" rel="stylesheet">
109
<link href="styles.css" rel="stylesheet" />
1110
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

frontEnd/src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var m = require("mithril");
2-
var sitesList = require("./views/sitesList");
32
var searchBar = require("./views/searchBar");
3+
var popular = require("./views/popular");
44
var addForm = require("./views/addForm");
55
var layout = require("./views/layout");
66

@@ -10,6 +10,11 @@ m.route(document.body, "/list", {
1010
return m(layout, m(searchBar))
1111
}
1212
},
13+
"/popular": {
14+
render: function() {
15+
return m(layout, m(popular))
16+
}
17+
},
1318
"/add": {
1419
render: function() {
1520
return m(layout, m(addForm))

frontEnd/src/models/sites.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ var sites = {
1313
})
1414
},
1515

16+
popular: [],
17+
loadPopular: function() {
18+
return m.request({
19+
method: "GET",
20+
url: "https://api.schroeff.com/sites",
21+
})
22+
.then(function(result) {
23+
sites.popular = result;
24+
console.log(sites.popular);
25+
})
26+
},
27+
1628
newSite: {},
1729
add: function(site) {
1830
return m.request({

frontEnd/src/views/layout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
m("div.inner", [
99
m("nav.nav nav-masthead justify-content-center", [
1010
m(m.route.Link, {href: "/list", class: 'nav-link' + (route === "/list" ? ' active' : '')}, "Zoeken"),
11+
m(m.route.Link, {href: "/popular", class: 'nav-link' + (route === "/popular" ? ' active' : '')}, "Populaire kortingen"),
1112
m(m.route.Link, {href: "/add", class: 'nav-link' + (route === "/add" ? ' active' : '')}, "Voeg korting toe")
1213
])
1314
])

frontEnd/src/views/popular.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var m = require("mithril");
2+
var sites = require("../models/sites");
3+
4+
module.exports = {
5+
oninit: function() {
6+
sites.loadPopular();
7+
},
8+
view: function() {
9+
return m("div.card-columns popular", sites.popular.map(function(site) {
10+
const thumbnail = site.thumbnail || 'https://seeklogo.net/wp-content/themes/seeklogo-2017/images/not-available.jpg';
11+
const title = site.product_name ? `${site.site_name}: ${site.product_name}` : site.site_name;
12+
const requirements =
13+
site.discount_requirements !== null
14+
? m('p.card-text', [
15+
m('b', 'Voorwaarden'),
16+
m('span', `: ${site.discount_requirements}`)])
17+
: null;
18+
const score = site.upvotes - site.downvotes;
19+
20+
return m('div.card', [
21+
m(`img[src=${thumbnail}].card-img-top .coupon-thumbnail`),
22+
m('div.card-body', [
23+
m(`a[href=${site.url}]`, m('h4.card-title', title)),
24+
m('p.card-text', site.description),
25+
requirements,
26+
m('div.card-footer', [
27+
`${score} punten`,
28+
]),
29+
])
30+
]);
31+
}));
32+
}
33+
};

frontEnd/src/views/sitesList.js

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

frontEnd/styles.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ body {
3939
justify-content: center;
4040
color: #fff;
4141
text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
42-
box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
42+
/*box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);*/
4343
}
4444

4545
.cover-container {
@@ -111,7 +111,7 @@ body {
111111
}
112112

113113
main {
114-
width: 50%;
114+
width: 60%;
115115
margin: 0 auto;
116116
}
117117

@@ -145,3 +145,10 @@ main {
145145
border-radius: 0px 30px 30px 0px;
146146
}
147147

148+
.card {
149+
background: #262626 !important;
150+
}
151+
152+
.popular {
153+
margin-top: 2em;
154+
}

0 commit comments

Comments
 (0)