-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-utils.js
110 lines (76 loc) · 2.71 KB
/
render-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
export function renderRegions(region) {
const div = document.createElement('div');
div.classList.add(`${region.name}`);
const a = document.createElement('a');
a.href = `./region-page/?id=${region.id}`;
const h2 = document.createElement('h2');
h2.textContent = region.name;
a.append(h2);
div.append(a);
return div;
}
export function renderRegionName(region) {
const div = document.createElement('div');
div.classList.add(`${region.name}`);
const h1 = document.createElement('h1');
h1.textContent = region.name;
div.append(h1);
return div;
}
export function renderTacoShops(shops) {
const div = document.createElement('div');
div.classList.add('shops');
const a = document.createElement('a');
a.href = `../shop-info/?id=${shops.id}`;
const h1 = document.createElement('h1');
h1.textContent = shops.name;
const img = document.createElement('img');
img.src = `../assets/${shops.image}.jpg`;
const h2 = document.createElement('h2');
h2.textContent = `${shops.rating} 🌮`;
div.append(h1, img, h2);
a.append(div);
return a;
}
export function renderReviews(user_review) {
const div = document.createElement('div');
div.classList.add('review');
const p = document.createElement('p');
p.textContent = `${user_review.content}`;
const span = document.createElement('span');
span.textContent = `${user_review.rating} 🌮`;
div.append(p, span);
return div;
}
export function renderShopInfo(shop_info) {
const div = document.createElement('div');
div.classList.add('shop');
const h2 = document.createElement('h2');
h2.textContent = shop_info.name;
const img = document.createElement('img');
img.src = `../assets/${shop_info.image}.jpg`;
const abouth4 = document.createElement('h4');
abouth4.textContent = shop_info.about;
const addressh3 = document.createElement('h3');
addressh3.textContent = shop_info.address;
const phoneh3 = document.createElement('h3');
phoneh3.textContent = shop_info.phone;
const menuA = document.createElement('a');
menuA.href = `${shop_info.menu}`;
menuA.textContent = `${shop_info.name} menu`;
div.append(h2, img, abouth4, addressh3, phoneh3, menuA,);
return div;
}
// export function renderHiddenForm() {
// }
export function renderPosts(post) {
// Renders the constantly displayed elements to the page
const div = document.createElement('div');
div.classList.add('community-post');
const p = document.createElement('p');
p.textContent = post.new_post;
const p2 = document.createElement('p');
p2.textContent = post.contact;
div.append(p, p2,);
return div;
}