-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplates.js
88 lines (82 loc) · 3.6 KB
/
templates.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
function sharedLayout(bodyContent) {
return `<!DOCTYPE html>
<html lang="en">
<head>
<title>Recipes Project</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel='stylesheet' href="public/style.css"
</head>
<body>${bodyContent}</body>
</html>
`;
}
function home() {
return sharedLayout(`
<div class="home_wrapper">
<h1 class="title">Cookvid-19</h1>
<p class="tagline"> Can't rely on Deliveroo or Ubereats no more? Have no fear, Cookvid has your back with some recipes</p>
<section class="links-wrapper">
<a class="links-wrapper__form" href="/form">Write A Recipe!</a>
<a class="links-wrapper__recipes" href="/breakfast" aria-label="Breakfast recipes">Breakfast!</a>
<a class="links-wrapper__recipes" href="/lunch" aria-label="Lunch recipes">Lunch!</a>
<a class="links-wrapper__recipes" href="/dinner" aria-label="Dinner recipes">Dinner!</a>
<a class="links-wrapper__recipes" href="/dessert" aria-label="Dessert recipes">Dessert!</a>
<a class="links-wrapper__recipes" href="/snacks" aria-label="Snack recipes">Snacks!</a>
</section>
<footer aria-label="contact-details">
<p>Bought to you by Team EIJO</p>
</footer>
</div>
`);
}
function form() {
return sharedLayout(`
<section>
<form class="form" id="form" action="/submit" method="POST">
<a class="link__home" href="/">Back to Home Page!</a>
<label class="form__label" for="recipeTitle">Recipe Title:</label>
<input class="form__input" id="recipeTitle" type="text" name="recipeTitle" placeholder="Pizza" required>
<label class="form__label" for="recipeCategory">Choose a category:</label>
<select id="recipeCategory" class="recipe__category" name="type" required>
<option value="breakfast">Breakfast</option>
<option value="lunch">Lunch</option>
<option value="dinner">Dinner</option>
<option value="snacks">Snacks</option>
<option value="desserts">Desserts</option>
</select>
<label class="form__label" for="ingredients">Ingredients:</label>
<textarea class="form__textbox" id="ingredients" form="form" name="ingredients" placeholder="1 egg" required></textarea>
<label class="form__label" for="ingredients">Method:</label>
<textarea class="form__textbox" form="form" id="method" name="method" placeholder="oven it" required></textarea>
<label class="form__label" for="vegetarian">Vegetarian:</label>
<select id="vegetarian" name="vegetarian" class= "dietary__req" required>
<option value="true">yes</option>
<option value="false">no</option>
</select>
<button class="form__button" aria-label="button to add recipe" type="submit">Add Recipe!</button>
</form>
</section>
`);
}
function createRecipes(posts) {
let str = "";
posts.map(item => {
return (str += `<section class='recipe__card'>
<h1 class='recipe__card-title'>${item.recipetitle}</h1>
<h2 class='recipe__card-subtitle'>Ingredients</h2>
<p class='recipe__card-subtext'>${item.ingredients}</p>
<h2 class='recipe__card-subtitle'>Method</h2>
<p class='recipe__card-subtext'>${item.method}</p>
<a class="link__home" href="/">Back to Home Page!</a>
<a class="link__form" href="/form">Write A Recipe!</a>
<i class="fas fa-seedling"></i>
</section>`);
});
return sharedLayout(str);
}
module.exports = {
home,
form,
createRecipes
};