Contributing with a Tailwind theme #199
-
My customer wants to render tables based on a Tailwind CSS theme called Tailadmin. So I'm doing a lot of work trying to adapt a custom template that I hope at the end I'll share with you. But meanwhile, I need to solve some sort of problems related with Tailadmin DOM structure. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
My first question is related with table header. I need to generate this 3 kind of table headers (left, center & right aligned) <table class="min-w-full">
{# table head #}
<thead class="border-gray-100 border-y bg-gray-50 dark:border-gray-800 dark:bg-gray-900">
<tr>
<th class="px-6 py-3 whitespace-nowrap">
<div class="flex items-center">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">Status</p>
</div>
</th>
<th class="px-6 py-3 whitespace-nowrap">
<div class="flex items-center justify-center">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">Enabled</p>
</div>
</th>
<th class="px-6 py-3 whitespace-nowrap text-right">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">Actions</p>
</th>
</tr>
</thead> |
Beta Was this translation helpful? Give feedback.
-
Can you recommend me a strategy to set this 3 kind of alignments in data table builder, and read the values in theme? I'm looking for something like this example: final class NewsDataTableType extends AbstractDataTableType
{
public function buildDataTable(DataTableBuilderInterface $builder, array $options): void
{
$builder
// columns
->addColumn(
'title',
TextColumnType::class,
[
'alignment' => 'center',
'sort' => true,
'export' => true,
]
) {# @see Kreyu\Bundle\DataTableBundle\Column\Type\ColumnType #}
{% block column_header %}
{% set label_attr = label_attr | default({}) %}
{% if data_table.vars.sorting_enabled and sortable %}
{% set active_attr = active_attr | default({}) %}
{% set inactive_attr = inactive_attr | default({}) %}
{% set sorted_attr = sorted ? active_attr : inactive_attr %}
{# Merge the sorted attr with column header attr, but merge its classes. #}
{# The column header attr class is added after the sorted attr class. #}
{% set attr = attr | merge(sorted_attr | merge({'class': (sorted_attr.class | default('') ~ ' ' ~ attr.class | default('')) | trim})) %}
{% if alignment == 'left' %}
<th class="px-6 py-3 whitespace-nowrap">
<div class="flex items-center">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">{{- block('column_header_label', theme, _context) -}}</p>
</div>
</th>
{% elseif alignment == 'center' %}
<th class="px-6 py-3 whitespace-nowrap">
<div class="flex items-center justify-center">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">{{- block('column_header_label', theme, _context) -}}</p>
</div>
</th>
{% elseif alignment == 'right' %}
<th class="px-6 py-3 whitespace-nowrap text-right">
<p class="font-medium text-gray-500 text-theme-xs dark:text-gray-400">{{- block('column_header_label', theme, _context) -}}</p>
</th> |
Beta Was this translation helpful? Give feedback.
-
It is possible to add a new ColumnType option 'alignment' to affect all other inherit column types? |
Beta Was this translation helpful? Give feedback.
-
This is how I'm getting the Tailwind result. You can see "+ Add", "Filters" (opened) & "Export" action buttons. Active filters are shown as badges with right icon to clear. Example screenshot table footer is only showing items per page and is not showing pagination section, but is working well too (I've placed into right corner). How can I remove "Value" label from input filter field? I only need to show one label (Title). |
Beta Was this translation helpful? Give feedback.
-
I've made my custom template to adjust the following stack:
But is very difficult to reuse. |
Beta Was this translation helpful? Give feedback.
I think in your case you'd want to override the
column_header
like you suggested in comment above.