codewithdennis / filament-simple-alert
为您的 filament 页面添加简单警报的插件
v3.0.4
2024-09-20 12:17 UTC
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.16
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
This package is auto-updated.
Last update: 2024-09-20 12:18:05 UTC
README
此包为 Filament 应用程序提供简单易用的警报组件。它允许您快速实现可定制的警报消息,通过提供清晰简洁的通知来提升用户体验。
安装
您可以通过 composer 安装此包。
composer require codewithdennis/filament-simple-alert
确保将以下内容添加到您的 `tailwind.config.js` 文件中。
'./vendor/codewithdennis/filament-simple-alert/resources/**/*.blade.php',
已在带有 Tailwind 的项目中设置好了 filament 吗?
如果您已经将 filament 安装到包含 Tailwind 的现有项目中,那么您需要[发布一个自定义主题](https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme),以便正确应用样式。
用法
警报可以在您的 infolists
或 forms
中使用,确保您选择了正确的组件。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert;
use CodeWithDennis\SimpleAlert\Components\Forms\SimpleAlert;
简单警报
有 4 种类型的简单警报:危险
、信息
、成功
和 警告
。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->danger() ->info() ->success() ->warning()
如果您想使用不同的颜色,可以使用 color
方法。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->color('purple')
图标
默认情况下,所有简单警报都将有一个图标。如果您想更改图标,可以使用 icon
方法。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->color('purple') ->icon('heroicon-s-users')
标题
您可以通过 title
方法向警报添加标题。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->title('Hoorraayy! Your request has been approved! 🎉')
描述
您可以通过 description
方法向警报添加描述。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->description('This is the description')
链接
您还可以通过 link
方法向警报添加链接。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->info() ->link('https://filamentphp.com'),
如果您想自定义链接标签,可以使用 linkLabel
方法。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->info() ->link('https://filamentphp.com') ->linkLabel('Read more!'),
如果您想在新标签页中打开链接,可以使用 linkBlank
方法。
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->info() ->link('https://filamentphp.com') ->linkBlank(),
示例
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert; SimpleAlert::make() ->success() ->title(new HtmlString('<strong>Hoorraayy! Your request has been approved! 🎉</strong>')) ->description('Lorem ipsum dolor sit amet consectetur adipisicing elit.') ->link('https://filamentphp.com') ->linkLabel('Read more!') ->linkBlank(),
截图
贡献
请参阅 CONTRIBUTING 以获取详细信息。
致谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。