Files
app
bootstrap
config
database
public
resources
css
fonts
img
js
lang
sass
views
auth
components
application-logo.blade.php
auth-card.blade.php
auth-session-status.blade.php
auth-validation-errors.blade.php
button.blade.php
dropdown-link.blade.php
dropdown.blade.php
input.blade.php
label.blade.php
nav-link.blade.php
responsive-nav-link.blade.php
errors
guest
layouts
pages
user
routes
storage
tests
.editorconfig
.env.example
.eslintrc.json
.gitattributes
.gitignore
.styleci.yml
README.md
artisan
composer.json
composer.lock
package-lock.json
package.json
phpunit.xml
server.php
tailwind.config.js
tsconfig.json
webpack.mix.js
diaREact/resources/views/components/dropdown.blade.php
2022-02-11 17:26:15 +01:00

44 lines
1.3 KiB
PHP

@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white'])
@php
switch ($align) {
case 'left':
$alignmentClasses = 'origin-top-left left-0';
break;
case 'top':
$alignmentClasses = 'origin-top';
break;
case 'right':
default:
$alignmentClasses = 'origin-top-right right-0';
break;
}
switch ($width) {
case '48':
$width = 'w-48';
break;
}
@endphp
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @close.stop="open = false">
<div @click="open = ! open">
{{ $trigger }}
</div>
<div x-show="open"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="transform opacity-0 scale-95"
x-transition:enter-end="transform opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="transform opacity-100 scale-100"
x-transition:leave-end="transform opacity-0 scale-95"
class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-lg {{ $alignmentClasses }}"
style="display: none;"
@click="open = false">
<div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}">
{{ $content }}
</div>
</div>
</div>