Skip to content

Commit 121122c

Browse files
Refactor from switch statement to match statement for dropdown blade component (#1509)
* Refactor switch statement to match statement * Refactor switch statement to match statement * Update dropdown.blade.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 4039f1d commit 121122c

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

stubs/livewire/resources/views/components/dropdown.blade.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white dark:bg-gray-700', 'dropdownClasses' => ''])
22

33
@php
4-
switch ($align) {
5-
case 'left':
6-
$alignmentClasses = 'ltr:origin-top-left rtl:origin-top-right start-0';
7-
break;
8-
case 'top':
9-
$alignmentClasses = 'origin-top';
10-
break;
11-
case 'none':
12-
case 'false':
13-
$alignmentClasses = '';
14-
break;
15-
case 'right':
16-
default:
17-
$alignmentClasses = 'ltr:origin-top-right rtl:origin-top-left end-0';
18-
break;
19-
}
4+
$alignmentClasses = match ($align) {
5+
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0',
6+
'top' => 'origin-top',
7+
'none', 'false' => '',
8+
default => 'ltr:origin-top-right rtl:origin-top-left end-0',
9+
};
2010
21-
switch ($width) {
22-
case '48':
23-
$width = 'w-48';
24-
break;
25-
}
11+
$width = match ($width) {
12+
'48' => 'w-48',
13+
};
2614
@endphp
2715

2816
<div class="relative" x-data="{ open: false }" @click.away="open = false" @close.stop="open = false">

0 commit comments

Comments
 (0)