Merge pull request 'TIST-23: added static favorites page and controller' (#25) from TIST-23 into develop
Reviewed-on: #25 Reviewed-by: steve_dekart <stevedekart2020@gmail.com>
This commit is contained in:
commit
aa0e153f65
26
apps/Recipes/Controllers/FavoritesController.php
Normal file
26
apps/Recipes/Controllers/FavoritesController.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lycoreco\Apps\Recipes\Controllers;
|
||||||
|
|
||||||
|
use Lycoreco\Apps\Recipes\Models\RecipeModel;
|
||||||
|
use Lycoreco\Includes\BaseController;
|
||||||
|
|
||||||
|
define('FAVORITES_MAX_RECIPES', 20);
|
||||||
|
|
||||||
|
class FavoritesController extends BaseController
|
||||||
|
{
|
||||||
|
protected $template_name = APPS_PATH . '/Recipes/Templates/favorites.php';
|
||||||
|
|
||||||
|
public function get_context_data()
|
||||||
|
{
|
||||||
|
$context = parent::get_context_data();
|
||||||
|
|
||||||
|
$context['recipes'] = RecipeModel::filter(
|
||||||
|
[],
|
||||||
|
['-obj.created_at'],
|
||||||
|
FAVORITES_MAX_RECIPES
|
||||||
|
);
|
||||||
|
|
||||||
|
return $context;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
apps/Recipes/Templates/favorites.php
Normal file
31
apps/Recipes/Templates/favorites.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
require_once APPS_PATH . '/Recipes/components.php';
|
||||||
|
|
||||||
|
the_header(
|
||||||
|
'Favorites',
|
||||||
|
'Here are your favorite recipes. Enjoy cooking!',
|
||||||
|
'favorites-page',
|
||||||
|
[
|
||||||
|
['keywords', 'favorites, recipes, cooking, food'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="favorites">
|
||||||
|
<div class="favorites-items">
|
||||||
|
<?php
|
||||||
|
for( $i = 0; $i < 5; $i++) {
|
||||||
|
foreach ($context['recipes'] as $recipe) {
|
||||||
|
the_product_item($recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
the_footer();
|
||||||
|
?>
|
||||||
@ -8,4 +8,5 @@ $recipes_urls = [
|
|||||||
new Path('/recipe/[:int]/export-pdf', new Controllers\ExportPdfController(), 'export-pdf'),
|
new Path('/recipe/[:int]/export-pdf', new Controllers\ExportPdfController(), 'export-pdf'),
|
||||||
new Path('/catalog', new Controllers\CatalogController(), 'catalog'),
|
new Path('/catalog', new Controllers\CatalogController(), 'catalog'),
|
||||||
new Path('/daily-meals', new Controllers\DailyMealsController, 'daily-meals'),
|
new Path('/daily-meals', new Controllers\DailyMealsController, 'daily-meals'),
|
||||||
|
new Path('/favorites', new Controllers\FavoritesController(), 'favorites'),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -734,8 +734,11 @@ input[type="checkbox"]{
|
|||||||
}
|
}
|
||||||
|
|
||||||
.catalog-recipe {
|
.catalog-recipe {
|
||||||
display: block;
|
display: flex;
|
||||||
width: 200px;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.catalog-recipe__image {
|
.catalog-recipe__image {
|
||||||
@ -1063,6 +1066,23 @@ label {
|
|||||||
margin-top: 46px;
|
margin-top: 46px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.favorites-items a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.favorites{
|
||||||
|
margin-top: 46px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.favorites-items{
|
||||||
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
column-gap: 25px;
|
||||||
|
row-gap: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
|
||||||
.catalog-items {
|
.catalog-items {
|
||||||
@ -1071,6 +1091,8 @@ label {
|
|||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.welcome__inner {
|
.welcome__inner {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
@ -1238,6 +1260,11 @@ label {
|
|||||||
grid-template-rows: repeat(6, 100px);
|
grid-template-rows: repeat(6, 100px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.favorites-items {
|
||||||
|
width: 100%;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1272,6 +1299,13 @@ label {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.favorites-items {
|
||||||
|
margin-right: 0;
|
||||||
|
justify-items: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.catalog-recipe {
|
.catalog-recipe {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -1298,4 +1332,10 @@ label {
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.favorites-items {
|
||||||
|
width: 100%;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<li class="nav-item"><a href="<?php the_permalink("index:home") ?>" class="nav-link">HOME</a>
|
<li class="nav-item"><a href="<?php the_permalink("index:home") ?>" class="nav-link">HOME</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item"><a href="<?php the_permalink("recipes:catalog") ?>" class="nav-link">RECIPES</a></li>
|
<li class="nav-item"><a href="<?php the_permalink("recipes:catalog") ?>" class="nav-link">RECIPES</a></li>
|
||||||
<li class="nav-item"><a href="#" class="nav-link">FAVORITES</a></li>
|
<li class="nav-item"><a href="<?php the_permalink("recipes:favorites")?>" class="nav-link">FAVORITES</a></li>
|
||||||
<li class="nav-item"><a href="<?php the_permalink("recipes:daily-meals") ?>" class="nav-link">MEAL A DAY</a></li>
|
<li class="nav-item"><a href="<?php the_permalink("recipes:daily-meals") ?>" class="nav-link">MEAL A DAY</a></li>
|
||||||
<li class="nav-item"><a href="#" class="nav-link">SUBMIT RECIPE</a></li>
|
<li class="nav-item"><a href="#" class="nav-link">SUBMIT RECIPE</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user