rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.7k stars 320 forks source link

Add ColorColumn #1590

Closed lrljoe closed 6 months ago

lrljoe commented 6 months ago

This PR adds a new ColorColumn

Color Columns

Color columns provide an easy way to a Color in a Column

You may pass either pass a CSS-compliant colour as a field

ColorColumn::make('Favourite Colour', 'favourite_color'),

Or you may use a Callback

ColorColumn::make('Favourite Colour')
    ->color(
            function ($row) {
                if ($row->success_rate < 40)
                {
                    return '#ff0000';
                }
                else if ($row->success_rate > 90)
                {
                    return '#008000';
                }
                else return '#ffa500';

            }
        ),

You may also specify attributes to use on the div displaying the color, to adjust the size or appearance, this receives the full row. By default, this will replace the standard classes, to retain them, set "default" to true. To then over-ride, you should prefix your classes with "!" to signify importance.

    ColorColumn::make('Favourite Colour')
            ->attributes(function ($row) {
                return [
                    'class' => '!rounded-lg self-center',
                    'default' => true,
                ];
            }),

All Submissions:

New Feature Submissions:

  1. [X] Does your submission pass tests and did you add any new tests needed for your feature?
  2. [X] Did you update all templates (if applicable)?
  3. [X] Did you add the relevant documentation (if applicable)?
  4. [X] Did you test locally to make sure your feature works as intended?

Changes to Core Features:

codecov[bot] commented 6 months ago

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (69368b8) 89.17% compared to head (a45c6c0) 89.14%.

Files Patch % Lines
src/Views/Columns/ColorColumn.php 50.00% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1590 +/- ## ============================================= - Coverage 89.17% 89.14% -0.04% - Complexity 1317 1334 +17 ============================================= Files 102 105 +3 Lines 3103 3140 +37 ============================================= + Hits 2767 2799 +32 - Misses 336 341 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.