Problem/Motivation
Olivero adds table.css to its base library, but the vast majority of pages don't include tables.
I think Olivero could define a table library, move the CSS there, then attach this to all table render elements / #theme table.
This would remove 2.2k of unused CSS on pages that don't have tables.
Steps to reproduce
Proposed resolution
Add a new library, like olivero.table and move table.css there.
Attach the library to tables, probably could be done in olivero_preprocess_table() which already exists.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
sandip commentedI am working on it.
Comment #4
sandip commentedPlease review the changes.
Comment #5
smustgrave commentedSeems pretty straight forward
@sandip poddar looking at your post history, could probably elevate past novice tagged issues. Thanks!
Comment #6
sandip commentedThanks @smustgrave! I'll definitely start looking into more advanced issues.
Comment #7
nod_The css is not added to pages with a table, something doesn't work here. I checked
/admin/contentwith olivero as admin theme.The file needs to have the deprecation dance: see https://www.drupal.org/about/core/policies/core-change-policies/how-to-d... for an example you can check #3512194: Move resize CSS into its own library
Comment #8
sandip commentedHi @nod_ thanks for the review. I wanted to clarify that I can see the table.css file being added correctly. For testing purpose, I intentionally added background-color: blue to the table tag, and I verified in the Network tab also that the stylesheet is loading as expected. Can you again have a look at it please.
For reference, I’ve attached a screenshot
Thanks again for your guidance and for providing these valuable resources. I haven’t try any recordable changes yet, but I’m going through the documentation you shared and trying to implement the same here.
Comment #9
sandip commentedSorry my bad! that thing is only works for
table.html.twignot working forview-view-table.html.twig. Sorry for the above noice i did not notice it before. I am fixing it.Comment #10
sandip commentedHere is the change record: https://www.drupal.org/node/3517675
Please review the changes.
Comment #11
smustgrave commentedCleaned up the CR a bit. Don't think we needed to include the MR as a patch, and tweaked the versions.
Comment #14
nod_Committed ab9823e and pushed to 11.x. Thanks!
Comment #15
mherchelSomehow I missed this.
Tables can also be added via CKEditor, which is why we had it as a global library. You can see at https://git.drupalcode.org/project/drupal/-/blob/11.2.x/core/themes/oliv..., we're also targeting tables that appear in
.text-content(which is formatted text).Comment #18
catch@mherchel - best to re-open issues if there's a problem or create a follow-up, it's easy for comments on fixed issues to go missing.
I've reverted this from 11.x and 11.2.x for more discussion. We could potentially add the library when text fields are rendered too.
Comment #19
sandip commentedHi @catch, @mherchel
Can we try something like this below. Is it the right approach for it?
New change:
Comment #20
sandip commentedIf you agree i am updating this in the MR so.
Comment #21
nod_that looks reasonable
Comment #23
sandip commented@nod_ sorry for the delay. I've raised the MR and attached some images for clarity. Moving the issue to NR.
Comment #24
smustgrave commentedDeprecation versions need to be updated for 11.3, CR too.
CR maybe could use before/after code snippets for people to use this library.
Comment #25
sandip commentedI am working on it.
Comment #26
sandip commented@smustgrave, I have implemented your suggestions please review the changes. Here is the updated CR: https://www.drupal.org/node/3517675
Comment #27
mherchelNew changes look good. The table library will be loaded when rich text fields are being displayed.
Comment #30
nod_Committed 3713df5 and pushed to 11.x. Thanks!