| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <script>
- import IngredientSearch from "$lib/IngredientSearch.svelte";
- let {data} = $props();
- </script>
- <div class="container">
- <div class="topbar">
- <h1>Search results</h1>
- </div>
- <IngredientSearch startingIngredients={data.ingredients} compact />
- <div class="recipes">
- {#each data.recipes as r}
- <a href="/recipe/{r.id}" class="recipe" data-sveltekit-reload>
- <p class="name">{r.name}</p>
- <p class="date">{r.updatedAt ? new Date(r.updatedAt).toLocaleDateString() : ""}</p>
- </a>
- {:else}
- <p class="empty">
- {#if data.ingredients.length === 0}
- Add at least one ingredient to search.
- {:else}
- No recipes match those ingredients.
- {/if}
- </p>
- {/each}
- </div>
- </div>
- <style>
- .container{
- width: min(720px, 100%);
- min-height: calc(100% - 75px);
- min-height: calc(100dvh - 75px);
- margin: 0 auto;
- padding: 1rem max(0.75rem, env(safe-area-inset-right, 0px)) max(2rem, env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
- color: var(--color-text);
- overflow-x: clip;
- }
- .topbar{
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 0.75rem 1rem;
- margin-bottom: 1rem;
- }
- h1{
- font-size: clamp(1.35rem, 1rem + 1.6vw, 1.75rem);
- font-weight: 700;
- line-height: 1.2;
- min-width: 0;
- }
- .recipes{
- margin-top: 1rem;
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
- }
- .recipe{
- display: flex;
- flex-direction: row;
- align-items: baseline;
- justify-content: space-between;
- gap: 0.75rem 1.5rem;
- min-width: 0;
- padding: 0.85rem 1rem;
- background: var(--color-surface);
- border: 1px solid var(--color-border);
- border-left: 3px solid var(--color-primary);
- border-radius: 10px;
- text-decoration: none;
- color: var(--color-text);
- }
- .name{
- flex: 1;
- min-width: 0;
- font-size: 1.05rem;
- font-weight: 600;
- line-height: 1.35;
- overflow-wrap: anywhere;
- }
- .date{
- flex-shrink: 0;
- color: var(--color-text-muted);
- font-size: 0.85rem;
- line-height: 1.3;
- white-space: nowrap;
- text-align: right;
- }
- .date:empty{
- display: none;
- }
- .empty{
- margin: 0;
- padding: 2.5rem 1.25rem;
- text-align: center;
- color: var(--color-text-muted);
- background: var(--color-surface);
- border: 1px dashed var(--color-border);
- border-radius: 10px;
- font-size: 0.95rem;
- line-height: 1.45;
- }
- @media (min-width: 560px){
- .container{
- padding: 1.5rem 1rem 3rem;
- }
- }
- @media (min-width: 900px){
- .container{
- padding-top: 2rem;
- }
- }
- </style>
|