+layout.svelte 2.3 KB

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