dlogon/tailwind-alerts
Composer 安装命令:
composer require dlogon/tailwind-alerts
包简介
create tailwind alerts from static
README 文档
README
Add tailwind alerts to your page with a single facade call
TailwindAlerts::addSessionMessage("This beautifull asset as been saved", TailwindAlerts::SUCCESS);
Installation
You can install the package via composer:
composer require dlogon/tailwind-alerts
You need tailwind V2 or V3 and you need to check if your project has the default_alert_colors in your tailwind config file, if not, you can export the config file to change the default colors, or simply you can pass the background color you want in the level parameter, or you can add the config file inside the content node on module exports in your tailwind config file
const defaultTheme = require('tailwindcss/defaultTheme'); /** @type {import('tailwindcss').Config} */ module.exports = { content: [ './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', './storage/framework/views/*.php', './resources/views/**/*.blade.php', './vendor/dlogon/tailwind-alerts/config/tailwind-alerts.php', ], theme: { extend: { fontFamily: { sans: ['Nunito', ...defaultTheme.fontFamily.sans], }, }, }, plugins: [require('@tailwindcss/forms')], };
You can publish the config file with:
php artisan vendor:publish --provider="Dlogon\TailwindAlerts\TailwindAlertsServiceProvider" --tag="config"
This is the contents of the published config file:
"default_alert_colors" => [ "SUCCESS" => "bg-green-500", "ERROR" => "bg-red-500", "WARNING" => "bg-yellow-500", "INFO" => "bg-blue-500" ], "session_name" => env("TAILWIND_ALERTS", "tailwind_alerts"), "new_colors" => []
Usage
add this Blade template
inside your viewport html wrapper
@tailwind_alerts
or you can choose the component style
<x-tailwindalerts::tailwind-alert/>
Then, you can use the facade in any part of your code to add a toast message
namespace App\Http\Controllers; use App\Models\MyModel; use Dlogon\TailwindAlerts\Facades\TailwindAlerts; class MyController extends Controller { ... public function store(Request $request) { TailwindAlerts::addSessionMessage("This beautifull asset as been saved", TailwindAlerts::SUCCESS); Mymodel::create($request->all()) return redirect()->route("My.index"); } ... });
the default position and type of the alert is bottom toast, you can use 4 types of alerts, calling the addSessionMessage whit the correct parameters, or calling the helper functions
Then, you can use the facade in any part of your code to add a toast message
use Dlogon\TailwindAlerts\Facades\TailwindAlerts; TailwindAlerts::addSessionMessage("Bottom toast", "bg-red-300", TailwindAlerts::BOTTOM_TOAST_CONTAINER, TailwindAlerts::TOAST_TEMPLATE ); TailwindAlerts::addBottomToastMessage("Another bottom toast", TailwindAlerts::ERROR); TailwindAlerts::addTopToastMessage("Top toast", TailwindAlerts::WARNING); TailwindAlerts::addHeaderMessage("Header line", TailwindAlerts::ERROR); TailwindAlerts::addFooterMessage("Footer line", TailwindAlerts::DEFAULT_ALERT);
Result
If your response is not a redirect response, then you should set the
$IsResponseRedirect static variable to false using the method setResponseRedirect(bool $value) if you use the helper functions, or you can set the last parameter in addSessionMessage() to false
use Dlogon\TailwindAlerts\Facades\TailwindAlerts; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; Route::get('/', function () { TailwindAlerts::setResponseRedirect(false); TailwindAlerts::addSessionMessage("Welcome", TailwindAlerts::SUCCESS); return view('welcome'); });
Where you use the component, you are able to use a javascript function to show alerts
AlertToast.showToast("An error", AlertToast.ERROR, AlertToast.TOP_TOAST_CONTAINER, AlertToast.TOAST_TEMPLATE)
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
dlogon/tailwind-alerts 适用场景与选型建议
dlogon/tailwind-alerts 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 312 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「toast」 「tailwind-alerts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dlogon/tailwind-alerts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dlogon/tailwind-alerts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dlogon/tailwind-alerts 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Add Notyf support in your Laravel app
Beautiful toast notifications for Laravel + Inertia.js applications. Fluent PHP API, multi-toast support, redirect-safe, with Vue 3 and React adapters.
Simple Livewire notifications system without any dependencies except TALL-stack.
Alfabank REST API integration
lightweight toast notification package for laravel
A bootstrap 4 toast wrapper for Laravel
统计信息
- 总下载量: 312
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-14

