Header.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <header
  3. class="w-full flex justify-between gap-5 bg-background-100 p-3 animate__animated animate__fadeInDown animate__faster z-10"
  4. >
  5. <ISandwich
  6. class="w-8 h-8 hover:opacity-50 cursor-pointer duration-150"
  7. @click="sideBar.show()"
  8. />
  9. <div class="flex-auto flex items-center font-semibold">
  10. {{ $router.currentRoute.value.name }}
  11. </div>
  12. <IMoreVertical
  13. class="w-8 h-8 hover:opacity-50 cursor-pointer duration-150"
  14. @click="show"
  15. />
  16. <div
  17. v-if="showMenu"
  18. class="fixed top-0 left-0 w-screen h-screen"
  19. >
  20. <div
  21. class="absolute top-0 left-0 w-full h-full bg-black bg-opacity-30 animate__duration"
  22. :class="showAnim ? 'animate__animated animate__fadeIn' : 'animate__animated animate__fadeOut'"
  23. />
  24. <div
  25. class="absolute top-0 left-0 w-full h-full flex justify-end items-start z-40"
  26. :class="showAnim ? 'animate__animated animate__fadeIn' : 'animate__animated animate__fadeOut'"
  27. style="--animate-duration: 200ms"
  28. @click="hide"
  29. >
  30. <div class="m-3 w-44 flex flex-col divide-y-2 divide-stone-700 drop-shadow-lg">
  31. <button
  32. v-for="(item, idx) in menu"
  33. :key="idx"
  34. class="flex gap-5 p-3 items-center bg-background-100 hover:bg-stone-700 animate__animated animate__fadeInDown duration-150"
  35. :class="{
  36. 'rounded-t-md': idx === 0,
  37. 'rounded-b-md': idx === menu.length - 1,
  38. }"
  39. :style="`--animate-duration: ${(idx + 1) * 50}ms`"
  40. @click="item.action"
  41. >
  42. <img
  43. :src="`/icons/bug-report.svg`"
  44. class="w-7 h-7"
  45. :alt="item.icon"
  46. >
  47. <p v-text="item.name" />
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. </header>
  53. </template>
  54. <script setup lang="ts">
  55. import { useDebug } from '~/store/useDebug'
  56. import { useSideBar } from '~/store/useSideBar'
  57. // import { useUser } from '~/store/useUser'
  58. const sideBar = useSideBar()
  59. // const user = useUser()
  60. const debug = useDebug()
  61. const showMenu = ref(false)
  62. const showAnim = ref(false)
  63. function hide() {
  64. showAnim.value = false
  65. setTimeout(() => {
  66. showMenu.value = false
  67. }, 100)
  68. }
  69. function show() {
  70. showMenu.value = true
  71. showAnim.value = true
  72. }
  73. const menu = [
  74. {
  75. name: 'Debug',
  76. icon: 'bug-report',
  77. action: () => debug.show(),
  78. },
  79. {
  80. name: 'Trigger error',
  81. icon: 'bug-report',
  82. action: () => {
  83. throw new Error('Test Error <3')
  84. },
  85. },
  86. ]
  87. </script>