timothyasp / nova-badge-field by timothyasp

A Laravel Nova field.
396,624
58
5
Package Data
Maintainer Username: timothyasp
Package Create Date: 2018-08-23
Package Last Update: 2022-06-23
Language: JavaScript
License: MIT
Last Refreshed: 2024-03-26 03:02:43
Package Statistics
Total Downloads: 396,624
Monthly Downloads: 17,563
Daily Downloads: 896
Total Stars: 58
Total Watchers: 5
Total Forks: 8
Total Open Issues: 1

Laravel Nova Badge Field

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

details page select

Index

index badge

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;

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;

Badge::make('Field')
   ->options($options)
   ->colors([
      'option1' => [
          'background' => '#ffffff',
          'color' => '#000000'
      ],
      'option2' => '#000000'
   ]);

Credits

Built for QuizGriz - the #1 online trivia and quiz game site

License

The MIT License (MIT). Please see License File for more information.