DropdownNav.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <div class="relative">
  3. <div v-if="open" @click="open = false" class="fixed inset-0"></div>
  4. <button @click="open = !open" class="relative flex items-center focus:outline-none">
  5. <span class="ml-2 md:ml-0 font-medium text-white">{{ username }}</span>
  6. <svg
  7. class="ml-1 h-5 w-5 fill-current text-white"
  8. xmlns="http://www.w3.org/2000/svg"
  9. viewBox="0 0 24 24"
  10. >
  11. <path
  12. d="M15.3 9.3a1 1 0 0 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 1.4-1.4l3.3 3.29 3.3-3.3z"
  13. />
  14. </svg>
  15. </button>
  16. <transition
  17. enter-active-class="transition-all transition-fastest ease-out-quad"
  18. leave-active-class="transition-all transition-faster ease-in-quad"
  19. enter-class="opacity-0 scale-70"
  20. enter-to-class="opacity-100 scale-100"
  21. leave-class="opacity-100 scale-100"
  22. leave-to-class="opacity-0 scale-70"
  23. >
  24. <div
  25. v-if="open"
  26. class="origin-top-right absolute right-0 mt-2 w-64 bg-white rounded-lg shadow-md py-2 z-10"
  27. >
  28. <slot></slot>
  29. </div>
  30. </transition>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: ['username'],
  36. data() {
  37. return {
  38. open: false,
  39. }
  40. },
  41. }
  42. </script>