Add more data to food view

This commit is contained in:
Christopher C. Wells 2021-03-03 06:03:39 -08:00
parent 67964e492f
commit 2ae2e1ad50
1 changed files with 81 additions and 58 deletions

View File

@ -1,7 +1,12 @@
<x-app-layout> <x-app-layout>
<x-slot name="header"> <x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight flex flex-auto"> <h2 class="font-semibold text-xl text-gray-800 leading-tight flex flex-auto items-center">
{{ $food->name }} <div>
{{ $food->name }}@if($food->detail), {{ $food->detail }}@endif
@if($food->brand)
<div>{{ $food->brand }}</div>
@endif
</div>
<a class="ml-2 text-gray-500 hover:text-gray-700 hover:border-gray-300 text-sm" <a class="ml-2 text-gray-500 hover:text-gray-700 hover:border-gray-300 text-sm"
href="{{ route('foods.edit', $food) }}"> href="{{ route('foods.edit', $food) }}">
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
@ -21,66 +26,84 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg"> <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200"> <div class="p-6 bg-white border-b border-gray-200">
<!-- TODO: tags, recipes, etc. --> <div class="flex flex-col space-y-2 sm:flex-row sm:space-x-4 sm:space-y-0">
<h3 class="text-2xl font-extrabold"> <div class="p-1 mb-2 border-2 border-black font-sans md:w-72">
{{ $food->name }}@if($food->detail), <span class="text-2xl font-extrabold">{{ $food->detail }}</span>@endif <div class="text-3xl font-extrabold leading-none">Nutrition Facts</div>
</h3> <div class="flex justify-between font-bold border-b-8 border-black">
@if($food->brand) <div>Serving size</div>
<div class="text-2xl font-extrabold">{{ $food->brand }}</div> <div>
@endif {{ $food->servingSizeFormatted }}
<div class="p-1 mb-2 border-2 border-black font-sans md:w-72"> {{ $food->servingUnitFormatted ?? $food->name }}
<div class="text-3xl font-extrabold leading-none">Nutrition Facts</div> ({{ $food->serving_weight }}g)
<div class="flex justify-between font-bold border-b-8 border-black"> </div>
<div>Serving size</div> </div>
<div> <div class="font-bold text-right">Amount per serving</div>
{{ $food->servingSizeFormatted }} <div class="flex justify-between items-end font-extrabold">
{{ $food->servingUnitFormatted ?? $food->name }} <div class="text-3xl">Calories</div>
({{ $food->serving_weight }}g) <div class="text-4xl">{{ $food->calories }}</div>
</div>
<div class="border-t-4 border-black text-sm">
<hr class="border-gray-500"/>
<div class="flex justify-between">
<div class="font-bold">Total Fat</div>
<div>{{ $food->fat }}g</div>
</div>
<hr class="border-gray-500"/>
<div class="flex justify-between">
<div class="font-bold">Cholesterol</div>
<div>{{ $food->cholesterol }}mg</div>
</div>
<hr class="border-gray-500"/>
<div class="flex justify-between">
<div class="font-bold">Sodium</div>
<div>{{ $food->sodium }}mg</div>
</div>
<hr class="border-gray-500"/>
<div class="flex justify-between">
<div class="font-bold">Total Carbohydrate</div>
<div>{{ $food->carbohydrates }}g</div>
</div>
<hr class="border-gray-500"/>
<div class="flex justify-between">
<div class="font-bold">Protein</div>
<div>{{ $food->protein }}g</div>
</div>
</div> </div>
</div> </div>
<div class="font-bold text-right">Amount per serving</div> <div class="flex flex-col space-y-2">
<div class="flex justify-between items-end font-extrabold"> @if(!$food->tags->isEmpty())
<div class="text-3xl">Calories</div> <h3 class="font-bold text-2xl">Tags</h3>
<div class="text-4xl">{{ $food->calories }}</div> <div class="flex flex-wrap">
</div> @foreach ($food->tags as $tag)
<div class="border-t-4 border-black text-sm"> <span class="m-1 bg-gray-200 rounded-full px-2 leading-loose">{{ $tag->name }}</span>
<hr class="border-gray-500"/> @endforeach
<div class="flex justify-between"> </div>
<div class="font-bold">Total Fat</div> @endif
<div>{{ $food->fat }}g</div> @if($food->description)
</div> <h3 class="font-bold text-2xl">Description</h3>
<hr class="border-gray-500"/> <div class="text-gray-800">{{ $food->description }}</div>
<div class="flex justify-between"> @endif
<div class="font-bold">Cholesterol</div> @if(!$food->ingredientAmountRelationships->isEmpty())
<div>{{ $food->cholesterol }}mg</div> <h3 class="font-bold text-2xl">Recipes</h3>
</div> <ul class="list-disc list-inside ml-3 space-y-1">
<hr class="border-gray-500"/> @foreach ($food->ingredientAmountRelationships as $ia)
<div class="flex justify-between"> <li> <a class="text-gray-500 hover:text-gray-700"
<div class="font-bold">Sodium</div> href="{{ route('recipes.show', $ia->parent) }}">{{ $ia->parent->name }}</a></li>
<div>{{ $food->sodium }}mg</div> @endforeach
</div> </ul>
<hr class="border-gray-500"/> @endif
<div class="flex justify-between"> @if($food->source)
<div class="font-bold">Total Carbohydrate</div> <h3 class="font-bold text-2xl">Source</h3>
<div>{{ $food->carbohydrates }}g</div> <div>
</div> @if(filter_var($food->source, FILTER_VALIDATE_URL))
<hr class="border-gray-500"/> <a class="text-gray-500 hover:text-gray-700" href="{{ $food->source }}">{{ $food->source }}</a>
<div class="flex justify-between"> @else
<div class="font-bold">Protein</div> {{ $food->source }}
<div>{{ $food->protein }}g</div> @endif
</div> </div>
</div>
</div>
@if($food->source)
<div class="mb-2 text-gray-500 text-sm">
<span class="font-extrabold">Source:</span>
@if(filter_var($food->source, FILTER_VALIDATE_URL))
<a href="{{ $food->source }}">{{ $food->source }}</a>
@else
{{ $food->source }}
@endif @endif
</div> </div>
@endif </div>
</div> </div>
</div> </div>
</div> </div>