gabrielesbaiz / nova-field-indicator
A colour-coded indicator field for Laravel Nova
Fund package maintenance!
Gabriele Sbaiz
Requires
- php: ^8.0
- illuminate/contracts: ^10.0||^11.0||^12.0
- laravel/nova: ^4.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
A colour-coded indicator field for Laravel Nova.
Original code from oleghalin/nova4-indicator-field
Features
- ✅ With labels
- ✅ Without labels
- ✅ Hide defined values
- ✅ Named colours
- ✅ Literal colours
Installation
You can install the package via composer:
composer require gabrielesbaiz/nova-field-indicator
Usage
use Gabrielesbaiz\NovaFieldIndicator\NovaFieldIndicator; NovaFieldIndicator::make('Status'),
Options
Labels
NovaFieldIndicator::make('Status') ->labels([ 'banned' => 'Banned', 'active' => 'Active', 'invited' => 'Invited', 'inactive' => 'Inactive', ])
Without Labels
NovaFieldIndicator::make('Status') ->withoutLabels()
Unknown Label
NovaFieldIndicator::make('Status') ->unknown('Unknown')
Should Hide
NovaFieldIndicator::make('Status') ->shouldHide('active')
NovaFieldIndicator::make('Status') ->shouldHide(['invited', 'requested'])
NovaFieldIndicator::make('Status') ->shouldHide(function($value) { return $value == 'inactive'; })
Should Hide If No
NovaFieldIndicator::make('Status') ->shouldHideIfNo()
Colours
Named Colours
NovaFieldIndicator::make('Status') ->colors([ 'banned' => 'red', 'active' => 'green', 'invited' => 'blue', 'inactive' => 'grey', ])
The available colours are the default "base" colours from Tailwind, with the addition of black:
- 'black'
#22292F
- 'grey' or 'gray'
#B8C2CC
- 'red'
#E3342F
- 'orange'
#F6993F
- 'yellow'
#FFED4A
- 'green'
#38C172
- 'teal'
#4DC0B5
- 'blue'
#3490DC
- 'indigo'
#6574CD
- 'purple'
#9561E2
- 'pink'
#F66D9B
As well as the following Nova variable colours:
- 'success'
var(--success)
- 'warning'
var(--warning)
- 'danger'
var(--danger)
- 'info'
var(--info)
Colour classes are not validated against the lists above, so if you enter an invalid colour, it will fall back to grey.
Literal Colours
NovaFieldIndicator::make('Status') ->colors([ '...' => '#ff0000', '...' => 'rgb(0, 255, 0)', '...' => 'rgba(0, 0, 0, 0.5)', '...' => 'hsl(120, 100%, 50%)', '...' => 'hsla(120, 100%, 50%, 0.5)', '...' => 'var(--success)', ])
Additional Colour Classes
.indicator-yourcolourname { background: #000000; }
NovaFieldIndicator::make('Status') ->colors([ 'yourstatus' => 'yourcolourname', ])
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.