+layout.svelte 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <script>
  2. import "$lib/global.css";
  3. import logo from '$lib/assets/favicon.svg';
  4. import {page} from "$app/state";
  5. import {getNotifications} from "$lib/notifier.svelte.js";
  6. let {data, children} = $props();
  7. let notifications = getNotifications();
  8. </script>
  9. <svelte:head>
  10. <link rel="icon" href={logo} />
  11. <title>Recipes</title>
  12. </svelte:head>
  13. {#if !page.url.pathname.endsWith("/print")}
  14. <header>
  15. <a class="logo" href="/">
  16. <img src={logo} alt="Site logo">
  17. </a>
  18. {#if data.loggedIn && page.url.pathname !== "/dashboard"}
  19. <a href="/dashboard" class="button">Dashboard</a>
  20. {/if}
  21. {#if page.url.pathname === "/"}
  22. {#if !data.loggedIn}
  23. <a href="/login" class="button">Sign In</a>
  24. <a href="/register" class="button">Sign Up</a>
  25. {:else}
  26. <a href="logout" class="button">Log Out</a>
  27. {/if}
  28. {/if}
  29. {#if page.url.pathname === "/register"}
  30. <a href="/login" class="button">Sign In</a>
  31. {/if}
  32. {#if page.url.pathname === "/login"}
  33. <a href="/register" class="button">Sign Up</a>
  34. {/if}
  35. <div class="notifications">
  36. {#each notifications as n}
  37. <p class="{n.type}">{n.message}</p>
  38. {/each}
  39. </div>
  40. </header>
  41. {/if}
  42. {@render children()}
  43. <style>
  44. header{
  45. display: flex;
  46. align-items: center;
  47. height: 75px;
  48. width: 100%;
  49. }
  50. .logo{
  51. height: 90%;
  52. cursor: pointer;
  53. }
  54. .logo img{
  55. height: 100%;
  56. width: auto;
  57. }
  58. .notifications{
  59. position: fixed;
  60. top: 1rem;
  61. right: 1rem;
  62. z-index: 9999;
  63. display: flex;
  64. flex-direction: column;
  65. gap: 0.5rem;
  66. width: min(320px, calc(100vw - 2rem));
  67. pointer-events: none;
  68. }
  69. .notifications p{
  70. margin: 0;
  71. padding: 0.75rem 1rem;
  72. border-radius: 6px;
  73. font-size: 0.9rem;
  74. line-height: 1.3;
  75. color: var(--color-text);
  76. background: var(--color-surface-alt);
  77. border: 1px solid var(--color-border);
  78. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  79. pointer-events: auto;
  80. }
  81. .notifications p.success{
  82. border-color: var(--color-success);
  83. }
  84. .notifications p.warning{
  85. border-color: var(--color-warning);
  86. }
  87. .notifications p.error{
  88. border-color: var(--color-error);
  89. }
  90. </style>