Header.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. UserName
  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 bg-transparent"
  19. >
  20. <div
  21. class="w-full h-full flex justify-end items-start"
  22. :class="showAnim ? 'animate__animated animate__fadeIn' : 'animate__animated animate__fadeOut'"
  23. style="--animate-duration: 200ms"
  24. @click="hide"
  25. >
  26. <div class="m-3 w-44 flex flex-col divide-y-2 divide-stone-700 drop-shadow-lg">
  27. <button
  28. v-for="(item, idx) in menu"
  29. :key="idx"
  30. class="flex gap-5 p-3 items-center bg-background-100 hover:bg-stone-700 animate__animated animate__fadeInDown duration-150"
  31. :class="{
  32. 'rounded-t-md': idx === 0,
  33. 'rounded-b-md': idx === menu.length - 1,
  34. }"
  35. :style="`--animate-duration: ${(idx + 1) * 50}ms`"
  36. @click="item.action"
  37. >
  38. <img
  39. :src="`/icons/bug-report.svg`"
  40. class="w-7 h-7"
  41. :alt="item.icon"
  42. >
  43. <p v-text="item.name" />
  44. </button>
  45. </div>
  46. </div>
  47. </div>
  48. </header>
  49. </template>
  50. <script setup lang="ts">
  51. import { useDebug } from '~/store/useDebug'
  52. import { useSideBar } from '~/store/useSideBar'
  53. // import { useUser } from '~/store/useUser'
  54. const sideBar = useSideBar()
  55. // const user = useUser()
  56. const debug = useDebug()
  57. const showMenu = ref(false)
  58. const showAnim = ref(false)
  59. function hide() {
  60. showAnim.value = false
  61. setTimeout(() => {
  62. showMenu.value = false
  63. }, 100)
  64. }
  65. function show() {
  66. showMenu.value = true
  67. showAnim.value = true
  68. }
  69. const menu = [
  70. {
  71. name: 'Debug',
  72. icon: 'bug-report',
  73. action: () => debug.show(),
  74. },
  75. {
  76. name: 'Debug',
  77. icon: 'bug-report',
  78. action: () => debug.show(),
  79. },
  80. ]
  81. </script>