awcodes/pounce
Composer 安装命令:
composer require awcodes/pounce
包简介
A global modal/dialog plugin for Filament.
README 文档
README
This plugin adds a global modal for usage in Filament and is a port of Wire Elements Modal.
Please star the original repo if you like this plugin.
Installation
You can install the package via composer:
composer require awcodes/pounce
Important
If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs for creating a custom theme first.
After setting up your theme, add the plugin's views to your tailwind.config.js file and run npm run dev or npm run build to add the plugin styles to your theme.
content: [ ... './vendor/awcodes/pounce/resources/**/*.blade.php', ]
For Panels
If you are using Filament Panels you need to add the plugin to the panels you wish to use the plugin with. This will add the necessary livewire component to the panel's layout.
public function panel(Panel $panel): Panel { return $panel ->plugins([ PouncePlugin::make(), ]); }
Stand-alone usage
If you are using stand-alone Filament packages you will need to manually add the plugin to any layouts where you intend to use it. This should go before the closing body tag, and you should only have one instance per page.
@livewire('pounce')
You can publish the config file with:
php artisan vendor:publish --tag="pounce-config"
Optionally (not recommended), you can publish the views using
php artisan vendor:publish --tag="pounce-views"
This is the contents of the published config file:
return [ 'modal_max_width' => \Awcodes\Pounce\Enums\MaxWidth::Medium, 'modal_alignment' => \Awcodes\Pounce\Enums\Alignment::MiddleCenter, 'modal_slide_over' => \Awcodes\Pounce\Enums\SlideDirection::None, 'close_modal_on_click_away' => true, 'close_modal_on_escape' => true, 'close_modal_on_escape_is_forceful' => true, 'dispatch_close_event' => false, 'destroy_on_close' => false, ];
Usage
Creating a modal
With the command line
For convince, the plugin offers a scaffolding command to create new modals. This will create a class file in App\Livewire or your configured Livewire directory. It will also create a view at resources/views/livewire.
The --form flag will scaffold the modal with some defaults for making a modal that uses Filament's form methods.
php artisan make:pounce {name?} {--form} {--F|force}
Manually
To manually create a modal you simply need to run the Livewire make command and extend the PounceComponent class.
php artisan make:livewire CustomModal
namespace App\Http\Livewire; use Awcodes\Pounce\PounceComponent; class CustomModal extends PounceComponent { public function render() { return view('livewire.custom-modal'); } }
Opening and Closing Modals
Note
Pounce uses all the same conventions and usage as Wire Elements Modal, the only thing to be aware of is to open a modal Pounce uses the pounce event and to close a modal it uses the unPounce event.
See Wire Elements Modal on GitHub for complete usage instructions.
Modal Alignment
Modals can be aligned to the top, center, or bottom of the screen and to the start, center, or end of the screen. The default alignment is MiddleCenter. See the alignment enum for all available options. This can also be set globally in the config file.
use Awcodes\Pounce\Enums\Alignment; public static function getAlignment(): Alignment { return Alignment::MiddleCenter; }
Modal Width
Modal widths can be set using the enum cases found in Filament's MaxWidth enum. See the MaxWidth enum for all available options. This can also be set globally in the config file.
use Awcodes\Pounce\Enums\MaxWidth; public static function getMaxWidth(): MaxWidth { return MaxWidth::Medium; }
Slide Overs
By default, all modals are standard pop-up modals. If you wish to use a slide over modal you can set the getSlideDirection method to one of the SlideDirection enum cases. See the SlideDirection enum for all available options. This can also be set globally in the config file.
use Awcodes\Pounce\Enums\SlideDirection; public static function getSlideDirection(): SlideDirection { return SlideDirection::Left; }
To open a normal modal with the slide features you will need to explicitly set the isSlideOver method to return false.
public static function isSlideOver(): bool { return false; }
Blade Views
While you are free to use any blade view you wish, the plugin comes with a few pre-made views to get you started. These views have predefined padding and margins to match Filament's UI.
<div> <x-pounce::header> {{-- Modal Header --}} </x-pounce::header> <x-pounce::close-button icon-color="white" /> // defaults to 'gray' <x-pounce::heading> {{-- Modal Heading --}} </x-pounce::heading> <x-pounce::description> {{-- Modal Description --}} </x-pounce::description> <x-pounce::content> {{-- Modal Content --}} </x-pounce::content> <x-pounce::footer align="start"> // accepts start, center, end {{-- Modal Footer --}} </x-pounce::footer> </div>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
awcodes/pounce 适用场景与选型建议
awcodes/pounce 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 199 次下载、GitHub Stars 达 10, 最近一次更新时间为 2024 年 01 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「modal」 「livewire」 「alpinejs」 「filament」 「awcodes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 awcodes/pounce 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 awcodes/pounce 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 awcodes/pounce 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Fork from ghosh/Micromodal. Tiny, dependency-free javascript library for creating accessible modal dialogs.
Livewire starter kit for Lunar e-commerce.
Make Filament modals draggable.
A Filament form component that displays repeater items in a table with modal-based editing.
A Laravel Nova field. To create a modal for creating or viewing related HasMany records without leaving the index page
统计信息
- 总下载量: 199
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-10