-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecipe-index.html
305 lines (267 loc) · 12.2 KB
/
recipe-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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
---
layout: default
title: Recipe Index
---
<style>
.pagination {
--bs-pagination-padding-x: 0.75rem;
--bs-pagination-padding-y: 0.375rem;
--bs-pagination-font-size: 1rem;
--bs-pagination-color: var(--bs-link-color);
--bs-pagination-bg: #fff;
--bs-pagination-border-width: 1px;
--bs-pagination-border-color: #dee2e6;
--bs-pagination-border-radius: 0.375rem;
--bs-pagination-hover-color: var(--bs-link-hover-color);
--bs-pagination-hover-bg: #e9ecef;
--bs-pagination-hover-border-color: #dee2e6;
--bs-pagination-focus-color: var(--bs-link-hover-color);
--bs-pagination-focus-bg: #e9ecef;
--bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
--bs-pagination-active-color: #fff;
--bs-pagination-active-bg: #0d6efd;
--bs-pagination-active-border-color: #0d6efd;
--bs-pagination-disabled-color: #6c757d;
--bs-pagination-disabled-bg: #fff;
--bs-pagination-disabled-border-color: #dee2e6;
display: flex;
padding-left: 0;
list-style: none;
}
.pagination li {
display:inline-block;
padding:5px;
}
.button:active,
.button.is-checked {
background-color: #28F;
}
.button.is-checked {
color: white;
/* text-shadow: 0 -1px hsla(0, 0%, 0%, 0.8); */
}
.button:active {
box-shadow: inset 0 1px 10px hsla(0, 0%, 0%, 0.8);
}
.ui-group h3 {
margin-right: 0.2em;
font-size: 16px;
}
</style>
<div class='d-flex align-items-center justify-content-between'>
<h1>{{page.title}}</h1>
<a href="{{ site.url }}"><span>Issues</span></a>
</div>
<div id="recipes" class="m-2 p-3">
<input type="text" class="quicksearch form-control" placeholder="Search" />
<!-- <div class="button-group filter-button-group justify-content-center">
<a class="btn btn-sm btn-primary" data-filter=".MainCourses">Mains</a>
<a class="btn btn-sm btn-primary" data-filter=".SideDishes">Sides</a>
<a class="btn btn-sm btn-primary active" data-filter="*">All</a>
</div> -->
<div class="d-flex flex-wrap filters pt-3 pb-3">
<div class="ui-group p-2">
<h3>Course</h3>
<div class="button-group js-radio-button-group" data-filter-group="color">
<button class="button is-checked btn btn-sm btn-light" data-filter="">any</button>
{% assign array_course_list = "" | split: "," %}
{% assign recipe_by_course = site.data.recipes | sort: "course_list" %}
{% for recipe in recipe_by_course %}
{% if recipe.course_list != "na" %}
{% assign array_course_list = array_course_list | push: recipe.course_list %}
{% endif %}
{% endfor %}
{% assign array_course = array_course_list | uniq %}
{% for course in array_course %}
<button class="button btn btn-sm btn-light" data-filter=".{{ course | remove: " " | replace: "&", "and" }}">{{course}}</button>
{% endfor %}
</div>
</div>
<div class="ui-group p-2">
<h3>Main Ingredient</h3>
<div class="button-group js-radio-button-group" data-filter-group="size">
<button class="button is-checked btn btn-sm btn-light" data-filter="">any</button>
{% assign array_ingredient = "" | split: "," %}
{% assign recipe_by_ingredient = site.data.recipes | sort: "main_ingredient_list" %}
{% for recipe in recipe_by_ingredient %}
{% if recipe.main_ingredient_list != "na" %}
{% assign array_ingredient = array_ingredient | push: recipe.main_ingredient_list %}
{% endif %}
{% endfor %}
{% assign array_ingred = array_ingredient | uniq %}
{% for ingredient in array_ingred %}
<button class="button btn btn-sm btn-light" data-filter=".{{ingredient | remove: " " | replace: "&", "and" }}">{{ingredient}}</button>
{% endfor %}
</div>
</div>
<div class="ui-group p-2">
<h3>Dish Type</h3>
<div class="button-group js-radio-button-group" data-filter-group="color">
<button class="button is-checked btn btn-sm btn-light" data-filter="">any</button>
{% assign array_dish_type = "" | split: "," %}
{% assign recipe_by_dish = site.data.recipes | sort: "dish_type_list" %}
{% for recipe in recipe_by_dish %}
{% if recipe.dish_type_list != "na" %}
{% assign array_dish_type = array_dish_type | push: recipe.dish_type_list %}
{% endif %}
{% endfor %}
{% assign array_dish = array_dish_type | uniq %}
{% for dish in array_dish %}
<button class="button btn btn-sm btn-light" data-filter=".{{ dish | remove: " " | replace: "&", "and" }}">{{dish}}</button>
{% endfor %}
</div>
</div>
<div class="ui-group p-2">
<h3>Recipe Type</h3>
<div class="button-group js-radio-button-group" data-filter-group="size">
<button class="button is-checked btn btn-sm btn-light" data-filter="">any</button>
{% assign array_recipe_type = "" | split: "," %}
{% assign recipe_by_type = site.data.recipes | sort: "recipe_type_list" %}
{% for recipe in recipe_by_type %}
{% if recipe.recipe_type_list != "na" %}
{% assign array_recipe_type = array_recipe_type | push: recipe.recipe_type_list %}
{% endif %}
{% endfor %}
{% assign array_recipe = array_recipe_type | uniq %}
{% for type in array_recipe %}
<button class="button btn btn-sm btn-light" data-filter=".{{ type | remove: " " | replace: "&", "and" }}">{{type}}</button>
{% endfor %}
</div>
</div>
<div class="ui-group p-2">
<h3>Cuisine</h3>
<div class="button-group js-radio-button-group" data-filter-group="size">
<button class="button is-checked btn btn-sm btn-light" data-filter="">any</button>
{% assign array_cuisine_list = "" | split: "," %}
{% assign recipe_by_cuisine = site.data.recipes | sort: "cuisine_list" %}
{% for recipe in recipe_by_cuisine %}
{% if recipe.cuisine_list != "na" %}
{% assign array_cuisine_list = array_cuisine_list | push: recipe.cuisine_list %}
{% endif %}
{% endfor %}
{% assign array_cuisine = array_cuisine_list | uniq %}
{% for cuisine in array_cuisine %}
<button class="button btn btn-sm btn-light" data-filter=".{{ cuisine | remove: " " | replace: "&", "and" }}">{{cuisine}}</button>
{% endfor %}
</div>
</div>
</div>
<ul class="grid list list-inline d-flex flex-wrap pt-3 pb-3">
{% assign recipe_by_title = site.data.recipes | sort: "title" %}
{% for recipe in recipe_by_title %}
{% if recipe.type == "recipes" %}
{% assign namepath = recipe.image_path | append: recipe.image_file %}
<li class="list-inline-item pb-2 {{ recipe.course_list | remove: " " }} {{ recipe.main_ingredient_list | remove: " " | replace: "&", "and" }} {{ recipe.cuisine_list | remove: " " | replace: "&", "and"}} {{ recipe.dish_type_list | remove: " " | replace: "&", "and" }} {{ recipe.recipe_type_list | remove: " " }}">
<!-- <a class="title" href="{{ recipe.title | datapage_url: 'recipes' }}">{{recipe.title}}</a> -->
<div class="card" style="max-width: 200px;">
<a class="title" href="{{ recipe.title | datapage_url: 'recipes' }}">
<img src="{{ namepath | prepend: site.url }}" class="card-img-top" alt="...">
</a>
<div class="card-body">
<a class="title" href="{{ recipe.title | datapage_url: 'recipes' }}">
<h5 class="card-title">{{recipe.title}}</h5> </a>
<p class="card-text">Issue {{ recipe.issue }}</p>
{% if recipe.course_list != "na" %}
<span class="card-text course_list"><small class="text-muted">{{ recipe.course_list }}</small></span>
{% endif %}
{% if recipe.cuisine_list != "na" %}
<span class="card-text cuisine_list"><small class="text-muted">{{ recipe.cuisine_list }}</small></span>
{% endif %}
{% if recipe.dish_type_list != "na" %}
<span class="card-text dish_type_list"><small class="text-muted">{{ recipe.dish_type_list }}</small></span>
{% endif %}
{% if recipe.main_ingredient_list != "na" %}
<span class="card-text main_ingredient_list"><small class="text-muted">{{ recipe.main_ingredient_list }}</small></span>
{% endif %}
{% if recipe.recipe_type_list != "na" %}
<span class="card-text recipe_type_list"><small class="text-muted">{{ recipe.recipe_type_list }}</small></span>
{% endif %}
</div>
</div>
</li>
{% endif %}{% endfor %}
</ul>
<!-- <nav aria-label="Page navigation">
<ul class="pagination"></ul>
</nav> -->
</div>
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src="https://unpkg.com/isotope-layout@3.0/dist/isotope.pkgd.js"></script>
<script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script>
// var $grid = $('.grid').imagesLoaded( function() {
// $grid.isotope({});
// });
// $('.filter-button-group').on( 'click', 'a', function() {
// var filterValue = $(this).attr('data-filter');
// $grid.isotope({ filter: filterValue });
// });
// $('.button-group a.btn').on('click', function(){
// $('.button-group a.btn').removeClass('active');
// $(this).addClass('active');
// });
// external js: isotope.pkgd.js
// quick search regex
var qsRegex;
// init Isotope
var $grid = $('.grid').isotope({
itemSelector: '.list-inline-item',
layoutMode: 'fitRows',
filter: function() {
return qsRegex ? $(this).text().match( qsRegex ) : true;
}
});
$grid.imagesLoaded().progress( function() {
$grid.isotope('layout');
});
// use value of search field to filter
var $quicksearch = $('.quicksearch').keyup( debounce( function() {
qsRegex = new RegExp( $quicksearch.val(), 'gi' );
$grid.isotope();
}, 200 ) );
// debounce so filtering doesn't happen every millisecond
function debounce( fn, threshold ) {
var timeout;
threshold = threshold || 100;
return function debounced() {
clearTimeout( timeout );
var args = arguments;
var _this = this;
function delayed() {
fn.apply( _this, args );
}
timeout = setTimeout( delayed, threshold );
};
}
// store filter for each group
var filters = {};
$('.filters').on( 'click', '.button', function( event ) {
var $button = $( event.currentTarget );
// get group key
var $buttonGroup = $button.parents('.button-group');
var filterGroup = $buttonGroup.attr('data-filter-group');
// set filter for group
filters[ filterGroup ] = $button.attr('data-filter');
// combine filters
var filterValue = concatValues( filters );
// set filter for Isotope
$grid.isotope({ filter: filterValue });
});
// change is-checked class on buttons
$('.button-group').each( function( i, buttonGroup ) {
var $buttonGroup = $( buttonGroup );
$buttonGroup.on( 'click', 'button', function( event ) {
$buttonGroup.find('.is-checked').removeClass('is-checked');
var $button = $( event.currentTarget );
$button.addClass('is-checked');
});
});
// flatten object by concatting values
function concatValues( obj ) {
var value = '';
for ( var prop in obj ) {
value += obj[ prop ];
}
return value;
}
</script>