wika-group/livewire-slide-over
Installation:
composer require wika-group/livewire-slide-over
Add the Livewire directive to your master layout (e.g., resources/views/layouts/app.blade.php):
@livewire('slide-over-panel')
Create a Slide Over Component:
php artisan make:livewire ShoppingCart
Update the generated component (app/Http/Livewire/ShoppingCart.php) to extend SlideOverComponent:
use WikaGroup\LivewireSlideOver\SlideOverComponent;
class ShoppingCart extends SlideOverComponent
{
public $title = "My Cart";
public $width = "400px"; // Default width
}
Trigger the Slide Over:
Use the @slideOver directive in your Blade view:
<button wire:click="$emit('openSlideOver', 'ShoppingCart')">Open Cart</button>
Render the Slide Over:
Define a slot in your component’s Blade template (resources/views/livewire/shopping-cart.blade.php):
<x-slide-over :title="$title" :width="$width">
<div class="p-4">
<!-- Your slide over content -->
<p>Cart items go here.</p>
</div>
</x-slide-over>
State Management:
$isOpen, $width, $position) to control visibility and dimensions dynamically.public function toggle()
{
$this->isOpen = !$this->isOpen;
}
<button wire:click="toggle">Toggle Slide Over</button>
Nested Slide Overs:
public $slideOverId = 'nested-cart'; // Unique identifier
Trigger from a child component:
@slideOver('nested-cart')
Dynamic Content:
<x-slide-over :title="$title">
@slot('content')
<livewire:child-component :data="$data" />
@endslot
</x-slide-over>
Integration with Livewire Actions:
$emit and $listen to sync slide over state with other components:
public function mount()
{
$this->listenFor('openSlideOver');
}
public function openSlideOver()
{
$this->isOpen = true;
}
resources/views/vendor/wika-group/livewire-slide-over/slide-over.blade.php).slide-over.js file in the package’s resources directory.aria-modal, aria-hidden) to the slide over’s root element.Namespace Conflicts:
batnieluyo/livewire-slide-over, ensure all usages of WireComponents\LivewireSlideOvers\SlideOverComponent are replaced with WikaGroup\LivewireSlideOver\SlideOverComponent. Run the upgrade script if needed:
php ./vendor/bin/slideover-upgrade
Z-Index Management:
z-index of the slide over container (default: 1050 in the package’s styles).State Persistence:
$isOpen) is tied to the component’s lifecycle. Avoid relying on it across page reloads unless persisted (e.g., via session or database).Multiple Instances:
$slideOverId). Duplicate IDs will cause rendering issues.@livewire('slide-over-panel') directive in the layout.ShoppingCart class name).Livewire::configureDebugMode(); // In a service provider or config file
Reusable Slide Over Templates:
BaseSlideOver) that extends SlideOverComponent and includes common UI elements (e.g., headers, footers). Extend this for specific use cases.Conditional Rendering:
if directive to conditionally render slide overs based on logic:
@if($showSlideOver)
@slideOver('unique-id')
@endif
Performance:
defer or dynamic components to reduce initial load time.Testing:
$this->livewire(ShoppingCart::class)
->call('toggle')
->assertSet('isOpen', true);
Custom Events:
slide-over-opened) for analytics or additional logic:
// In slide-over.js
document.addEventListener('slide-over-opened', (e) => {
console.log('Slide over opened:', e.detail.id);
});
How can I help you explore Laravel packages today?