tonystore / livewire-interactions
用于在 Laravel 应用程序中生成 Livewire 交互的包。
v0.0.2
2022-03-15 19:10 UTC
Requires
- php: ^7.2|^8.0
- livewire/livewire: 2.*
- overtrue/laravel-follow: ^3.0|^4.0
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-09-16 01:56:34 UTC
README
用于在 Laravel 应用程序中生成 Livewire 交互的包。
REQUIREMENTS
通过 COMPOSER 安装
步骤 1: Composer
在控制台运行此命令行。
composer require tonystore/livewire-interactions
步骤 2: 发布资产
发布配置文件
php artisan vendor:publish --provider="Tonystore\LivewireInteraction\LivewireInteractionProvider" --tag=config-interaction
发布语言
如果您希望修改任何翻译,请发布翻译。
php artisan vendor:publish --provider="Tonystore\LivewireInteraction\LivewireInteractionProvider" --tag=langs-interaction
使用方法
默认情况下,Bootstrap 是 follow 组件的默认主题。但您也可以切换到 Tailwind。
<?php return [ /* * Supported Theme: 'bootstrap', 'tailwind'. */ 'theme' => 'bootstrap', ];
您可以根据以下说明自定义应用于 follow 组件的默认样式。
<?php return [ 'bootstrap' => [ // Bootstrap styles 'btn' => [ 'follow_class' => 'btn btn-info btn-sm', 'unfollow_class' => 'btn btn-danger btn-sm' ], 'icon' => [ 'follow_icon' => 'fas fa-user-plus', 'unfollow_icon' => 'fas fa-user-xmark' ] ], ];
要使用 follow 和 unfollow 组件,您可以在代码中的任何位置添加它,如下所示
<body> //INSERT COMPONENT <livewire:follow :user="$user" :wire:key="$user->id" /> //OR BLADE DIRECTIVE @livewire('follow', ['user' => $jugador], key($user->id)) //The user parameter is mandatory. </body>
您还可以通过将新设置作为参数传递到组件中,直接在组件中自定义要使用的样式。
<div> <livewire:follow :user="$user" //User to follow :follow_class="btn btn-block btn-lg" //Classes for follow button. :unfollow_class="btn btn-block btn-lg" //Classes for unfollowing button :follow_icon="btn btn-block btn-lg" //Classes for icon to follow. :unfollow_icon="btn btn-block btn-lg" //Classes to icon unfollowing :only_icon="btn btn-block btn-lg" //Show only the icon, without a description /> </div>