Header.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <header
  3. class="w-full flex justify-between gap-5 bg-background-100 p-3 animate__animated animate__fadeInDown animate__faster"
  4. >
  5. <Icon
  6. @click="sideBar.show()"
  7. name="solar:hamburger-menu-outline"
  8. class="w-8 h-8 hover:opacity-50 cursor-pointer duration-150"
  9. />
  10. <div class="flex-auto flex items-center font-semibold">UserName</div>
  11. <Icon
  12. name="basil:other-2-outline"
  13. @click="show"
  14. class="w-8 h-8 hover:opacity-50 cursor-pointer duration-150"
  15. />
  16. <div
  17. v-if="showMenu"
  18. class="absolute top-0 left-0 w-screen h-screen bg-transparent z-50"
  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. class="flex gap-5 p-3 items-center bg-background-100 hover:bg-stone-700 animate__animated animate__fadeInDown duration-150"
  30. :class="{
  31. 'rounded-t-md': idx === 0,
  32. 'rounded-b-md': idx === menu.length - 1,
  33. }"
  34. :style="`--animate-duration: ${(idx + 1) * 50}ms`"
  35. @click="item.action"
  36. >
  37. <Icon :name="item.icon" class="w-7 h-7 text-stone-500" />
  38. <p v-text="item.name" />
  39. </button>
  40. </div>
  41. </div>
  42. </div>
  43. </header>
  44. </template>
  45. <script setup lang="ts">
  46. import { useDebug } from "~/store/useDebug";
  47. import { useSideBar } from "~/store/useSideBar";
  48. import { useUser } from "~/store/useUser";
  49. const sideBar = useSideBar();
  50. const user = useUser();
  51. const debug = useDebug()
  52. const showMenu = ref(false);
  53. const showAnim = ref(false);
  54. function hide() {
  55. showAnim.value = false;
  56. setTimeout(() => {
  57. showMenu.value = false;
  58. }, 100);
  59. }
  60. function show() {
  61. showMenu.value = true;
  62. showAnim.value = true;
  63. }
  64. const menu = [
  65. {
  66. name: "Debug",
  67. icon: "material-symbols:bug-report-outline",
  68. action: () => debug.show(),
  69. },
  70. ];
  71. </script>