Skip to content

Commit

Permalink
Merge pull request #15475 from filamentphp/rename-max-width-enum
Browse files Browse the repository at this point in the history
Rename max width enum
  • Loading branch information
danharrin authored Jan 30, 2025
2 parents 44abd7a + 71f0972 commit 62fbb7e
Show file tree
Hide file tree
Showing 33 changed files with 160 additions and 157 deletions.
2 changes: 1 addition & 1 deletion docs/09-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ In v4, Filament automatically scopes all queries in a panel to the current tenan
The `$maxContentWidth` property on page classes has a new type. It is now able to accept `MaxWidth` enum values, as well as strings and null:

```php
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

protected MaxWidth | string | null $maxContentWidth = null;
```
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/docs/03-modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ You can change the width of the modal by using the `modalWidth()` method. Option

```php
use Filament\Actions\Action;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

Action::make('updateAuthor')
->form([
Expand All @@ -354,7 +354,7 @@ Action::make('updateAuthor')
->action(function (array $data): void {
// ...
})
->modalWidth(MaxWidth::FiveExtraLarge)
->modalWidth(Width::FiveExtraLarge)
```

## Executing code when the modal opens
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/docs/04-grouping-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ The dropdown may be set to a width by using the `dropdownWidth()` method. Option

```php
use Filament\Actions\ActionGroup;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

ActionGroup::make([
// Array of actions
])
->dropdownWidth(MaxWidth::ExtraSmall)
->dropdownWidth(Width::ExtraSmall)
```

