Skip to content

Commit

Permalink
Speed improvement by replacing View composer (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
arukompas authored Jul 5, 2022
1 parent 96c8937 commit 8daf260
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 0 additions & 10 deletions src/LivewireModalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,5 @@ public function configurePackage(Package $package): void
public function bootingPackage(): void
{
Livewire::component('livewire-ui-modal', Modal::class);

View::composer('livewire-ui-modal::modal', function ($view) {
if (config('livewire-ui-modal.include_js', true)) {
$view->jsPath = __DIR__.'/../public/modal.js';
}

if (config('livewire-ui-modal.include_css', false)) {
$view->cssPath = __DIR__ . '/../public/modal.css';
}
});
}
}
13 changes: 12 additions & 1 deletion src/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ public function getListeners(): array

public function render(): View
{
return view('livewire-ui-modal::modal');
if (config('livewire-ui-modal.include_js', true)) {
$jsPath = __DIR__.'/../public/modal.js';
}

if (config('livewire-ui-modal.include_css', false)) {
$cssPath = __DIR__ . '/../public/modal.css';
}

return view('livewire-ui-modal::modal', [
'jsPath' => $jsPath ?? null,
'cssPath' => $cssPath ?? null,
]);
}
}

0 comments on commit 8daf260

Please sign in to comment.