generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 44
feat: add headerToolbar() for inline filter/search in page header #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ebadb67
feat: add headerToolbar() to render filter/search inline with page title
ManukMinasyan 4eac40c
refactor: make headerToolbar the default behavior
ManukMinasyan 8625e4a
fix: left-align header and fix filter indicator layout
ManukMinasyan f14d2b5
fix: remove fi-header class that caused center alignment
ManukMinasyan b68237c
fix: add fi-ta-ctn context for proper filter dropdown styling
ManukMinasyan 692098f
fix: add explicit shadow and border to filter dropdown panel
ManukMinasyan 4a9ceba
fix: use fi-ta-ctn context for native filter dropdown styling
ManukMinasyan 6564322
refactor: default headerToolbar to false for backward compatibility
ManukMinasyan 744e77f
fix: add modal/slide-over support and render hook to header toolbar
ManukMinasyan 3cfd31e
docs: add headerToolbar() to API reference and customization guide
ManukMinasyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| @php | ||
| use Filament\Support\Enums\IconSize; | ||
| use Filament\Support\Enums\Width; | ||
| use Filament\Support\Facades\FilamentView; | ||
| use Filament\Support\Icons\Heroicon; | ||
| use Filament\Tables\Enums\FiltersLayout; | ||
| use Filament\Tables\Filters\Indicator; | ||
| use Filament\Tables\View\TablesIconAlias; | ||
| use Filament\Tables\View\TablesRenderHook; | ||
|
|
||
| use function Filament\Support\generate_icon_html; | ||
|
|
||
| $table = $this->getTable(); | ||
| $isFilterable = $table->isFilterable(); | ||
| $isSearchable = $table->isSearchable(); | ||
| $filterIndicators = $table->getFilterIndicators(); | ||
|
|
||
| $filtersLayout = $table->getFiltersLayout(); | ||
| $filtersTriggerAction = $table->getFiltersTriggerAction(); | ||
| $filtersApplyAction = $table->getFiltersApplyAction(); | ||
| $filtersForm = $this->getTableFiltersForm(); | ||
| $filtersFormWidth = $table->getFiltersFormWidth(); | ||
| $filtersFormMaxHeight = $table->getFiltersFormMaxHeight(); | ||
| $filtersResetActionPosition = $table->getFiltersResetActionPosition(); | ||
| $activeFiltersCount = $table->getActiveFiltersCount(); | ||
|
|
||
| if (is_string($filtersFormWidth)) { | ||
| $filtersFormWidth = Width::tryFrom($filtersFormWidth) ?? $filtersFormWidth; | ||
| } | ||
|
|
||
| $hasFiltersDialog = $isFilterable && in_array($filtersLayout, [FiltersLayout::Dropdown, FiltersLayout::Modal]); | ||
| $isModalLayout = ($filtersLayout === FiltersLayout::Modal) || ($hasFiltersDialog && $filtersTriggerAction->isModalSlideOver()); | ||
| @endphp | ||
|
|
||
| <div class="fi-page-header-main-ctn !gap-y-2 !pt-4 !pb-0"> | ||
| {{-- Breadcrumbs --}} | ||
| @if (filled($breadcrumbs)) | ||
| <x-filament::breadcrumbs :breadcrumbs="$breadcrumbs" class="mb-2" /> | ||
| @endif | ||
|
|
||
| {{-- Title row: heading + filter + search --}} | ||
| <div class="flex items-center gap-4"> | ||
| <div class="flex-1 min-w-0"> | ||
| <h1 class="fi-header-heading text-2xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-3xl"> | ||
| {{ $heading }} | ||
| </h1> | ||
|
|
||
| @if (filled($subheading)) | ||
| <p class="fi-header-subheading mt-1 max-w-2xl text-sm text-gray-600 dark:text-gray-400"> | ||
| {{ $subheading }} | ||
| </p> | ||
| @endif | ||
| </div> | ||
|
|
||
| <div class="flex items-center gap-x-6 shrink-0"> | ||
| @if ($isFilterable && $hasFiltersDialog) | ||
| @if ($isModalLayout) | ||
| @php | ||
| $filtersTriggerActionModalAlignment = $filtersTriggerAction->getModalAlignment(); | ||
| $filtersTriggerActionIsModalAutofocused = $filtersTriggerAction->isModalAutofocused(); | ||
| $filtersTriggerActionHasModalCloseButton = $filtersTriggerAction->hasModalCloseButton(); | ||
| $filtersTriggerActionIsModalClosedByClickingAway = $filtersTriggerAction->isModalClosedByClickingAway(); | ||
| $filtersTriggerActionIsModalClosedByEscaping = $filtersTriggerAction->isModalClosedByEscaping(); | ||
| $filtersTriggerActionModalDescription = $filtersTriggerAction->getModalDescription(); | ||
| $filtersTriggerActionVisibleModalFooterActions = $filtersTriggerAction->getVisibleModalFooterActions(); | ||
| $filtersTriggerActionModalFooterActionsAlignment = $filtersTriggerAction->getModalFooterActionsAlignment(); | ||
| $filtersTriggerActionModalHeading = $filtersTriggerAction->getCustomModalHeading() ?? __('filament-tables::table.filters.heading'); | ||
| $filtersTriggerActionModalIcon = $filtersTriggerAction->getModalIcon(); | ||
| $filtersTriggerActionModalIconColor = $filtersTriggerAction->getModalIconColor(); | ||
| $filtersTriggerActionIsModalSlideOver = $filtersTriggerAction->isModalSlideOver(); | ||
| $filtersTriggerActionIsModalFooterSticky = $filtersTriggerAction->isModalFooterSticky(); | ||
| $filtersTriggerActionIsModalHeaderSticky = $filtersTriggerAction->isModalHeaderSticky(); | ||
| @endphp | ||
|
|
||
| <x-filament::modal | ||
| :alignment="$filtersTriggerActionModalAlignment" | ||
| :autofocus="$filtersTriggerActionIsModalAutofocused" | ||
| :close-button="$filtersTriggerActionHasModalCloseButton" | ||
| :close-by-clicking-away="$filtersTriggerActionIsModalClosedByClickingAway" | ||
| :close-by-escaping="$filtersTriggerActionIsModalClosedByEscaping" | ||
| :description="$filtersTriggerActionModalDescription" | ||
| :footer-actions="$filtersTriggerActionVisibleModalFooterActions" | ||
| :footer-actions-alignment="$filtersTriggerActionModalFooterActionsAlignment" | ||
| :heading="$filtersTriggerActionModalHeading" | ||
| :icon="$filtersTriggerActionModalIcon" | ||
| :icon-color="$filtersTriggerActionModalIconColor" | ||
| :slide-over="$filtersTriggerActionIsModalSlideOver" | ||
| :sticky-footer="$filtersTriggerActionIsModalFooterSticky" | ||
| :sticky-header="$filtersTriggerActionIsModalHeaderSticky" | ||
| :width="$filtersFormWidth" | ||
| :wire:key="$this->getId() . '.board.filters'" | ||
| class="fi-ta-filters-modal" | ||
| > | ||
| <x-slot name="trigger"> | ||
| {{ $filtersTriggerAction->badge($activeFiltersCount) }} | ||
| </x-slot> | ||
|
|
||
| {{ $filtersTriggerAction->getModalContent() }} | ||
|
|
||
| {{ $filtersForm }} | ||
|
|
||
| {{ $filtersTriggerAction->getModalContentFooter() }} | ||
| </x-filament::modal> | ||
| @else | ||
| {{-- Wrap in fi-ta-ctn context so Filament's scoped table CSS applies to filters --}} | ||
| <div class="fi-ta-ctn fi-ta-ctn-with-header" style="display: contents;"> | ||
| <div class="fi-ta-header-toolbar" style="display: contents;"> | ||
| <x-filament::dropdown | ||
| :max-height="$filtersFormMaxHeight" | ||
| placement="bottom-end" | ||
| shift | ||
| :flip="false" | ||
| :width="$filtersFormWidth ?? Width::ExtraSmall" | ||
| :wire:key="$this->getId() . '.board.filters'" | ||
| class="fi-ta-filters-dropdown" | ||
| > | ||
| <x-slot name="trigger"> | ||
| {{ $filtersTriggerAction->badge($activeFiltersCount) }} | ||
| </x-slot> | ||
|
|
||
| <x-filament-tables::filters | ||
| :apply-action="$filtersApplyAction" | ||
| :form="$filtersForm" | ||
| :reset-action-position="$filtersResetActionPosition" | ||
| /> | ||
| </x-filament::dropdown> | ||
| </div> | ||
| </div> | ||
| @endif | ||
| @endif | ||
|
|
||
| @if ($isSearchable) | ||
| <x-filament-tables::search-field | ||
| :debounce="$table->getSearchDebounce()" | ||
| :on-blur="$table->isSearchOnBlur()" | ||
| :placeholder="$table->getSearchPlaceholder()" | ||
| /> | ||
| @endif | ||
| </div> | ||
| </div> | ||
|
|
||
| {{-- Active filter indicators --}} | ||
| @if ($filterIndicators) | ||
| @if (filled($filterIndicatorsView = FilamentView::renderHook(TablesRenderHook::FILTER_INDICATORS, scopes: static::class, data: ['filterIndicators' => $filterIndicators]))) | ||
| {{ $filterIndicatorsView }} | ||
| @else | ||
| <div class="fi-ta-filter-indicators flex items-center gap-x-2"> | ||
| <div class="flex flex-wrap items-center gap-1"> | ||
| @foreach ($filterIndicators as $indicator) | ||
| <x-filament::badge :color="$indicator->getColor()"> | ||
| {{ $indicator->getLabel() }} | ||
|
|
||
| @if ($indicator->isRemovable()) | ||
| <x-slot | ||
| name="deleteButton" | ||
| :label="__('filament-tables::table.filters.actions.remove.label')" | ||
| :wire:click="$indicator->getRemoveLivewireClickHandler()" | ||
| wire:loading.attr="disabled" | ||
| wire:target="removeTableFilter" | ||
| ></x-slot> | ||
| @endif | ||
| </x-filament::badge> | ||
| @endforeach | ||
| </div> | ||
|
|
||
| @if (collect($filterIndicators)->contains(fn (Indicator $indicator): bool => $indicator->isRemovable())) | ||
| <button | ||
| type="button" | ||
| x-tooltip="{ | ||
| content: @js(__('filament-tables::table.filters.actions.remove_all.tooltip')), | ||
| theme: $store.theme, | ||
| }" | ||
| wire:click="removeTableFilters" | ||
| wire:loading.attr="disabled" | ||
| wire:target="removeTableFilters,removeTableFilter" | ||
| class="fi-icon-btn fi-size-sm" | ||
| > | ||
| {{ generate_icon_html(Heroicon::XMark, alias: TablesIconAlias::FILTERS_REMOVE_ALL_BUTTON, size: IconSize::Small) }} | ||
| </button> | ||
| @endif | ||
| </div> | ||
| @endif | ||
| @endif | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <x-filament-panels::page> | ||
| <div class="h-[calc(100vh-11rem)]"> | ||
| <div class="h-[calc(100vh-11rem)] relative" style="z-index: 0;"> | ||
| {{ $this->board }} | ||
| </div> | ||
| </x-filament-panels::page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.