Skip to content

Commit

Permalink
Add max height to language switch dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklopf committed Jun 18, 2024
1 parent 6c3903f commit 5abbd50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/views/language-switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
! $isVisibleOutsidePanels && $isFlagsOnly=> 'bottom',
default => 'bottom-end',
};
$maxHeight = $languageSwitch->getMaxHeight();
@endphp
<div>
@if ($isVisibleOutsidePanels)
Expand Down
1 change: 1 addition & 0 deletions resources/views/switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
teleport
:placement="$placement"
:width="$isFlagsOnly ? 'flags-only' : 'fls-dropdown-width'"
:max-height="$maxHeight"
class="fi-dropdown fi-user-menu"
>
<x-slot name="trigger">
Expand Down
14 changes: 14 additions & 0 deletions src/LanguageSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class LanguageSwitch extends Component

protected bool | Closure $visibleOutsidePanels = false;

protected string $maxHeight = 'max-content';

protected Closure | string $renderHook = 'panels::global-search.after';

protected Closure | string | null $userPreferredLocale = null;
Expand Down Expand Up @@ -174,6 +176,13 @@ public function visible(bool | Closure $insidePanels = true, bool | Closure $out
return $this;
}

public function maxHeight(string $height): static
{
$this->maxHeight = $height;

return $this;
}

public function getDisplayLocale(): ?string
{
return $this->evaluate($this->displayLocale);
Expand Down Expand Up @@ -270,6 +279,11 @@ public function getPreferredLocale(): string
return in_array($locale, $this->getLocales(), true) ? $locale : config('app.locale');
}

public function getMaxHeight(): string
{
return $this->maxHeight;
}

/**
* @return array<string, Panel>
*/
Expand Down

0 comments on commit 5abbd50

Please sign in to comment.