- 🇮🇳India santosh_verma Faridabad
Adding a patch for table zebra styling
before
after
- last update
over 1 year ago Custom Commands Failed - 🇫🇷France Chris64 France
The patch 3332049-1.patch → has a little space problem:
s/&:nth-child(even){/&:nth-child(even) {/
With Drupal 9.5.8 the patch does not apply. With Drupal 10.0.x-dev the patch applied cleanly. But the table has no zebra. Since thetr
elements in the table have noeven
/odd
classes. If now in the Olivero theme the Clarotable.html.twig
file is used, then the table has zebra. A suitabletable.html.twig
file seems missing for the theme Olivero. Yes, Screenshot 2023-04-28 at 8.37.03 PM.png → is what is expected. - Status changed to Needs work
over 1 year ago 9:38pm 28 April 2023 - 🇮🇳India santosh_verma Faridabad
Rerolling the patch for D10 with Custom Commands Failed issue fixes.
- Status changed to Needs review
over 1 year ago 7:46am 1 May 2023 - last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago Patch Failed to Apply - 🇫🇷France Chris64 France
@ Santosh_Verma I can't get the same result than you.
In my case, the page theme is Olivero. And the html table in this page is build through an html.twig file. On a Drupal 10.1.0 installation.
0) Apply your patch: 3332049-8.patch: OK: applied cleanly.
1) With the original Olivero theme the table html look like,<table data-striping="1" class="dated"> <thead>...</thead> <tbody> <tr data-info="paragraph/21294" id="paragraph/21294">...</tr> <tr data-info="paragraph/21286" id="paragraph/21286">...</tr> <tr data-info="paragraph/21287" id="paragraph/21287">...</tr> ...
Visually: PB: table is no zebra. And there is no
table.html.twig
in thecore/themes/olivero/templates/
.
2) I alter the Olivero theme, by coping the table.html.twig file from Claro theme incore/themes/olivero/templates/dataset/
.
Then (drush cr needed) the table html look like,<table data-striping="1" class="dated"> <thead>...</thead> <tbody> <tr data-info="paragraph/21294" id="paragraph/21294" class="odd">...</tr> <tr data-info="paragraph/21286" id="paragraph/21286" class="even">...</tr> <tr data-info="paragraph/21287" id="paragraph/21287" class="odd">...</tr> ...
Visually: OK: table is zebra.
- Status changed to Needs work
over 1 year ago 12:45pm 1 May 2023 - last update
over 1 year ago 29,367 pass - Status changed to Needs review
over 1 year ago 12:58pm 1 May 2023 - last update
over 1 year ago 29,367 pass - 🇮🇳India santosh_verma Faridabad
#Chris64 i have attached the latest patch please test with this.
- 🇫🇷France Chris64 France
Fine @Santosh_Verma! Zebra gets in the table without table.html.twig file. Patch 3332049-13 → applied cleanly.
Few remarks,
- The final/bottom horizontal line is missing in the table.
- In my case, better without,
padding-block: var(--sp1);
: row less height, table more compact.
vertical-align: top;
: no horizontal alignment problem in rows.
The full corresponding rule,:is(.forum table, .text-content table, .views-table, .draggable-table, table) td, :is(.forum table, .text-content table, .views-table, .draggable-table, table) th { /* padding-block: var(--sp1); */ padding-inline-start: 0; padding-inline-end: var(--sp1); /* vertical-align: top; */ }
- Status changed to Needs work
over 1 year ago 4:01pm 1 May 2023 - 🇮🇳India Kaustab_Roy
Added patch based comment #14 requirement.
But I think it will be better to create a subtheme of Olivero theme, then add changes or override them as needed.
Even the changes in above patches can be problematic if we run postcss.Kindly review.
- 🇫🇷France Chris64 France
@Kaustab_Roy, patch 3332049-17 → applied cleanly, and makes what was missing. Only one little objection: the final line now exists, but its color if different from the first one. After a look to the patch and the page style, what about rather?,
:is(.forum table, .text-content table, .views-table, .draggable-table, table) tr:last-child td { - border-block-end: 0; + border-block-end: 2px solid var(--color--primary-50); }
and,
&:last-child { & td { - border-block-end: 0; + border-block-end: 2px solid var(--color--primary-50); } }
The file structure would be more the same. Nothing else in view.
If we can avoid to create a subtheme and only use the default Drupal theme it would be much better!
- 🇮🇳India santosh_verma Faridabad
#Chris64 : Regarding the recent modifications and changes in CSS that you requested in the last patch, implementing them may have an adverse impact on the styling of other sections of the website.While I agree that your suggested solution is better than creating a generic rule for all tables, I have encountered an issue where the even/odd classes are not being applied when I copied the table.html.twig file from Claro to Olivero.
Could you provide more information, such as the folder structure (mine is core/themes/olivero/templates/dataset/table.html.twig) and how to view the table in the frontend (I am creating a view with a format:table)? - 🇫🇷France Chris64 France
@Santosh_Verma, I suggested to use a
table.html.twig
from an other theme for Olivero, since in the old Bartik theme it was made this way, and some other themes have it. But not sure it is the good solution for Olivero. Yes, same folder for me, for the filetable.html.twig
in Olivero. We use this to mimic the old system. I enjoy your solution: using cssnth-child(even)
/nth-child(2n)
instead of a twig. Only verified for our particular case. But no problems seen on our site. It is believable that problems occur with yours solutions or my suggestions in some cases. Is it possible to avoid this cases? May be reducing the ambitions of the patch. Seems important: our table does not come from a view: it is a table of paragraphs gets from modules reference_table_formatter and paragraph through a field of type entity_reference_revision. Basic for the style configuration. Surely, no enough images from our part, and so not easy to see how look like the problem. Here some images (from different places):
Olivero Original:
Olivero + Claro table.html.twig:
Olivero + Css Patch 3332049-13:
Olivero + Css Patch 3332049-13+17:
- Status changed to Postponed: needs info
over 1 year ago 10:33am 1 June 2023 - Status changed to Active
9 months ago 10:07am 23 April 2024 - 🇬🇧United Kingdom joachim
Other core themes have 'odd' and 'even' css classes to allow table striping.
This should be in all core themes.