Sidenav.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <aside class="flex justify-between h-full md:flex-col">
  3. <nav class="flex flex-1 flex-nowrap md:flex-col md:flex-none bg-primary">
  4. <NuxtLink
  5. v-for="(navigation, index) in primaryNavigation"
  6. :key="`navigation-${index}`"
  7. :to="localePath(navigation.target)"
  8. class="nav-link"
  9. tabindex="0"
  10. >
  11. <div v-if="navigation.svg">
  12. <SmartIcon :name="navigation.svg" class="svg-icons" />
  13. </div>
  14. <span v-if="EXPAND_NAVIGATION">{{ navigation.title }}</span>
  15. <tippy
  16. v-if="!EXPAND_NAVIGATION"
  17. :placement="mdAndLarger ? 'right' : 'bottom'"
  18. theme="tooltip"
  19. :content="navigation.title"
  20. />
  21. </NuxtLink>
  22. </nav>
  23. </aside>
  24. </template>
  25. <script setup lang="ts">
  26. import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
  27. import { useSetting } from "~/newstore/settings"
  28. import { useI18n } from "~/helpers/utils/composables"
  29. const t = useI18n()
  30. const breakpoints = useBreakpoints(breakpointsTailwind)
  31. const mdAndLarger = breakpoints.greater("md")
  32. const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
  33. const primaryNavigation = [
  34. {
  35. target: "index",
  36. svg: "link-2",
  37. title: t("navigation.rest"),
  38. },
  39. {
  40. target: "graphql",
  41. svg: "graphql",
  42. title: t("navigation.graphql"),
  43. },
  44. {
  45. target: "realtime",
  46. svg: "globe",
  47. title: t("navigation.realtime"),
  48. },
  49. {
  50. target: "documentation",
  51. svg: "book-open",
  52. title: t("navigation.doc"),
  53. },
  54. {
  55. target: "settings",
  56. svg: "settings",
  57. title: t("navigation.settings"),
  58. },
  59. ]
  60. </script>
  61. <style scoped lang="scss">
  62. .nav-link {
  63. @apply relative;
  64. @apply p-4;
  65. @apply flex flex-col flex-1;
  66. @apply items-center;
  67. @apply justify-center;
  68. @apply hover:(bg-primaryDark text-secondaryDark);
  69. @apply focus-visible:text-secondaryDark;
  70. &::after {
  71. @apply absolute;
  72. @apply inset-x-0;
  73. @apply md:inset-x-auto;
  74. @apply md:inset-y-0;
  75. @apply bottom-0;
  76. @apply md:bottom-auto;
  77. @apply md:left-0;
  78. @apply z-2;
  79. @apply h-0.5;
  80. @apply md:h-full;
  81. @apply w-full;
  82. @apply md:w-0.5;
  83. content: "";
  84. }
  85. &:focus::after {
  86. @apply bg-divider;
  87. }
  88. .material-icons,
  89. .svg-icons {
  90. @apply opacity-75;
  91. }
  92. span {
  93. @apply mt-2;
  94. @apply text-tiny;
  95. }
  96. &.exact-active-link {
  97. @apply text-secondaryDark;
  98. @apply bg-primaryLight;
  99. @apply hover:text-secondaryDark;
  100. .material-icons,
  101. .svg-icons {
  102. @apply opacity-100;
  103. }
  104. &::after {
  105. @apply bg-accent;
  106. }
  107. }
  108. }
  109. </style>