Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.46k stars 215 forks source link

Tailwind style not applied to a row value #1347

Closed peroxovy closed 7 months ago

peroxovy commented 7 months ago

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes - I didn't work.

Is there an error in the console?

No

PHP Version

8.020

PowerGrid

3

Laravel

10

Livewire

2

Alpine JS

No response

Theme

Tailwind 3.x

Describe the bug.

->addColumn(fn (NotificationCategory $model) => '<div class="py-2 px-4 bg-['.$model->color.']"></div>')

Using this kind of closure inside addColumns() method does not apply tailwind styles. Value is stored as HEX and it's visible under Development Tools, but it's not working. How can I color the cell with the custom color then?

To Reproduce...

First click on "FOO" then....

Extra information

<?php
 //...
peroxovy commented 7 months ago

Instead of using classes which probably aren't pared correctly I suggest to user classic CSS style property:

->addColumn('color', fn (NotificationCategory $model) => '<div class="py-2 px-2 rounded-md" style="background-color:'.e($model->color).';"></div>');

Like this it is working properly.