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,13 +26,7 @@
<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">
{{ $food->name }}@if($food->detail), <span class="text-2xl font-extrabold">{{ $food->detail }}</span>@endif
</h3>
@if($food->brand)
<div class="text-2xl font-extrabold">{{ $food->brand }}</div>
@endif
<div class="p-1 mb-2 border-2 border-black font-sans md:w-72"> <div class="p-1 mb-2 border-2 border-black font-sans md:w-72">
<div class="text-3xl font-extrabold leading-none">Nutrition Facts</div> <div class="text-3xl font-extrabold leading-none">Nutrition Facts</div>
<div class="flex justify-between font-bold border-b-8 border-black"> <div class="flex justify-between font-bold border-b-8 border-black">
@ -71,11 +70,33 @@
</div> </div>
</div> </div>
</div> </div>
<div class="flex flex-col space-y-2">
@if(!$food->tags->isEmpty())
<h3 class="font-bold text-2xl">Tags</h3>
<div class="flex flex-wrap">
@foreach ($food->tags as $tag)
<span class="m-1 bg-gray-200 rounded-full px-2 leading-loose">{{ $tag->name }}</span>
@endforeach
</div>
@endif
@if($food->description)
<h3 class="font-bold text-2xl">Description</h3>
<div class="text-gray-800">{{ $food->description }}</div>
@endif
@if(!$food->ingredientAmountRelationships->isEmpty())
<h3 class="font-bold text-2xl">Recipes</h3>
<ul class="list-disc list-inside ml-3 space-y-1">
@foreach ($food->ingredientAmountRelationships as $ia)
<li> <a class="text-gray-500 hover:text-gray-700"
href="{{ route('recipes.show', $ia->parent) }}">{{ $ia->parent->name }}</a></li>
@endforeach
</ul>
@endif
@if($food->source) @if($food->source)
<div class="mb-2 text-gray-500 text-sm"> <h3 class="font-bold text-2xl">Source</h3>
<span class="font-extrabold">Source:</span> <div>
@if(filter_var($food->source, FILTER_VALIDATE_URL)) @if(filter_var($food->source, FILTER_VALIDATE_URL))
<a href="{{ $food->source }}">{{ $food->source }}</a> <a class="text-gray-500 hover:text-gray-700" href="{{ $food->source }}">{{ $food->source }}</a>
@else @else
{{ $food->source }} {{ $food->source }}
@endif @endif
@ -85,4 +106,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</x-app-layout> </x-app-layout>