Skip to content

Commit

Permalink
Added options for dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjansen committed Dec 29, 2021
1 parent de7bb03 commit 0138833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions resources/views/components/dropdown.blade.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
@props(['orientation' => 'left'])

@php
$orientationClass = match($orientation) {
'left' => 'top-7 left-0',
'right' => 'right-0',
'down' => 'bottom-0 left-0 -mr-1',
'down right' => 'bottom-0 right-0 -mr-1',
default => 'top-7 left-0',
}
@endphp

<div>
<div x-data="{ open: false }"
{{ $attributes->merge(['class' => 'relative']) }}
{{ $attributes->merge(['class' => 'relative']) }}
>
<div x-on:click="open = true">
{{ $trigger }}
</div>

<div :class="{'block': open, 'hidden': ! open}"
class="absolute z-50 mt-2 w-48 rounded-md shadow-lg origin-top-right top-7 {{ $orientation === 'left' ? 'left-0' : 'right-0' }} hidden"
class="absolute z-50 mt-2 w-48 rounded-md shadow-lg origin-top-right {{ $orientationClass }} hidden"
@click.away="open = false"
>
<div class="rounded-md shadow-xs py-1 bg-white">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/profile-dropdown.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-move-dropdown align="left" width="48" orientation="{{ ($orientation ?? 'right') ? 'right' : 'left' }}">
<x-move-dropdown align="left" width="48" orientation="{{ $orientation ?? 'left' }}">
<x-slot name="trigger">
<button {{ $attributes->merge(['class' => 'flex text-sm border-2 border-transparent rounded-full focus:outline-none focus:border-gray-300 transition duration-150 ease-in-out']) }}>
@if (optional(Auth::user())->profile_photo_url)
Expand Down

0 comments on commit 0138833

Please sign in to comment.