+page.svelte 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <script>
  2. import IngredientSearch from "$lib/IngredientSearch.svelte";
  3. let {data} = $props();
  4. </script>
  5. <div class="container">
  6. <div class="topbar">
  7. <h1>Search results</h1>
  8. </div>
  9. <IngredientSearch startingIngredients={data.ingredients} compact />
  10. <div class="recipes">
  11. {#each data.recipes as r}
  12. <a href="/recipe/{r.id}" class="recipe" data-sveltekit-reload>
  13. <p class="name">{r.name}</p>
  14. <p class="date">{r.updatedAt ? new Date(r.updatedAt).toLocaleDateString() : ""}</p>
  15. </a>
  16. {:else}
  17. <p class="empty">
  18. {#if data.ingredients.length === 0}
  19. Add at least one ingredient to search.
  20. {:else}
  21. No recipes match those ingredients.
  22. {/if}
  23. </p>
  24. {/each}
  25. </div>
  26. </div>
  27. <style>
  28. .container{
  29. width: min(720px, 100%);
  30. min-height: calc(100% - 75px);
  31. min-height: calc(100dvh - 75px);
  32. margin: 0 auto;
  33. 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));
  34. color: var(--color-text);
  35. overflow-x: clip;
  36. }
  37. .topbar{
  38. display: flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. gap: 0.75rem 1rem;
  42. margin-bottom: 1rem;
  43. }
  44. h1{
  45. font-size: clamp(1.35rem, 1rem + 1.6vw, 1.75rem);
  46. font-weight: 700;
  47. line-height: 1.2;
  48. min-width: 0;
  49. }
  50. .recipes{
  51. margin-top: 1rem;
  52. display: flex;
  53. flex-direction: column;
  54. gap: 0.5rem;
  55. }
  56. .recipe{
  57. display: flex;
  58. flex-direction: row;
  59. align-items: baseline;
  60. justify-content: space-between;
  61. gap: 0.75rem 1.5rem;
  62. min-width: 0;
  63. padding: 0.85rem 1rem;
  64. background: var(--color-surface);
  65. border: 1px solid var(--color-border);
  66. border-left: 3px solid var(--color-primary);
  67. border-radius: 10px;
  68. text-decoration: none;
  69. color: var(--color-text);
  70. }
  71. .name{
  72. flex: 1;
  73. min-width: 0;
  74. font-size: 1.05rem;
  75. font-weight: 600;
  76. line-height: 1.35;
  77. overflow-wrap: anywhere;
  78. }
  79. .date{
  80. flex-shrink: 0;
  81. color: var(--color-text-muted);
  82. font-size: 0.85rem;
  83. line-height: 1.3;
  84. white-space: nowrap;
  85. text-align: right;
  86. }
  87. .date:empty{
  88. display: none;
  89. }
  90. .empty{
  91. margin: 0;
  92. padding: 2.5rem 1.25rem;
  93. text-align: center;
  94. color: var(--color-text-muted);
  95. background: var(--color-surface);
  96. border: 1px dashed var(--color-border);
  97. border-radius: 10px;
  98. font-size: 0.95rem;
  99. line-height: 1.45;
  100. }
  101. @media (min-width: 560px){
  102. .container{
  103. padding: 1.5rem 1rem 3rem;
  104. }
  105. }
  106. @media (min-width: 900px){
  107. .container{
  108. padding-top: 2rem;
  109. }
  110. }
  111. </style>