Skip to content

Commit

Permalink
Merge pull request #5 from Jelmer-Ketelaar/#64
Browse files Browse the repository at this point in the history
#64 Added some styling
  • Loading branch information
Jelmer-Ketelaar authored Oct 21, 2021
2 parents 5e3ca07 + 406a2ae commit aa647bb
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 58 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-ctype": "*",
"ext-curl": "*",
"ext-iconv": "*",
Expand Down
47 changes: 47 additions & 0 deletions public/style/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
html {
height: 20%;
}
body {
font-family: 'Montserrat', sans-serif;
height: 100%;
background-color: #e9dcd1;
}

.p {
line-height: 1.5;
}

.grid {
display: inline-grid;
border: #1111 1px solid;
box-shadow: 0 0 5px -1px rgb(0 0 0 / 30%), 0 0 15px -1px rgb(0 0 0 / 25%), 0 0 20px -1px rgb(0 0 0 / 15%);
margin: 4vw 0 0 4vw;
height: 25vh;
width: 20vh;
border-radius: 10%;
background-color: #e9dcd1;
}

.grid:active {
box-shadow: 0 0 5px -1px rgb(0 0 0 / 30%), 0 0 15px -1px rgb(0 0 0 / 25%), 0 0 20px -1px rgb(0 0 0 / 15%);
transform: translateY(10px) translateX(10px);
}

.meal-name {
color: #b5191f !important;
text-decoration: none;
text-align: center;
margin-top: 2vh;
}

.image {
margin-top: 5vh;
height: 10vh;
}

.text {
margin-left: 2vw;
}
h1 {
font-size: 4rem;
}
6 changes: 6 additions & 0 deletions src/Controller/MealController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ public function getMealCategories(MealMatcherService $mealMatcherService): Respo
return $this->render('categories/index.html.twig', ['meals' => $mealMatcherService->getParentMealCategories()]);
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
#[Route('/{parentId}', name: 'meal_categories_for_parent')]
public function getCategoriesForParent(int $parentId, MealMatcherService $mealMatcherService)
{
return $this->render('categories/index.html.twig', ['meals' => $mealMatcherService->getCategoriesForParent($parentId)]);
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
#[Route('/meals/{categoryId}', name: 'meals_for_category')]
public function getMealsForCategory(int $categoryId, MealMatcherService $mealMatcherService)
{
Expand Down
18 changes: 13 additions & 5 deletions src/Service/MealMatcherService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function getMealsCategories()
return $categories;
}

public function getParentMealCategories()
/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getParentMealCategories(): array
{
$categories = $this->getMealsCategories();
$parentCategories = [];
Expand All @@ -44,7 +47,10 @@ public function getParentMealCategories()
return $parentCategories;
}

public function getCategoriesForParent(int $parentId)
/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getCategoriesForParent(int $parentId): array
{
$categories = $this->getMealsCategories();
$childCategories = [];
Expand All @@ -60,11 +66,13 @@ public function getCategoriesForParent(int $parentId)
return $childCategories;
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getMealsForCategory(int $categoryId)
{
$response = $this->client->request('GET', '/meals/category/'.$categoryId);
$response = $this->client->request('GET', '/meals/category/' . $categoryId);

$meals = json_decode($response->getBody()->getContents());
return $meals;
return json_decode($response->getBody()->getContents());
}
}
67 changes: 38 additions & 29 deletions templates/categories/index.html.twig
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
{% extends 'base.html.twig' %}

{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('style/style.css') }}">
{% endblock %}

{% block title %}Hello MealController!{% endblock %}

{% block body %}
<style>
.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}
.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}
</style>

<div class="example-wrapper">
<h1>Welkom bij de online sommelier</h1>
<p>Hier kunt u uw gerecht kiezen en dan worden er bijpassende wijnen gezocht.</p>
</div>
<div class="meals">
{% for meal in meals %}
{% if meal.parent is null %}
<p><a href="{{ path('meal_categories_for_parent', {parentId: meal.categoryId}) }}"> {{ meal.name }}</a>
</p>
{% else %}
<p><a href="{{ path('meals_for_category', {categoryId: meal.categoryId}) }}"> {{ meal.name }}</a>
</p>
{% endif %}
{% endfor %}
</div>
<style>
.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}
.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}
</style>

<div class="text">
<h1>U het gerecht en wij adviseren de wijn!</h1>
<p class="p"></p>
</div>
{% for meal in meals %}
<section class="grid">
{% if meal.parent is null %}
<a href="{{ path('meal_categories_for_parent', {parentId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
<img src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
</a>

{# <section class="grid2"> #}
{% else %}
<a href="{{ path('meals_for_category', {categoryId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
</a>
{% endif %}
</section>
{% endfor %}
{% endblock %}


56 changes: 33 additions & 23 deletions templates/meals/index.html.twig
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
{% extends 'base.html.twig' %}

{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('style/style.css') }}">
{% endblock %}


{% block title %}Hello MealController!{% endblock %}


{% block body %}
<style>
.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}
.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}
</style>
{#https://mealmatcher.grandcruwijnen.nl/meals/%7B12de8bb3-8ce2-43a9-8b09-d56161365ebc%7D#}
<div class="example-wrapper">
<h1>Welkom bij de online sommelier</h1>
<p>Hier kunt u uw gerecht kiezen en dan worden er bijpassende wijnen gezocht.</p>
</div>
{% for meal in meals %}
<p>{{ meal.name }}</p>
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="">
{% endfor %}
<style>
.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}
.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}
</style>
{# https://mealmatcher.grandcruwijnen.nl/meals/%7B12de8bb3-8ce2-43a9-8b09-d56161365ebc%7D #}

{% endblock %}
<div class="example-wrapper">
<h1>Welkom bij de online sommelier</h1>
<p>Hier kunt u uw gerecht kiezen en dan worden er bijpassende wijnen gezocht.</p>
</div>


<div class="grid-row main-categories">
{% for meal in meals %}
<p>{{ meal.name }}</p>
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="">
{% endfor %}
</div>

{% endblock %}


0 comments on commit aa647bb

Please sign in to comment.