dropdown.blade.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. @props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-fogra'])
  2. @php
  3. switch ($align) {
  4. case 'left':
  5. $alignmentClasses = 'origin-top-left left-0';
  6. break;
  7. case 'top':
  8. $alignmentClasses = 'origin-top';
  9. break;
  10. case 'right':
  11. default:
  12. $alignmentClasses = 'origin-top-right right-0';
  13. break;
  14. }
  15. switch ($width) {
  16. case '48':
  17. $width = 'w-48';
  18. break;
  19. }
  20. @endphp
  21. <div class="relative" x-data="{ open: false }" @click.outside="open = false" @close.stop="open = false">
  22. <div @click="open = ! open">
  23. {{ $trigger }}
  24. </div>
  25. <div x-show="open"
  26. x-transition:enter="transition ease-out duration-200"
  27. x-transition:enter-start="transform opacity-0 scale-95"
  28. x-transition:enter-end="transform opacity-100 scale-100"
  29. x-transition:leave="transition ease-in duration-75"
  30. x-transition:leave-start="transform opacity-100 scale-100"
  31. x-transition:leave-end="transform opacity-0 scale-95"
  32. class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-md shadow-burnt {{ $alignmentClasses }}"
  33. style="display: none;"
  34. @click="open = false">
  35. <div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}">
  36. {{ $content }}
  37. </div>
  38. </div>
  39. </div>