codicastudio/badge-field
Composer 安装命令:
composer require codicastudio/badge-field
包简介
A random Codica Studio package.
README 文档
README
Simple Laravel Nova Badge field. It extends the Select field and allows a simple mapping of colors to values to display a "Badge" in the index.
Details Page
Index
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require timothyasp/nova-badge-field
Usage
use Timothyasp\Badge\Badge;
$options = [
'option1' => 'Option 1',
'option2' => 'Option 2'
];
Badge::make('Field')
->options($options)
->colors([
'option1' => '#ffffff',
'option2' => '#000000'
]);
If you want to set the text color of the badge, set the color attribute on the option. If there isn't an option set, it defaults to setting the background color and the text color is set to a contrasting white/black color based on the brightness of the background.
use Timothyasp\Badge\Badge;
$options = [
'option1' => 'Option 1',
'option2' => 'Option 2'
];
Badge::make('Field')
->options($options)
->colors([
'option1' => [
'background' => '#ffffff',
'color' => '#000000'
],
'option2' => '#000000'
]);
If you prefer to use the label on the index and detail pages, you can use the ->displayUsingLabels() option.
use Timothyasp\Badge\Badge;
$options = [
'option1' => 'Option 1',
'option2' => 'Option 2'
];
Badge::make('Field')
->options($options)
->colors([
'option1' => '#ffffff',
'option2' => '#000000'
])->displayUsingLabels();
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-25