5balloons/livewire-tooltip
Composer 安装命令:
composer require 5balloons/livewire-tooltip
包简介
A dynamic tooltip component using laravel livewire
README 文档
README
A dynamic, easy-to-use tooltip component for Laravel Livewire, enabling developers to add interactive tooltips to their Laravel applications with minimal effort.
Features
- Dynamic content loading via Livewire
- Customizable tooltip positioning with Popper.js
- Easy integration with any Laravel project
- Support for HTML content and asynchronous data fetching
Installation
To install the package, run the following command in your terminal:
composer require 5balloons/livewire-tooltip
Usage
To use the LivewireTooltip component in your Livewire views, you need to follow below steps
Install PooperJs
You can either install PopperJS via npm , or simply include the below CDN file in your layout file head element.
<script src="https://unpkg.com/@popperjs/core@2"></script>
Include Tooltip component in your view / layout
Include the tooltip component in your view file where you want to have the dynamic tooltip implemented, or you can include it in your layout file if you intend to have tooltips across your application
<livewire:livewire-tooltip />
Tooltip Elements
Example of a link that triggers the tooltip:
<a class="tooltip-link" tooltip-method="\App\Http\Controllers\YourController::tooltip">Hover me</a>
To implement the dynamic tooltip functionality, you need to define a method named tooltip in your controller. This method should return either a string or a view file that contains the content to be displayed in the tooltip.
Here's an example of how you can define the tooltip method in your controller:
public function tooltip() { // Your code here to generate the tooltip content return 'This is the tooltip content'; }
Make sure to replace 'This is the tooltip content' with the actual content you want to display in the tooltip.
Once you have defined the tooltip method, you can use it in your view by adding the tooltip-method attribute to the tooltip link element, like this:
<a class="tooltip-link" tooltip-method="\App\Http\Controllers\YourController::tooltip">Hover me</a>
Remember to replace \App\Http\Controllers\YourController with the actual namespace and class name of your controller.
That's it! Now when the user hovers over the tooltip link, the tooltip method will be invoked and the returned content will be displayed in the tooltip.
The tooltip method can either return a String or a View file. Tooltip component should be able to parse the dynamic variables and render the content inside tooltip
Advanced Usage
For dynamic content loading and custom positioning:
<a class="tooltip-link" tooltip-method="\App\Http\Controllers\YourController::tooltip" data-param1="value" data-placement="bottom">Hover for dynamic content</a>
You can pass parameters to the method and specify the tooltip position as given in the above example
License
This package is open-sourced software licensed under the MIT license.
5balloons/livewire-tooltip 适用场景与选型建议
5balloons/livewire-tooltip 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.93k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2024 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 5balloons/livewire-tooltip 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 5balloons/livewire-tooltip 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-15