-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
205 lines (196 loc) · 6.46 KB
/
index.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aeropress Recipe Generator</title>
<script src="https://unpkg.com/vue@3.4.0/dist/vue.global.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.7.0/dist/tabler-icons.min.css">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<script src="random_database.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
body {
display: flex;
flex-direction: column;
justify-content: space-between;
}
#app {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff; /* White background for the content area */
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.container {
display: flex;
flex-direction: column;
}
.title {
text-align: center;
margin-bottom: 20px;
font-size: 2rem;
color: #333;
}
.content {
text-align: center;
}
.button {
margin-top: 20px;
}
.icon {
display: block;
margin: 0 auto 20px;
width: 100px;
height: 100px;
}
.recipe-part {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 10px;
}
.recipe-part img {
width: 40px;
height: 40px;
margin-right: 10px;
}
.loading {
display: flex;
justify-content: center;
align-items: center;
height: 300px;
}
.loading img {
max-width: 100%;
max-height: 100%;
}
@media (max-width: 600px) {
.recipe-part {
flex-direction: column;
align-items: center;
}
.recipe-part img {
margin-right: 0;
margin-bottom: 5px;
}
}
#footer {
background-color: rgb(161, 161, 161);
text-align: center;
padding: 10px;
}
</style>
</head>
<body>
<section class="section">
<div class="container" id="app">
<!--<img src="aeropress-icon.webp" alt="Aeropress Icon" class="icon">-->
<a id="logo-link" href="./index.html"><img src="aeropress.png" alt="Aeropress Icon" class="icon" ></a>
<h1 class="title">Aeropress Recipe Generator</h1>
<div class="content">
<div v-if="loading" class="loading">
<img src="loading_kettle.gif" alt="Loading"><br />
</div>
<p v-if="loading">Hold tight, while we're brewing your fresh recipe for you!</p>
<div v-if="!loading && allVariablesSet">
<div class="recipe-part">
<img src="coffeebag.webp" alt="Coffee Bag Icon">
<p><strong>Recipe:</strong> {{ recipe }}</p>
</div>
<div class="recipe-part">
<img src="kettle.webp" alt="Kettle Icon">
<p><strong>Brew Temperature:</strong> {{ brewTemperature }}</p>
</div>
<div class="recipe-part">
<img src="time.webp" alt="Time Icon">
<p><strong>Grind Size and Brew Time:</strong> {{ grindSizeAndBrewTime }}</p>
</div>
<div class="recipe-part">
<img src="technique.webp" alt="Brew Technique Icon">
<p><strong>Brew Technique:</strong> {{ brewTechnique }}</p>
</div>
<div class="recipe-part">
<img src="stirring.webp" alt="Stirring Icon">
<p><strong>Stirring Technique:</strong> {{ stirringTechnique }}</p>
</div>
</div>
<p v-if="!loading && !allVariablesSet">
Welcome coffee lover! Ready to brew the perfect cup with your Aeropress? Click "Generate Recipe" to get started on a delightful coffee adventure!
</p>
</div>
<div class="field is-grouped is-grouped-centered" v-if="!loading">
<p class="control">
<button class="button is-primary" @click="generateRecipe" :disabled="loading"><i class="ti ti-arrows-shuffle"></i> Generate Random Recipe</button>
</p>
</div>
</div>
</section>
<div id="footer">
<p class="is-size-6">
The Aeropress Recipe Creator<br />
Inspired by <a href="https://web.archive.org/web/20171208104650/https://jimseven.com/2017/12/06/coffee-brewing-dice/">James Hoffman's recipe dice</a><br />
Made with ☕️ by <a href="https://github.com/tpei/aeropress_recipes">tpei</a><br />
Icon by <a href="https://www.flaticon.com/authors/lapiyee">Lapiyee</a>
</p>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
database: database,
recipe: '',
brewTemperature: '',
grindSizeAndBrewTime: '',
brewTechnique: '',
stirringTechnique: '',
loading: false
};
},
computed: {
allVariablesSet() {
return this.recipe && this.brewTemperature && this.grindSizeAndBrewTime && this.brewTechnique && this.stirringTechnique;
}
},
methods: {
getRandomElement(array) {
return array[Math.floor(Math.random() * array.length)];
},
generateRecipe() {
this.loading = true;
setTimeout(() => {
this.recipe = this.getRandomElement(this.database.coffeeToWater);
this.brewTemperature = this.getRandomElement(this.database.brewTemperature);
this.grindSizeAndBrewTime = this.getRandomElement(this.database.grindSizeAndBrewTime);
this.brewTechnique = this.getRandomElement(this.database.brewTechnique);
this.stirringTechnique = this.getRandomElement(this.database.stirringTechnique);
this.loading = false;
}, 1000); // Simulate loading time
}
}
}).mount('#app');
document.getElementById('logo-link').addEventListener('click', function(event) {
event.preventDefault();
window.location.href = this.href;
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});
</script>
</body>
</html>