azenox / flashmcqueen
基于会话的PHP闪存消息
1.0
2021-03-09 10:50 UTC
This package is auto-updated.
Last update: 2024-09-16 02:42:26 UTC
README
基于会话的PHP闪存消息。
将消息存储在会话中,并在需要时显示它们。
特性
- 自定义图标、颜色或使用预定义函数
- 命名空间
- 持久消息
安装
通过composer
composer require azenox/flashmcqueen
通过文件(从本存储库下载PHP文件(以及如果需要,样式文件))。
require '/path/to/FlashMcQueen.php';
使用方法
require '/path/to/FlashMcQueen.php'; use AzenoX\FlashMcQueen; if(!session_id()) session_start(); $flash = new FlashMcQueen(); $flash->success("A Success Message", true, [], true); $flash->error("An Error Message"); $flash->warning("A Warning Message"); $flash->info("An Informational Message"); $flash->custom("Am a Fish", '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M21 11c0-.552-.448-1-1-1s-1 .448-1 1c0 .551.448 1 1 1s1-.449 1-1m3 .486c-1.184 2.03-3.29 4.081-5.66 5.323-1.336-1.272-2.096-2.957-2.103-4.777-.008-1.92.822-3.704 2.297-5.024 2.262.986 4.258 2.606 5.466 4.478m-6.63 5.774c-.613.255-1.236.447-1.861.573-1.121 1.348-2.796 2.167-5.287 2.167-.387 0-.794-.02-1.222-.061.647-.882.939-1.775 1.02-2.653-2.717-1.004-4.676-2.874-6.02-4.287-1.038 1.175-2.432 2-4 2 1.07-1.891 1.111-4.711 0-6.998 1.353.021 3.001.89 4 1.999 1.381-1.2 3.282-2.661 6.008-3.441-.1-.828-.399-1.668-1.008-2.499.429-.04.837-.06 1.225-.06 2.467 0 4.135.801 5.256 2.128.68.107 1.357.272 2.019.495-1.453 1.469-2.271 3.37-2.263 5.413.008 1.969.773 3.799 2.133 5.224"/></svg>', '#00BCD4', true); $flash->display();
请随意使用和修改src/目录下的 style.css 来美化消息。
所有方法列表
成功
$flash->success(string $msg, bool $persistent = false, array $delays = [], bool $floatingIcon = false);
- $msg: 显示的消息
- $persistent: 如果消息将在屏幕上保留直到用户移除它则为true(默认:false)
- $delays: 这是一个包含3个可选键的关联数组
- fadeIn(默认:1):淡入动画的秒数
- stay(默认:5):消息在屏幕上显示的秒数
- fadeOut(默认:1):淡出动画的秒数
- $floatingIcon: 如果图标应该被动画化则为true
错误
$flash->error(string $msg, bool $persistent = false, array $delays = [], bool $floatingIcon = false);
- $msg: 显示的消息
- $persistent: 如果消息将在屏幕上保留直到用户移除它则为true(默认:false)
- $delays: 这是一个包含3个可选键的关联数组
- fadeIn(默认:1):淡入动画的秒数
- stay(默认:5):消息在屏幕上显示的秒数
- fadeOut(默认:1):淡出动画的秒数
- $floatingIcon: 如果图标应该被动画化则为true
警告
$flash->warning(string $msg, bool $persistent = false, array $delays = [], bool $floatingIcon = false);
- $msg: 显示的消息
- $persistent: 如果消息将在屏幕上保留直到用户移除它则为true(默认:false)
- $delays: 这是一个包含3个可选键的关联数组
- fadeIn(默认:1):淡入动画的秒数
- stay(默认:5):消息在屏幕上显示的秒数
- fadeOut(默认:1):淡出动画的秒数
- $floatingIcon: 如果图标应该被动画化则为true
信息
$flash->info(string $msg, bool $persistent = false, array $delays = [], bool $floatingIcon = false);
- $msg: 显示的消息
- $persistent: 如果消息将在屏幕上保留直到用户移除它则为true(默认:false)
- $delays: 这是一个包含3个可选键的关联数组
- fadeIn(默认:1):淡入动画的秒数
- stay(默认:5):消息在屏幕上显示的秒数
- fadeOut(默认:1):淡出动画的秒数
- $floatingIcon: 如果图标应该被动画化则为true
自定义
$flash->custom(string $msg, string $icon, string $color, bool $persistent = false, array $delays = [], bool $floatingIcon = false);
- $msg: 显示的消息
- $icon: 可以是任何字符或任何SVG
- $color: 一个十六进制颜色(以'#'开头)
- $persistent: 如果消息将在屏幕上保留直到用户移除它则为true(默认:false)
- $delays: 这是一个包含3个可选键的关联数组
- fadeIn(默认:1):淡入动画的秒数
- stay(默认:5):消息在屏幕上显示的秒数
- fadeOut(默认:1):淡出动画的秒数
- $floatingIcon: 如果图标应该被动画化则为true
关于
这是我的第一个大型项目,如果有任何错误或您想让我添加/修改某些内容,请告诉我。