Last active
October 3, 2024 09:35
-
-
Save PierreLebedel/e6a4f2f49483ea95fa852bb706405797 to your computer and use it in GitHub Desktop.
TallStackUI component to show toast message on Livewire event (to replace Jetstream action-message component for example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@props(['on', 'method'=>'success', 'title'=>null]) | |
@php | |
if( !in_array($method, ['success', 'warning', 'error', 'info']) ){ | |
$method = 'info'; | |
} | |
if( empty($title) && $slot->isEmpty() ){ | |
$title = __('Success'); | |
} | |
@endphp | |
<div x-data="{ | |
description: @js($slot->isEmpty() ? null : $slot->toHtml()), | |
title: @js($title), | |
}" x-init="@this.on('{{ $on }}', () => { | |
$interaction('toast').{{ $method }}(title, description).send(); | |
})"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{-- The toast will be fired on `saved` Livewire event --}} | |
<x-toast-message on="saved" :title="__('Saved.')"> | |
{{ __('Your content is saved.') }} | |
</x-toast-message> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment