Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
(First, verify that the preprocess changes have been made. #2322163: [meta] Consensus Banana Phase 1, move CSS classes from preprocess to twig templates.)
- Copy the Twig templates from the core module's templates directory to Classy's templates directory. Include all templates, even ones without classes.
- Remove all classes from the core module's template. Remove all classes added with addClass and ones that are hard-coded in the template.
- If there are classes that are required for basic functionality, discuss whether they should be kept.
- If there is CSS from the module, or anywhere else, referring to the class, discuss removing it or moving it to Bartik&Seven. Do not move the CSS to Classy.
Twig Templates to Copy
core/modules/node/templates/field--node--created.html.twig
core/modules/node/templates/field--node--title.html.twig
core/modules/node/templates/field--node--uid.html.twig
core/modules/node/templates/node-add-list.html.twig
core/modules/node/templates/node-edit-form.html.twig
core/modules/node/templates/node.html.twig
Comment | File | Size | Author |
---|---|---|---|
#30 | copy_node_templates_to-2349721-29.patch | 6.29 KB | mortendk |
#20 | copy_node_templates_to-2349721-20.patch | 5.93 KB | lauriii |
#20 | interdiff.txt | 7.34 KB | lauriii |
Comments
Comment #1
lauriiiComment #3
davidhernandezPlease double-check if any removed classes are being used in javascript. It is best to test the affected template using Stark to make sure nothing is broken.
Comment #4
Manuel Garcia CreditAttribution: Manuel Garcia commentedApplied the patch and did some searching on the removed classes inside /core. I only mention here the ones that came up with some results that might need attention. None of the classes turned up on any JS file.
node-type-list
Used in
core/modules/block_content/templates/block-content-add-list.html.twig
layout-node-form
found in
core/themes/seven/css/layout/node-add.css
:layout-region
Used in
core/modules/block/css/block.admin.css
andcore/modules/node/css/node.module.css
layout-region-node-secondary
In
core/modules/node/css/node.module.css
andcore/themes/seven/css/layout/node-add.css
layout-region-node-footer
In
core/modules/node/css/node.module.css
.node--unpublished
In
core/modules/system/css/system.theme.css
Comment #5
rteijeiro CreditAttribution: rteijeiro commentedTrying to fix tests.
Comment #6
davidhernandezI believe all the failing tests are fixed by this issue. #2350823: Use the Classy theme in the Testing profile
Comment #8
lauriiiNo need to fix tests
Comment #9
wheatpenny CreditAttribution: wheatpenny commentedBelow is the list of removed classes:
node-type-list
layout-node-form
clearfix
layout-region
layout-region-node-main
layout-region-node-secondary
layout-region-node-footer
node
node--type-*
node--promoted
node--sticky
node--unpublished
node--view-mode-*
node__meta
node__submitted
node__content
node__links
I found the same results as @Manuel Garcia. Except for "node--unpublished," the CSS for the other classes deals with layout and is not functional.
However, for "node--unpublished," that CSS is the background color on nodes to indicate that they are unpublished. I'm not convinced that this class is necessary, but I can see the argument that it's functional. We'll need to decide if that class name remains in the module template.
Finally, I noticed when "node.html.twig" was copied to Classy, the following were removed:
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - content_attributes: Same as attributes, except applied to the main
* content tag that appears in the template.
* - author_attributes: Same as attributes, except applied to the author of
* the node tag that appears in the template.
and the following was added:
* - is_front: Flag for front. Will be true when presented on the front page.
I wanted to bring this up in case we need to add the _attributes comments back. Also, are we adding "is_front" to node.html.twig?
TO DO:
1. Copy the following templates to Classy:
core/modules/node/templates/field--node--created.html.twig
core/modules/node/templates/field--node--title.html.twig
core/modules/node/templates/field--node--uid.html.twig
Comment #10
wheatpenny CreditAttribution: wheatpenny commentedComment #11
lauriiiSo is there any CSS or JS attached to
.node--unpublished
in core? I think we could remove it because it's not functionality everyone wants to have I guess.Comment #12
Manuel Garcia CreditAttribution: Manuel Garcia commentedPlaces in CSS where you find
.node--unpublished
:core/modules/system/css/system.theme.css Line 9:
core/themes/bartik/css/style.css line 852:
core/themes/bartik/css/style.css line 856:
The class isn't used on any JS file in core.
Comment #13
davidhernandez.node-unpublished is used to add that pink background color you see when a node is unpublished. It is style, but I understand the argument that it is functional. This is a similar discussion we've been having about the color striping of the update pages. Should someone using Stark still get the visual cue. I don't mind leaving it in.
Comment #14
wheatpenny CreditAttribution: wheatpenny commentedThis looks like a good novice issue, so I'm going to write up next steps:
1. Copy (but do not delete)
core/modules/node/templates/field--node--created.html.twig
core/modules/node/templates/field--node--title.html.twig
core/modules/node/templates/field--node--uid.html.twig
to
core/themes/classy/templates/field--node--created.html.twig
core/themes/classy/templates/field--node--title.html.twig
core/themes/classy/templates/field--node--uid.html.twig
2. In core/modules/node/templates/node.html.twig, add the following above "article:"
3. In core/modules/node/templates/node.html.twig, change
<article{{ attributes }}>
to<article{{ attributes.addClass(classes) }}>
Comment #15
preshetin CreditAttribution: preshetin commentedHere I tried to implement #14 instructions.
In this patch I only copied three .twig files (Step 1). As for changing core/modules/node/templates/node.html.twig I was confused. As I understand, the necessary changes already exist:
Comment #16
preshetin CreditAttribution: preshetin commentedComment #17
wheatpenny CreditAttribution: wheatpenny commentedThanks, @preshetin! What you'll need to do is apply the patch from #1, make the changes listed in #14, and then make a new patch. There are good resources (https://www.drupal.org/patch), but you should also feel free to reach out to me, and I'll help walk you through the steps. Also, feel free to stop by #drupal-contribute or #drupal-twig in IRC (https://www.drupal.org/irc) for assistance.
Comment #18
preshetin CreditAttribution: preshetin commented@wheatpenny, thank you for review. Here is how it looks now.
If anything is still wrong, please specify.
Comment #19
lauriiiWe could also remove the set and addClass
Comment #20
lauriiiComment #23
wheatpenny CreditAttribution: wheatpenny commentedThanks @laurii. Based on comment #13, shouldn't we add set and addClass back to /core/modules/node/templates/node.html.twig? My understanding is that we want to make the class "node--unpublished" available in Stark.
Comment #25
LewisNymanIf it is required for functionality then we are communicating on color alone which is against our accessibility standards. I would rather move the styling out of Stark and communicate this in plain text.
Comment #26
wheatpenny CreditAttribution: wheatpenny commentedYes, we are communicating the the node's "unpublished" state through color only. Below is an unpublished node.
Comment #27
wheatpenny CreditAttribution: wheatpenny commentedThere is an existing issue that is working on improving the "unpublished" state: https://www.drupal.org/node/867830
Comment #28
mortendk CreditAttribution: mortendk commentedplease lets keep these patches to only focus on moving to classy, if theres other work that needs to get done, then create a followup issue
Comment #29
alexpottAre not copied and they are missing classes.
Comment #30
mortendk CreditAttribution: mortendk commentedI need new glasses, wonder how i missed that heres a reroll with the attributes still there in core but classes moved out.
Comment #31
Manuel Garcia CreditAttribution: Manuel Garcia commentedPatch works and reads great. Tested it on a clean install, everything is as it was.
Comment #32
Jeff Burnz CreditAttribution: Jeff Burnz commented#25 see this #867830: "Unpublished" style of rendered entities is not accessible (and looks bad)
Comment #33
alexpottCSS and templates are not subject to beta evaluation. Committed ebea5b8 and pushed to 8.0.x. Thanks!