## Controlling the maximum height of the dropdown
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/src/ActionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Filament\Support\Concerns\HasExtraAttributes;
use Filament\Support\Concerns\HasIcon;
use Filament\Support\Concerns\HasTooltip;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
use Filament\Support\Facades\FilamentIcon;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\View\View;
Expand Down Expand Up @@ -377,7 +377,7 @@ public function toEmbeddedHtml(): string
$panelAttributes = (new ComponentAttributeBag)
->class([
'fi-dropdown-panel',
($width instanceof MaxWidth) ? "fi-width-{$width->value}" : (is_string($width) ? $width : 'fi-width-default'),
($width instanceof Width) ? "fi-width-{$width->value}" : (is_string($width) ? $width : 'fi-width-default'),
'fi-scrollable' => $maxHeight,
])
->style([
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/src/AssociateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Filament\Actions\Concerns\CanCustomizeProcess;
use Filament\Forms\Components\Select;
use Filament\Schemas\Schema;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
use Filament\Tables\Table;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function setUp(): void

$this->modalSubmitActionLabel(__('filament-actions::associate.single.modal.actions.associate.label'));

$this->modalWidth(MaxWidth::Large);
$this->modalWidth(Width::Large);

$this->extraModalFooterActions(function (): array {
return $this->canAssociateAnother ? [
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/src/AttachAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Filament\Actions\Concerns\CanCustomizeProcess;
use Filament\Forms\Components\Select;
use Filament\Schemas\Schema;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
use Filament\Support\Services\RelationshipJoiner;
use Filament\Tables\Table;
use Illuminate\Database\Connection;
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function setUp(): void

$this->modalSubmitActionLabel(__('filament-actions::attach.single.modal.actions.attach.label'));

$this->modalWidth(MaxWidth::Large);
$this->modalWidth(Width::Large);

$this->extraModalFooterActions(function (): array {
return $this->canAttachAnother() ? [
Expand Down
14 changes: 7 additions & 7 deletions packages/actions/src/Concerns/CanOpenModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Closure;
use Filament\Actions\Action;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
use Filament\Support\Facades\FilamentIcon;
use Filament\Support\View\Components\Modal;
use Illuminate\Contracts\Support\Htmlable;
Expand Down Expand Up @@ -69,7 +69,7 @@ trait CanOpenModal

protected string | Htmlable | Closure | null $modalDescription = null;

protected MaxWidth | string | Closure | null $modalWidth = null;
protected Width | string | Closure | null $modalWidth = null;

protected bool | Closure | null $hasModal = null;

Expand Down Expand Up @@ -309,7 +309,7 @@ public function modalSubheading(string | Htmlable | Closure | null $subheading =
return $this;
}

public function modalWidth(MaxWidth | string | Closure | null $width = null): static
public function modalWidth(Width | string | Closure | null $width = null): static
{
$this->modalWidth = $width;

Expand Down Expand Up @@ -507,7 +507,7 @@ public function getModalAlignment(): Alignment | string
return $alignment;
}

if ($this->isConfirmationRequired() || in_array($this->getModalWidth(), [MaxWidth::ExtraSmall, MaxWidth::Small, 'xs', 'sm'])) {
if ($this->isConfirmationRequired() || in_array($this->getModalWidth(), [Width::ExtraSmall, Width::Small, 'xs', 'sm'])) {
return Alignment::Center;
}

Expand Down Expand Up @@ -585,17 +585,17 @@ public function hasModalDescription(): bool
return filled($this->getModalDescription());
}

public function getModalWidth(): MaxWidth | string
public function getModalWidth(): Width | string
{
if ($width = $this->evaluate($this->modalWidth)) {
return $width;
}

if ($this->isConfirmationRequired()) {
return MaxWidth::Medium;
return Width::Medium;
}

return MaxWidth::FourExtraLarge;
return Width::FourExtraLarge;
}

public function isModalFooterSticky(): bool
Expand Down
12 changes: 6 additions & 6 deletions packages/actions/src/Concerns/HasDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Filament\Actions\Concerns;

use Closure;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

trait HasDropdown
{
Expand All @@ -15,7 +15,7 @@ trait HasDropdown

protected int | Closure | null $dropdownOffset = null;

protected MaxWidth | string | Closure | null $dropdownWidth = null;
protected Width | string | Closure | null $dropdownWidth = null;

public function dropdown(bool | Closure $condition = true): static
{
Expand Down Expand Up @@ -45,7 +45,7 @@ public function dropdownOffset(int | Closure | null $offset): static
return $this;
}

public function dropdownWidth(MaxWidth | string | Closure | null $width): static
public function dropdownWidth(Width | string | Closure | null $width): static
{
$this->dropdownWidth = $width;

Expand All @@ -67,12 +67,12 @@ public function getDropdownOffset(): ?int
return $this->evaluate($this->dropdownOffset);
}

public function getDropdownWidth(): MaxWidth | string | null
public function getDropdownWidth(): Width | string | null
{
$width = $this->evaluate($this->dropdownWidth);

if (! ($width instanceof MaxWidth)) {
$width = MaxWidth::tryFrom($width) ?? $width;
if (! ($width instanceof Width)) {
$width = Width::tryFrom($width) ?? $width;
}

return $width;
Expand Down
8 changes: 4 additions & 4 deletions packages/forms/src/Components/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Filament\Support\Concerns\HasReorderAnimationDuration;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
use Filament\Support\Facades\FilamentIcon;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -93,7 +93,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
*/
protected ?array $blockPickerColumns = [];

protected MaxWidth | string | Closure | null $blockPickerWidth = null;
protected Width | string | Closure | null $blockPickerWidth = null;

protected function setUp(): void
{
Expand Down Expand Up @@ -1088,14 +1088,14 @@ public function getBlockPickerColumns(?string $breakpoint = null): array | int |
return $columns;
}

public function blockPickerWidth(MaxWidth | string | Closure | null $width): static
public function blockPickerWidth(Width | string | Closure | null $width): static
{
$this->blockPickerWidth = $width;

return $this;
}

public function getBlockPickerWidth(): MaxWidth | string | null
public function getBlockPickerWidth(): Width | string | null
{
$width = $this->evaluate($this->blockPickerWidth);

Expand Down
6 changes: 3 additions & 3 deletions packages/panels/docs/03-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ This example assumes you have a Blade view at `resources/views/filament/settings
By default, Filament will restrict the width of the content on the page, so it doesn't become too wide on large screens. To change this, you may override the `getMaxContentWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `ExtraSmall`, `Small`, `Medium`, `Large`, `ExtraLarge`, `TwoExtraLarge`, `ThreeExtraLarge`, `FourExtraLarge`, `FiveExtraLarge`, `SixExtraLarge`, `SevenExtraLarge`, `Full`, `MinContent`, `MaxContent`, `FitContent`, `Prose`, `ScreenSmall`, `ScreenMedium`, `ScreenLarge`, `ScreenExtraLarge` and `ScreenTwoExtraLarge`. The default is `SevenExtraLarge`:

```php
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

public function getMaxContentWidth(): MaxWidth
public function getMaxContentWidth(): Width
{
return MaxWidth::Full;
return Width::Full;
}
```

Expand Down
8 changes: 4 additions & 4 deletions packages/panels/docs/08-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,27 @@ By default, Filament will restrict the width of the content on the page, so it d

```php
use Filament\Panel;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

public function panel(Panel $panel): Panel
{
return $panel
// ...
->maxContentWidth(MaxWidth::Full);
->maxContentWidth(Width::Full);
}
```

If you'd like to set the max content width for pages of the type `SimplePage`, like login and registration pages, you may do so using the `simplePageMaxContentWidth()` method. The default is `Large`:

```php
use Filament\Panel;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;

public function panel(Panel $panel): Panel
{
return $panel
// ...
->simplePageMaxContentWidth(MaxWidth::Small);
->simplePageMaxContentWidth(Width::Small);
}
```

Expand Down
52 changes: 27 additions & 25 deletions packages/panels/resources/views/components/layout/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@php
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Enums\Width;
@endphp

<x-filament-panels::layout.base :livewire="$livewire">
Expand All @@ -22,13 +22,15 @@ class="fi-layout flex min-h-screen w-full flex-row-reverse overflow-x-clip"
x-bind:class="{
'fi-main-ctn-sidebar-open': $store.sidebar.isOpen,
}"
x-bind:style="'display: flex; opacity:1;'" {{-- Mimics `x-cloak`, as using `x-cloak` causes visual issues with chart widgets --}}
x-bind:style="'display: flex; opacity:1;'"
{{-- Mimics `x-cloak`, as using `x-cloak` causes visual issues with chart widgets --}}
@elseif (filament()->isSidebarFullyCollapsibleOnDesktop())
x-data="{}"
x-bind:class="{
'fi-main-ctn-sidebar-open': $store.sidebar.isOpen,
}"
x-bind:style="'display: flex; opacity:1;'" {{-- Mimics `x-cloak`, as using `x-cloak` causes visual issues with chart widgets --}}
x-bind:style="'display: flex; opacity:1;'"
{{-- Mimics `x-cloak`, as using `x-cloak` causes visual issues with chart widgets --}}
@elseif (! (filament()->isSidebarCollapsibleOnDesktop() || filament()->isSidebarFullyCollapsibleOnDesktop() || filament()->hasTopNavigation() || (! filament()->hasNavigation())))
x-data="{}"
x-bind:style="'display: flex; opacity:1;'" {{-- Mimics `x-cloak`, as using `x-cloak` causes visual issues with chart widgets --}}
Expand All @@ -43,28 +45,28 @@ class="fi-layout flex min-h-screen w-full flex-row-reverse overflow-x-clip"
<main
@class([
'fi-main mx-auto h-full w-full px-4 md:px-6 lg:px-8',
match ($maxContentWidth ??= (filament()->getMaxContentWidth() ?? MaxWidth::SevenExtraLarge)) {
MaxWidth::ExtraSmall, 'xs' => 'max-w-xs',
MaxWidth::Small, 'sm' => 'max-w-sm',
MaxWidth::Medium, 'md' => 'max-w-md',
MaxWidth::Large, 'lg' => 'max-w-lg',
MaxWidth::ExtraLarge, 'xl' => 'max-w-xl',
MaxWidth::TwoExtraLarge, '2xl' => 'max-w-2xl',
MaxWidth::ThreeExtraLarge, '3xl' => 'max-w-3xl',
MaxWidth::FourExtraLarge, '4xl' => 'max-w-4xl',
MaxWidth::FiveExtraLarge, '5xl' => 'max-w-5xl',
MaxWidth::SixExtraLarge, '6xl' => 'max-w-6xl',
MaxWidth::SevenExtraLarge, '7xl' => 'max-w-7xl',
MaxWidth::Full, 'full' => 'max-w-full',
MaxWidth::MinContent, 'min' => 'max-w-min',
MaxWidth::MaxContent, 'max' => 'max-w-max',
MaxWidth::FitContent, 'fit' => 'max-w-fit',
MaxWidth::Prose, 'prose' => 'max-w-prose',
MaxWidth::ScreenSmall, 'screen-sm' => 'max-w-(--breakpoint-sm)',
MaxWidth::ScreenMedium, 'screen-md' => 'max-w-(--breakpoint-md)',
MaxWidth::ScreenLarge, 'screen-lg' => 'max-w-(--breakpoint-lg)',
MaxWidth::ScreenExtraLarge, 'screen-xl' => 'max-w-(--breakpoint-xl)',
MaxWidth::ScreenTwoExtraLarge, 'screen-2xl' => 'max-w-(--breakpoint-2xl)',
match ($maxContentWidth ??= (filament()->getMaxContentWidth() ?? Width::SevenExtraLarge)) {
Width::ExtraSmall, 'xs' => 'max-w-xs',
Width::Small, 'sm' => 'max-w-sm',
Width::Medium, 'md' => 'max-w-md',
Width::Large, 'lg' => 'max-w-lg',
Width::ExtraLarge, 'xl' => 'max-w-xl',
Width::TwoExtraLarge, '2xl' => 'max-w-2xl',
Width::ThreeExtraLarge, '3xl' => 'max-w-3xl',
Width::FourExtraLarge, '4xl' => 'max-w-4xl',
Width::FiveExtraLarge, '5xl' => 'max-w-5xl',
Width::SixExtraLarge, '6xl' => 'max-w-6xl',
Width::SevenExtraLarge, '7xl' => 'max-w-7xl',
Width::Full, 'full' => 'max-w-full',
Width::MinContent, 'min' => 'max-w-min',
Width::MaxContent, 'max' => 'max-w-max',
Width::FitContent, 'fit' => 'max-w-fit',
Width::Prose, 'prose' => 'max-w-prose',
Width::ScreenSmall, 'screen-sm' => 'max-w-(--breakpoint-sm)',
Width::ScreenMedium, 'screen-md' => 'max-w-(--breakpoint-md)',
Width::ScreenLarge, 'screen-lg' => 'max-w-(--breakpoint-lg)',
Width::ScreenExtraLarge, 'screen-xl' => 'max-w-(--breakpoint-xl)',
Width::ScreenTwoExtraLarge, 'screen-2xl' => 'max-w-(--breakpoint-2xl)',
default => $maxContentWidth,
},
])
Expand Down
Loading

0 comments on commit 62fbb7e

Please sign in to comment.