定制 mrjokermr/dynamic-toasts 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrjokermr/dynamic-toasts

最新稳定版本:v1.1.2

Composer 安装命令:

composer require mrjokermr/dynamic-toasts

包简介

Dynamic toasts for livewire

README 文档

README

Simple Livewire 3 toast messages package

Compatible with any css framework & no CDN requirements. (Uses native inline css styling & svg icons.)

Example

Installation

Install via composer:

  composer require mrjokermr/dynamic-toasts

Place the Livewire component right before the closing body tag in your layout (for example in resources/views/layouts/app.blade.php)

@livewire('dynamic-toasts')
</body>

Usage/Examples

use Mrjokermr\DynamicToasts\Classes\ToastMessage;
use Mrjokermr\DynamicToasts\Enums\ToastMessageType;
use Mrjokermr\DynamicToasts\Livewire\DisplayDynamicToasts;

$this->dispatch(
    DisplayDynamicToasts::NEW_TOAST_EVENT,
    ToastMessage::make(
        message: "Hello GitHub",
        type: ToastMessageType::INFO
    ),
);

//or use session->flash() when wanting to display a toast message after redirecting
session()->flash(
    DisplayDynamicToasts::FLASH_TOAST_EVENT,
    ToastMessage::make(
        message: __('toasts.scheduled', ['name' => __('shared.visit')]),
        type: ToastMessageType::POSITIVE
    )
);

Available types:

use Mrjokermr\DynamicToasts\Enums\ToastMessageType;

ToastMessageType::INFO
ToastMessageType::SUCCESS
ToastMessageType::POSITIVE
ToastMessageType::NEGATIVE
ToastMessageType::FAILURE
ToastMessageType::WARNING

Customization:

Without icon:

Add the ->hideIcon() function.

Example:

$this->dispatch(
    DisplayDynamicToasts::NEW_TOAST_EVENT,
    ToastMessage::make(
        message: "Hello GitHub",
        type: ToastMessageType::INFO
    )->hideIcon(),
);

Set expiration time:

Add the ->setExpiresAtSeconds() function.

Example:

$this->dispatch(
    DisplayDynamicToasts::NEW_TOAST_EVENT,
    ToastMessage::make(
        message: "Hello GitHub",
        type: ToastMessageType::INFO
    )->setExpiresAtSeconds(seconds: 12),
);

Config

php artisan vendor:publish --tag=dynamic-toasts-config

You might change the background color and text color for each individual pop up type, or the default toast duration. default config:

return [
    'default_seconds' => 5,
    'default_value_show_icon' => true,

    'styles' => [
        'positive' => [
            'background-color' => '#00c950',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
        'success' => [
            'background-color' => '#00c950',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
        'negative' => [
            'background-color' => '#fb2c36',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
        'failure' => [
            'background-color' => '#fb2c36',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
        'warning' => [
            'background-color' => '#fe9a00',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
        'info' => [
            'background-color' => '#fe9a00',
            'text-color' => '#fcfcfc',
            'class' => null,
        ],
    ],
];

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-09-05