diff --git a/app/Livewire/Card/CardComponent.php b/app/Livewire/Card/CardComponent.php index 40a7afb..4575485 100644 --- a/app/Livewire/Card/CardComponent.php +++ b/app/Livewire/Card/CardComponent.php @@ -10,9 +10,12 @@ use Domain\Timelog\Actions\CreateTimelogAction; use Illuminate\Contracts\View\View; use Livewire\Component; +use Support\Helpers\Concerns\UseNotice; class CardComponent extends Component { + use UseNotice; + public Card $card; protected $listeners = [ @@ -30,6 +33,7 @@ public function start(): void } $this->refreshCard($currentCard); + $this->success('Task started successfully.'); } public function stop(): void @@ -41,6 +45,7 @@ public function stop(): void CreateTimelogAction::run($currentCard); $this->refreshCard($currentCard); + $this->success('Task Stoped successfully.'); } public function delete(): void @@ -50,6 +55,7 @@ public function delete(): void $this->card->delete(); $this->dispatch("bucket-$bucketId-updated"); + $this->success('Task Deleted successfully.'); } public function render(): View diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 581face..9b9a38c 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -8,3 +8,7 @@ window.addEventListener('refresh.preline.dropdown', () => { setTimeout(() => HSDropdown.autoInit(), 1000); }); + +window.addEventListener('notice.add', (event) => { + Livewire.dispatch('notice', event.detail[0]); +}); diff --git a/resources/views/components/icons/close.blade.php b/resources/views/components/icons/close.blade.php new file mode 100644 index 0000000..bd006d3 --- /dev/null +++ b/resources/views/components/icons/close.blade.php @@ -0,0 +1,3 @@ +twMerge('size-6') }} xmlns="http://www.w3.org/2000/svg" fill="fillColor" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> + + diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index b153e13..9aa918e 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -20,7 +20,9 @@
{{ $slot }}
+ @livewire('wire-elements-modal') @vite('resources/assets/js/app.js') + @stack('javascript') diff --git a/resources/views/components/utils/notice.blade.php b/resources/views/components/utils/notice.blade.php new file mode 100644 index 0000000..94eaf1f --- /dev/null +++ b/resources/views/components/utils/notice.blade.php @@ -0,0 +1,66 @@ +{{-- @see https://codepen.io/KevinBatdorf/pen/JjGKbMa?editors=1010 --}} +
+
+ +
+
+ +@push('javascript') + +@endpush diff --git a/src/Support/Helpers/Concerns/UseNotice.php b/src/Support/Helpers/Concerns/UseNotice.php new file mode 100644 index 0000000..fae0b24 --- /dev/null +++ b/src/Support/Helpers/Concerns/UseNotice.php @@ -0,0 +1,39 @@ +notice('info', $message,); + } + + public function success(string $message): void + { + $this->notice('success', $message,); + } + + public function warning(string $message): void + { + $this->notice('warning', $message,); + } + + public function error(string $message): void + { + $this->notice('error', $message,); + } + + public function notice(string $type, string $message): void + { + $this->dispatch( + 'notice.add', + [ + 'type' => $type, + 'text' => $message, + ] + ); + } +}