Installation:
composer require awcodes/pounce
Theme Integration (required for Filament Panels):
Update tailwind.config.js to include Pounce's views:
content: [
'./vendor/awcodes/pounce/resources/**/*.blade.php',
// ... other paths
]
Run npm run dev or npm run build.
Register Plugin (for Filament Panels):
public function panel(Panel $panel): Panel {
return $panel->plugins([
\Awcodes\Pounce\PouncePlugin::make(),
]);
}
First Modal Usage:
use Awcodes\Pounce\Facades\Pounce;
// Trigger modal
Pounce::modal('Confirm Action')
->content('Are you sure you want to proceed?')
->acceptButton('Delete')
->cancelButton('Cancel')
->accept(function () {
// Handle acceptance
})
->cancel(function () {
// Handle cancellation
})
->mount();
Dynamic Modal Content: Use Blade views or dynamic strings for content:
Pounce::modal('Dynamic Content')
->content(view('modals.custom-modal', ['data' => $data]))
->mount();
Form Integration: Combine with Filament Forms for rich interactions:
Pounce::modal('Edit Record')
->content(
Form::make()
->schema([
TextInput::make('name')->required(),
])
->getWidget()
)
->accept(function (array $data) {
// Save logic
})
->mount();
Reusable Modal Components: Create a service class for consistent modal patterns:
class ModalService {
public function confirm(string $title, string $message, callable $onAccept) {
Pounce::modal($title)
->content($message)
->accept($onAccept)
->cancel(function () {})
->mount();
}
}
Panel-Specific Modals: Scope modals to specific panels by registering the plugin per-panel.
Livewire Integration: Mount modals from Livewire components:
public function mount() {
Pounce::modal('Livewire Modal')
->content('Content from Livewire')
->mount();
}
content() method:
->content('<div class="p-6 bg-gray-100">...</div>')
small, large):
->size('large')
aria-label or aria-describedby for screen readers:
->content('<div id="modal-content" aria-describedby="modal-desc">...</div>')
Theme Dependency:
Livewire Conflicts:
wire:ignore on modal content or lazy-load components.Event Handling:
accept()/cancel() may not persist across requests.wire:model.live or store logic in a service class.Styling Overrides:
tailwind.config.js.content().Z-Index Conflicts:
z-index in your theme’s CSS:
.pounce-modal { z-index: 50; }
Modal Not Showing?:
npm run dev was executed post-theme update.Closures Not Triggering:
dd() in closures to debug execution flow.Custom Animations:
Extend the modal’s Alpine.js logic in resources/js/pounce.js:
document.addEventListener('alpine:init', () => {
Alpine.data('pounce', () => ({
// Override transition logic
}));
});
Global Modal State: Use Alpine’s reactivity to manage state across modals:
->content('<div x-data="...">...</div>')
Server-Side Logic: Offload heavy processing to Livewire or controllers to avoid blocking the UI.
Testing: Use Filament’s testing helpers to assert modal interactions:
$this->assertModalOpened('Confirm Action');
$this->assertModalClosed();
content() for i18n support.How can I help you explore Laravel packages today?