You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <script lang="ts">
  2. import { link } from "svelte-routing";
  3. import selectionStore from "../stores/selection";
  4. export let location: string = window.location.pathname.split("?")[0];
  5. function updateLocation() {
  6. setTimeout(() => {
  7. location = window.location.pathname.split("?")[0];
  8. }, 0);
  9. }
  10. $: selected = {
  11. home: $selectionStore.path === "/",
  12. goals: $selectionStore.path.startsWith("/goals"),
  13. questlog: $selectionStore.path.startsWith("/questlog"),
  14. projects: $selectionStore.path.startsWith("/projects"),
  15. items: $selectionStore.path.startsWith("/items"),
  16. logs: $selectionStore.path.startsWith("/logs"),
  17. }
  18. </script>
  19. <nav>
  20. <a on:click={updateLocation} class:selected={selected.home} use:link href="/">Stufflog</a>
  21. <a on:click={updateLocation} class:selected={selected.goals} use:link href="/goals">Goals</a>
  22. <a class="desktop" on:click={updateLocation} class:selected={selected.questlog} use:link href="/questlog">Projects</a>
  23. <a class="mobile" on:click={updateLocation} class:selected={selected.projects} use:link href="/projects">Projects</a>
  24. <a on:click={updateLocation} class:selected={selected.items} use:link href="/items">Items</a>
  25. <a on:click={updateLocation} class:selected={selected.logs} use:link href="/logs">Logs</a>
  26. </nav>
  27. <style>
  28. nav {
  29. margin: 0;
  30. text-align: center;
  31. }
  32. a {
  33. display: inline-block;
  34. padding: 0.25em;
  35. color: #555;
  36. font-size: 1em;
  37. }
  38. a.selected {
  39. color: #AAA;
  40. }
  41. a.mobile {
  42. display: none;
  43. }
  44. @media screen and (max-width: 600px) {
  45. a.mobile {
  46. display: inline-block;
  47. }
  48. a.desktop {
  49. display: none;
  50. }
  51. }
  52. </style>