[Regression] no table zebra CSS classes

Created on 9 January 2023, over 1 year ago
Updated 23 April 2024, 2 months ago

Problem/Motivation

The new theme Olivero doesn't allow table zebra. Therefore distinguish different rows in a table may be difficult. Some others themes like the old Bartik or the new Claro ones do it using odd/even classes through table.html.twig and convenient css rules. Theme Olivero hasn't such table twig. Thus for this theme the default table twig
core/modules/system/templates/table.html.twig,
is used, which does not implement odd/even classes. Moreover the table.css exists for that theme but has no rules for odd/even classes.

Therefore does this lack is intentional or is a forgetfulness? Why an other approach is used for table zebra? Which one is expected instead?

Steps to reproduce

Proposed resolution

Add a table.html.twig file to Olivero theme, like the Claro theme one.
Add a rule for tr.odd in table.pcss.css.

Remaining tasks

Modify table.pcss.css.
: not necessary.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Olivero 

Last updated 1 day ago

Created by

🇫🇷France Chris64 France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India Gauravvv Delhi, India
  • 🇮🇳India Santosh_Verma

    Adding a patch for table zebra styling

    before

    after

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 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 the tr elements in the table have no even/odd classes. If now in the Olivero theme the Claro table.html.twig file is used, then the table has zebra. A suitable table.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 about 1 year ago
  • 🇮🇳India Santosh_Verma

    Rerolling the patch for D10 with Custom Commands Failed issue fixes.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Patch Failed to Apply
  • 🇮🇳India Santosh_Verma

    Rerolling the patch for D10.0.x

  • 🇫🇷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 the core/themes/olivero/templates/.
    2) I alter the Olivero theme, by coping the table.html.twig file from Claro theme in core/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 about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    29,367 pass
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    29,367 pass
  • 🇮🇳India Santosh_Verma

    #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 about 1 year ago
  • 🇮🇳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

    #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 file table.html.twig in Olivero. We use this to mimic the old system. I enjoy your solution: using css nth-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 about 1 year ago
  • Status changed to Active 2 months ago
  • 🇬🇧United Kingdom joachim

    Other core themes have 'odd' and 'even' css classes to allow table striping.

    This should be in all core themes.

Production build 0.69.0 2024