Kreyu / data-table-bundle

Streamlines creation process of the data tables in Symfony applications. NOT PRODUCTION READY.
https://data-table-bundle.swroblewski.pl
MIT License
70 stars 14 forks source link

Refactor built-in themes for easier usage #91

Open Kreyu opened 4 months ago

Kreyu commented 4 months ago

Twig themes are a bit chaotic in some parts, with unnecessary blocks, weird attribute inheritance, etc. This has to be done before first stable release to prevent additional work with previously created custom themes.

alexandre-castelain commented 4 months ago

Hello @Kreyu !

When you say you want to delete unnecessary blocks, are you referring to this:

What surprises me in the way the views are divided is that sometimes we directly use the twig blocks {{ block('table') }} and sometimes we use the extension functions {{ data_table_pagination(pagination) }}.

Shouldn't we have something more uniform? Shouldn't the DataTableView prepare everything for display and therefore not go through the twig extension?

Have a good day, Alexandre

Kreyu commented 3 months ago

When you say you want to delete unnecessary blocks, are you referring to this:

kreyu_data_table | kreyu_data_table_table | table | kreyu_data_table_form_aware kreyu_data_table_action_bar | action_bar kreyu_data_table_header_row | table_head_row

Exactly. Most of those blocks are unnecessary, and provide no real benefit.

What surprises me in the way the views are divided is that sometimes we directly use the twig blocks {{ block('table') }} and sometimes we use the extension functions {{ data_table_pagination(pagination) }}.

Yeah, that seems a bit weird. There's plenty of twig functions that allow rendering each part of the data table individually - just like in Symfony Form you can render label, widget, help message and errors separately. I think this is fine. Those functions however, should render different blocks - for example, instead of using kreyu_data_table_table block, just a simple table should be sufficient. Not sure whether the built-in themes should use the functions, or their blocks directly.

I think most of the work with refactoring has already be done in base theme, now I'm adjusting and ironing out the Bootstrap and Tabler themes.