Skip to content

Commit

Permalink
Separate config for alert and confirm (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
jantinnerezo authored Dec 27, 2020
1 parent 8cdf191 commit fce150d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
* https://sweetalert2.github.io/#configuration
*/
return [
'position' => 'top-end',
'timer' => 3000,
'toast' => true,
'text' => null,
'showCancelButton' => true,
'showConfirmButton' => false,
'alert' => [
'position' => 'top-end',
'timer' => 3000,
'toast' => true,
'text' => null,
'showCancelButton' => true,
'showConfirmButton' => false,
],
'confirm' => [
'position' => 'center',
'toast' => false,
'timer' => null,
'showConfirmButton' => true,
'cancelButtonText' => 'No'
]
];
6 changes: 3 additions & 3 deletions src/LivewireAlertServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function registerViews()
protected function registerAlertMacro()
{
Component::macro('alert', function ($type = 'success', $message = '', $options = []) {
$options = array_merge(config('livewire-alert'), $options);
$options = array_merge(config('livewire-alert.alert'), $options);

$this->dispatchBrowserEvent('alert', [
'type' => $type,
Expand All @@ -41,7 +41,7 @@ protected function registerAlertMacro()
public function registerFlashMacro()
{
Component::macro('flash', function ($type = 'success', $message = '', $options = []) {
$options = array_merge(config('livewire-alert'), $options);
$options = array_merge(config('livewire-alert.alert'), $options);

session()->flash('livewire-alert', [
'type' => $type,
Expand All @@ -54,7 +54,7 @@ public function registerFlashMacro()
public function registerConfirmMacro()
{
Component::macro('confirm', function ($title, $options = []) {
$options = array_merge(config('livewire-alert'), $options);
$options = array_merge(config('livewire-alert.confirm'), $options);

$identifier = (string) Str::uuid();

Expand Down

0 comments on commit fce150d

Please sign in to comment.