Add better placeholder content for goals

This commit is contained in:
Christopher C. Wells 2021-02-15 14:18:33 -08:00
parent c642111c20
commit a5d42fa8e5
7 changed files with 66 additions and 41 deletions

View File

@ -50,7 +50,10 @@ class GoalController extends Controller
*/ */
public function show(Goal $goal): View public function show(Goal $goal): View
{ {
return view('goals.show')->with('goal', $goal); return view('goals.show')
->with('goal', $goal)
->with('nameOptions', Goal::getNameOptions())
->with('frequencyOptions', Goal::$frequencyOptions);
} }
/** /**

View File

@ -43,7 +43,7 @@ final class Goal extends Model
* Supported options for thr frequency attribute. * Supported options for thr frequency attribute.
*/ */
public static array $frequencyOptions = [ public static array $frequencyOptions = [
['value' => 'daily', 'label' => 'daily'], 'daily' => ['value' => 'daily', 'label' => 'daily'],
]; ];
/** /**

View File

@ -10,21 +10,21 @@ class Nutrients
public static float $gramsPerOunce = 28.349523125; public static float $gramsPerOunce = 28.349523125;
public static array $all = [ public static array $all = [
['value' => 'calories', 'label' => 'calories', 'unit' => null], 'calories' => ['value' => 'calories', 'label' => 'calories', 'unit' => null],
['value' => 'carbohydrates', 'label' => 'carbohydrates', 'unit' => 'g'], 'carbohydrates' => ['value' => 'carbohydrates', 'label' => 'carbohydrates', 'unit' => 'g'],
['value' => 'cholesterol', 'label' => 'cholesterol', 'unit' => 'mg'], 'cholesterol' => ['value' => 'cholesterol', 'label' => 'cholesterol', 'unit' => 'mg'],
['value' => 'fat', 'label' => 'fat', 'unit' => 'g'], 'fat' => ['value' => 'fat', 'label' => 'fat', 'unit' => 'g'],
['value' => 'protein', 'label' => 'protein', 'unit' => 'g'], 'protein' => ['value' => 'protein', 'label' => 'protein', 'unit' => 'g'],
['value' => 'sodium', 'label' => 'sodium', 'unit' => 'mg'], 'sodium' => ['value' => 'sodium', 'label' => 'sodium', 'unit' => 'mg'],
]; ];
public static array $units = [ public static array $units = [
['value' => 'cup', 'label' => 'cup'], 'cup' => ['value' => 'cup', 'label' => 'cup'],
['value' => 'gram', 'label' => 'grams'], 'gram' => ['value' => 'gram', 'label' => 'grams'],
['value' => 'oz', 'label' => 'oz'], 'oz' => ['value' => 'oz', 'label' => 'oz'],
['value' => 'serving', 'label' => 'servings'], 'serving' => ['value' => 'serving', 'label' => 'servings'],
['value' => 'tbsp', 'label' => 'tbsp.'], 'tbsp' => ['value' => 'tbsp', 'label' => 'tbsp.'],
['value' => 'tsp', 'label' => 'tsp.'], 'tsp' => ['value' => 'tsp', 'label' => 'tsp.'],
]; ];
/** /**

View File

@ -20,7 +20,7 @@
<x-inputs.input name="from" <x-inputs.input name="from"
type="date" type="date"
class="block w-full" class="block w-full"
:value="old('from', $goal->from)" /> :value="old('from', $goal->from?->toDateString())" />
</div> </div>
<!-- To --> <!-- To -->
@ -29,7 +29,7 @@
<x-inputs.input name="to" <x-inputs.input name="to"
type="date" type="date"
class="block w-full" class="block w-full"
:value="old('to', $goal->to)" /> :value="old('to', $goal->to?->toDateString())" />
</div> </div>
<!-- Frequency --> <!-- Frequency -->

View File

@ -36,11 +36,9 @@
<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">
<div class="space-y-4">
@forelse($goals['present'] as $goal) @forelse($goals['present'] as $goal)
<details> <div class="flex space-x-2 items-center">
<summary>{{ $goal->summary }}</summary>
TODO: Details for the day!
<div class="flex">
<a class="text-gray-500 hover:text-gray-700 hover:border-gray-300 text-sm" <a class="text-gray-500 hover:text-gray-700 hover:border-gray-300 text-sm"
href="{{ route('goals.edit', $goal) }}"> href="{{ route('goals.edit', $goal) }}">
<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">
@ -54,8 +52,8 @@
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg> </svg>
</a> </a>
<div class="text-lg font-bold">{{ $goal->summary }}</div>
</div> </div>
</details>
@empty @empty
<div>No goals set.</div> <div>No goals set.</div>
@endforelse @endforelse
@ -63,4 +61,5 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</x-app-layout> </x-app-layout>

View File

@ -21,7 +21,18 @@
<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: GOAL SHOW PAGE <div class="grid grid-cols-2 gap-y-1 gap-x-3 max-w-md inline-grid">
<div class="font-bold">From</div>
<div>{{ $goal->from?->toDateString() ?? 'Any' }}</div>
<div class="font-bold">To</div>
<div>{{ $goal->to?->toDateString() ?? 'Any' }}</div>
<div class="font-bold">Frequency</div>
<div>{{ \Illuminate\Support\Str::ucfirst($frequencyOptions[$goal->frequency]['label']) }}</div>
<div class="font-bold">Trackable</div>
<div>{{ \Illuminate\Support\Str::ucfirst($nameOptions[$goal->name]['label']) }}</div>
<div class="font-bold">Goal</div>
<div>{{ $goal->goal }}{{ $nameOptions[$goal->name]['unit'] }}</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -37,46 +37,58 @@
<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">
<div class="flex align-top flex-col space-y-4 sm:flex-row sm:space-x-4 sm:space-y-0"> <div class="flex align-top flex-col space-y-4 sm:flex-row sm:space-x-4 sm:space-y-0">
<div class="w-full sm:w-5/12 md:w-5/12"> <div class="w-full sm:w-5/12 lg:w-4/12">
<h3 class="font-semibold text-xl text-gray-800">{{ $date->format('D, j M Y') }}</h3> <div class="flex justify-between items-baseline">
<h3 class="font-semibold text-lg text-gray-800">{{ $date->format('D, j M Y') }}</h3>
<div class="text-gray-700">{{ $entries->count() }} {{ \Illuminate\Support\Pluralizer::plural('entry', $entries->count()) }}</div> <div class="text-gray-700">{{ $entries->count() }} {{ \Illuminate\Support\Pluralizer::plural('entry', $entries->count()) }}</div>
<div class="text-right border-t-8 border-black pt-2">% Daily goal</div> </div>
<div class="grid grid-cols-2 text-sm"> <div class="text-right border-t-8 border-black text-sm pt-2">% Daily goal</div>
<div class="border-b-4 border-black"> <div class="flex justify-between items-baseline border-b-4 border-black">
<div>
<span class="font-extrabold text-2xl">Calories</span> <span class="font-extrabold text-2xl">Calories</span>
<span class="text-lg">{{ number_format($sums['calories']) }}</span> <span class="text-lg">{{ number_format($sums['calories']) }}</span>
</div> </div>
<div class="font-extrabold text-right text-lg border-b-4 border-black"> <div class="font-extrabold text-right text-lg">
{{ $dailyGoals['calories'] ?? 'N/A' }} {{ $dailyGoals['calories'] ?? 'N/A' }}
</div> </div>
<div class="border-b border-gray-300"> </div>
<div class="flex justify-between items-baseline border-b border-gray-300 text-sm">
<div>
<span class="font-bold">Fat</span> <span class="font-bold">Fat</span>
{{ number_format($sums['fat']) }}g {{ number_format($sums['fat']) }}g
</div> </div>
<div class="text-right border-b border-gray-300"> <div class="text-right">
{{ $dailyGoals['fat'] ?? 'N/A' }} {{ $dailyGoals['fat'] ?? 'N/A' }}
</div> </div>
<div class="border-b border-gray-300"> </div>
<div class="flex justify-between items-baseline border-b border-gray-300 text-sm">
<div>
<span class="font-bold">Cholesterol</span> <span class="font-bold">Cholesterol</span>
{{ number_format($sums['cholesterol']) }}mg {{ number_format($sums['cholesterol']) }}mg
</div> </div>
<div class="text-right border-b border-gray-300"> <div class="text-right">
{{ $dailyGoals['cholesterol'] ?? 'N/A' }} {{ $dailyGoals['cholesterol'] ?? 'N/A' }}
</div> </div>
<div class="border-b border-gray-300"> </div>
<div class="flex justify-between items-baseline border-b border-gray-300 text-sm">
<div>
<span class="font-bold">Sodium</span> <span class="font-bold">Sodium</span>
{{ number_format($sums['sodium']) }}mg {{ number_format($sums['sodium']) }}mg
</div> </div>
<div class="text-right border-b border-gray-300"> <div class="text-right">
{{ $dailyGoals['sodium'] ?? 'N/A' }} {{ $dailyGoals['sodium'] ?? 'N/A' }}
</div> </div>
<div class="border-b border-gray-300"> </div>
<div class="flex justify-between items-baseline border-b border-gray-300 text-sm">
<div>
<span class="font-bold">Carbohydrates</span> <span class="font-bold">Carbohydrates</span>
{{ number_format($sums['carbohydrates']) }}g {{ number_format($sums['carbohydrates']) }}g
</div> </div>
<div class="text-right border-b border-gray-300"> <div class="text-right">
{{ $dailyGoals['carbohydrates'] ?? 'N/A' }} {{ $dailyGoals['carbohydrates'] ?? 'N/A' }}
</div> </div>
</div>
<div class="flex justify-between items-baseline text-sm">
<div> <div>
<span class="font-bold">Protein</span> <span class="font-bold">Protein</span>
{{ number_format($sums['protein']) }}g {{ number_format($sums['protein']) }}g