(First, verify that the preprocess changes have been made. #2322163: [meta] Consensus Banana Phase 1, move CSS classes from preprocess to twig templates.)

  1. Copy the Twig templates from the core module's templates directory to Classy's templates directory. Include all templates, even ones without classes.
  2. 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

Files: 
CommentFileSizeAuthor
#30 copy_node_templates_to-2349721-29.patch6.29 KBmortendk
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 85,653 pass(es). View
#20 copy_node_templates_to-2349721-20.patch5.93 KBlauriii
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 85,547 pass(es). View
#20 interdiff.txt7.34 KBlauriii

Comments

lauriii’s picture

Status: Active » Needs review
FileSize
9.17 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 81,422 pass(es). View

Status: Needs review » Needs work

The last submitted patch, 1: copy_node_templates_to-2349721-1.patch, failed testing.

davidhernandez’s picture

Please 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.

Manuel Garcia’s picture

Applied 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:

27 .toolbar-vertical .layout-node-form:after {
28   display: none;
29 }

layout-region
Used in core/modules/block/css/block.admin.css and core/modules/node/css/node.module.css

   25: .layout-region {
   26    box-sizing: border-box;
   27  }

layout-region-node-secondary
In core/modules/node/css/node.module.css and core/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

rteijeiro’s picture

Assigned: Unassigned » rteijeiro

Trying to fix tests.

davidhernandez’s picture

I believe all the failing tests are fixed by this issue. #2350823: Use the Classy theme in the Testing profile

Status: Needs work » Needs review
lauriii’s picture

Assigned: rteijeiro » Unassigned

No need to fix tests

wheatpenny’s picture

Below 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

wheatpenny’s picture

Status: Needs review » Needs work
lauriii’s picture

So 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.

Manuel Garcia’s picture

Places in CSS where you find .node--unpublished:

core/modules/system/css/system.theme.css Line 9:

.node--unpublished {
   background-color: #fff4f4;
}

core/themes/bartik/css/style.css line 852:

.node--unpublished,
.unpublished {
  padding: 20px 15px 0;
}

core/themes/bartik/css/style.css line 856:

.node--unpublished .comment-text .comment-arrow,
.unpublished .comment-text .comment-arrow {
  border-left: 1px solid #fff4f4;
  border-right: 1px solid #fff4f4;
}

The class isn't used on any JS file in core.

davidhernandez’s picture

.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.

wheatpenny’s picture

Issue tags: +Novice

This 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:"

{%
  set classes = [
    not node.isPublished() ? 'node--unpublished',
  ]
%}

3. In core/modules/node/templates/node.html.twig, change <article{{ attributes }}> to <article{{ attributes.addClass(classes) }}>

preshetin’s picture

FileSize
2.7 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 82,589 pass(es). View

Here 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:

{%
  set classes = [
    'node',
    'node--type-' ~ node.bundle|clean_class,
    node.isPromoted() ? 'node--promoted',
    node.isSticky() ? 'node--sticky',
    not node.isPublished() ? 'node--unpublished',
    view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
  ]
%}
<article{{ attributes.addClass(classes) }}>
preshetin’s picture

Status: Needs work » Needs review
wheatpenny’s picture

Thanks, @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.

preshetin’s picture

FileSize
11.77 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 82,597 pass(es). View
3.17 KB

@wheatpenny, thank you for review. Here is how it looks now.

If anything is still wrong, please specify.

lauriii’s picture

Status: Needs review » Needs work
+++ b/core/modules/node/templates/node.html.twig
@@ -70,12 +70,7 @@
 {%
   set classes = [
...
 <article{{ attributes.addClass(classes) }}>

We could also remove the set and addClass

lauriii’s picture

Status: Needs work » Needs review
FileSize
7.34 KB
5.93 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 85,547 pass(es). View

Status: Needs review » Needs work

The last submitted patch, 20: copy_node_templates_to-2349721-20.patch, failed testing.

Status: Needs work » Needs review
wheatpenny’s picture

Thanks @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.

LewisNyman’s picture

.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.

If 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.

wheatpenny’s picture

FileSize
92.71 KB

Yes, we are communicating the the node's "unpublished" state through color only. Below is an unpublished node.
Screenshot of unpublished node

wheatpenny’s picture

There is an existing issue that is working on improving the "unpublished" state: https://www.drupal.org/node/867830

mortendk’s picture

Status: Needs review » Reviewed & tested by the community

please 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

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  • field--node--uid.html.twig
  • field--node--title.html.twig
  • field--node--created.html.twig

Are not copied and they are missing classes.

mortendk’s picture

Status: Needs work » Needs review
FileSize
6.29 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 85,653 pass(es). View

I need new glasses, wonder how i missed that heres a reroll with the attributes still there in core but classes moved out.

Manuel Garcia’s picture

Status: Needs review » Reviewed & tested by the community

Patch works and reads great. Tested it on a clean install, everything is as it was.

Jeff Burnz’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

CSS and templates are not subject to beta evaluation. Committed ebea5b8 and pushed to 8.0.x. Thanks!

  • alexpott committed ebea5b8 on 8.0.x
    Issue #2349721 by lauriii, preshetin, wheatpenny, mortendk: Copy node...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.