Header.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. v-if="header.menu.length > 0"
  14. class="w-8 h-8 hover:opacity-50 cursor-pointer duration-150 show"
  15. @click="show"
  16. />
  17. <div
  18. v-if="showMenu"
  19. class="fixed top-0 left-0 w-screen h-screen"
  20. >
  21. <div
  22. class="absolute top-0 left-0 w-full h-full bg-black bg-opacity-30 animate__duration"
  23. :class="showAnim ? 'animate__animated animate__fadeIn' : 'animate__animated animate__fadeOut'"
  24. />
  25. <div
  26. class="absolute top-0 left-0 w-full h-full flex justify-end items-start z-40"
  27. :class="showAnim ? 'animate__animated animate__fadeIn' : 'animate__animated animate__fadeOut'"
  28. style="--animate-duration: 200ms"
  29. @click="hide"
  30. >
  31. <div class="m-3 w-fit flex flex-col divide-y-2 divide-stone-700 drop-shadow-lg">
  32. <button
  33. v-for="(item, idx) in header.menu"
  34. :key="idx"
  35. class="flex gap-4 p-3 items-center bg-background-100 hover:bg-stone-700 animate__animated animate__fadeInDown duration-150"
  36. :class="{
  37. 'rounded-t-md': idx === 0,
  38. 'rounded-b-md': idx === header.menu.length - 1,
  39. }"
  40. :style="`--animate-duration: ${(idx + 1) * 50}ms`"
  41. @click="item.action"
  42. >
  43. <img
  44. :src="`/icons/${item.icon}.svg`"
  45. class="w-6 h-6 opacity-50"
  46. :alt="item.icon"
  47. >
  48. <p v-text="item.name" />
  49. </button>
  50. </div>
  51. </div>
  52. </div>
  53. </header>
  54. </template>
  55. <script setup lang="ts">
  56. import { useSideBar } from '~/store/useSideBar'
  57. import { useHeader } from '~/store/useHeader'
  58. const sideBar = useSideBar()
  59. const header = useHeader()
  60. const showMenu = ref(false)
  61. const showAnim = ref(false)
  62. function hide() {
  63. showAnim.value = false
  64. setTimeout(() => {
  65. showMenu.value = false
  66. }, 100)
  67. }
  68. function show() {
  69. showMenu.value = true
  70. showAnim.value = true
  71. }
  72. </script>