yii-extension / alert-flash-tailwind
该包最新版本(dev-master)没有可用的许可信息。
Alert Flash Tailwind 小部件。
该包的官方仓库似乎已不存在,因此该包已被冻结。
dev-master / 1.0.x-dev
2021-09-29 10:37 UTC
Requires
- php: ^7.4|^8.0
- yii-extension/asset-tailwind: ^1.0.0
- yii-extension/widgets: ^1.0.0
- yiisoft/session: ^1.0
Requires (Dev)
- nyholm/psr7: ^1.4.0
- phpunit/phpunit: ^9.5
- roave/infection-static-analysis-plugin: ^1.8
- vimeo/psalm: ^4.8
- yiisoft/var-dumper: ^1.1.0
- dev-master / 1.0.x-dev
- dev-dependabot/composer/vimeo/psalm-tw-5.8
- dev-dependabot/github_actions/actions/cache-3.3.0
- dev-dependabot/composer/yiisoft/session-tw-2.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.24.0
- dev-dependabot/github_actions/actions/checkout-3.3.0
- dev-dependabot/github_actions/codecov/codecov-action-3.1.1
This package is auto-updated.
Last update: 2024-01-10 06:44:22 UTC
README
Alert Flash Tailwind 小部件
安装
composer require yii-extension/alert-flash-tailwind
使用方法
这些小部件不会注册任何资源,您必须为 Tailwind Css 框架 注册资源
在控制器或操作中
<?php declare(strict_types=1); namespace App\Action; use Psr\Http\Message\ResponseInterface; use Yiisoft\Session\Flash\Flash; final class Action { public function index(Flash $flash): ResponseInterface { $flash->add( 'danger', // types: [danger, info, success, warning] [ 'body' => '<b>Holy smokes!</b> Something seriously bad happened.' // Its mandatory. ], true ); } }
在布局中
<?php declare(strict_types=1); use Yii\Extension\Tailwind\AlertFlash; use Yiisoft\Session\Flash\Flash; /** @var Flash $flash */ ?> <?= AlertFlash::widget([$flash]) ->bodyClass('align-middle flex-grow inline-block mr-8') ->bodyTag('p') ->buttonLabel('×') ->buttonOnClick('closeAlert()') ->iconAttributes(['class' => 'fa-2x pr-2']) ->class('flex font-bold items-center px-4 py-3 text-sm text-white') ->layoutBody('{icon}{body}{button}') ->render(); ?>
Html输出
<div id="w0-alert" class="bg-red-600 flex font-bold items-center px-4 py-3 text-sm text-white" role="alert"> <div><i class="fa-2x pr-2 far fa-times-circle"></i></div> <p class="align-middle flex-grow inline-block mr-8"><b>Holy smokes!</b> Something seriously bad happened.</p> <button type="button" class="float-right px-4 py-3" onclick="closeAlert()">×</button> </div>
注意:Tailwind 不提供任何用于关闭 AlertFlash 的 JavaScript 实现,因此您需要自行实现。
示例 JavaScript
function closeAlert() { document.getElementById('w0-alert').style.display = 'none'; }
单元测试
该包使用 PHPUnit 进行测试。要运行测试
./vendor/bin/phpunit
突变测试
该包的测试使用 Infection 突变框架进行检查。要运行它
./vendor/bin/infection
静态分析
代码使用 Psalm 进行静态分析。要运行静态分析
./vendor/bin/psalm
许可
Yii Packages 的 yii-extension/alert-flash-tailwind
是自由软件。
它根据 BSD 许可协议发布。有关更多信息,请参阅 LICENSE
。
由 Yii Extension 维护。