rezaulhreza/flash-toast

使用 TALL stack 构建的流畅提示管理器。


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

演示项目

FlashToast 演示

安装

您可以通过 composer 安装此软件包

composer require rezaulhreza/flash-toast

然后发布配置文件

php artisan vendor:publish --tag="flash-toast-config"

发布视图文件

php artisan vendor:publish --tag="flash-toast-views"

发布文件后,将文件从 resources\views\vendor\flash-toast\components 移动到 resources\views\components。现在您可以将文件放置在任何您想要的位置,例如 .

或者,只需这样做

@include('vendor.flash-toast.components.flash-toast')

用法

与 TALL stack 一同运行:Laravel、TailwindCSS、Livewire、AlpineJS。

指南

可用方法:success - info - warning - danger。标题,HTML,级别,持续时间。

在组件类中使用 FlashToast

在组件类中:示例

$this->toastInfo('this is a info toast');
$this->toastSuccess('this is a successful toast');

当然,以上都是可定制的。

要添加 HTML 代码、标题或持续时间,甚至自定义级别(级别是提示的类型,例如 - 成功、信息等)。示例

use FlashToast; // don't forget to import it!!!
$this->toastSuccess('This is a string message');

注意:为了在 README 中展示用法,故意留下了一个空格,否则会编译 markdown 预览中的 h1。在使用应用程序场景时请使用实际标记。

Blade 组件

component/toast.blade.php

样式在 blade 文件中,但是您可以自定义它

以下是一个示例

<?php
namespace Rezaulhreza\FlashToast\Example;

use Livewire\Component;
use Rezaulhreza\FlashToast\FlashToast;

class FlashToastExample extends Component
{

    public function stringMessage()
    {
        $this->toastSuccess('This is a string message');
    }

    public function text()
    {
        $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->text('Some text'));
    }

    public function html()
    {
        $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->title('My title')->level('warning')->html('<h2 class="text-2xl">Sub title</h2> <b>Warning</b>'));
    }

    public function duration()
    {
        $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->text('Showing for 200 ms')->showForMilliseconds(200));
    }

    public function render()
    {
        return view('flash-toast-example');
    }
}

测试

composer test

变更日志

请参阅CHANGELOG 了解最近更改的信息。

贡献

请参阅CONTRIBUTING 了解详细信息。

安全

如果您发现任何与安全相关的问题,请通过电子邮件emailrezahere@gmail.com 发送,而不是使用问题跟踪器。

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件