skoyah / nova-toasted
自定义并创建您的Laravel Nova通知。
v0.1
2020-04-07 11:44 UTC
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-09-20 17:02:56 UTC
README
一个用于自定义Laravel Nova Toasted通知的包。
安装
composer require skoyah/nova-toasted
php artisan vendor:publish --tag=nova-toasted
在发布资产后,在您的config
文件夹中现在有一个toasted.php
文件,其中包含Nova和Toasted插件本身使用的默认选项。您可以自由地根据您的需求更改它们。有关这些值的信息,请参阅Toasted文档
toasts
键是您将注册所有自定义Toasted组件的位置
'toasts' => [ [ 'name' => 'forbidden', 'message' => 'Sorry! You are not authorized.', 'options' => [ 'type' => 'error', 'duration' => 2000, ], ], ],
使用方法
在注册组件后,您可以使用它们全局使用,形式如下
this.$toasted.forbidden(); //inside vue components Nova.bus.$toasted.forbidden(); //globally available
此外,您仍然可以为特定情况使用自定义消息和选项
this.$toasted.forbidden('Access denied.', { duration: 5000 });
样式
为了样式化您的自定义主题和Toasted组件以及覆盖默认组件,在您的CSS文件中
/* styling your custom theme */ .my-custom-theme { //... } /* use this classes override default components */ .toasted.default { //... } .toasted.success { //... } .toasted.error { //... } .toasted.info { //... } .toasted.warning { //... } /* custom components */ .toasted.forbidden { //... }
示例
.my-theme { padding: 20px !important; color: white; } .toasted.forbidden { background-color: blueviolet; }