Problem/Motivation

These changes are coming from the feedback that we've received from the patch submission that we've made on 9/23/2020.

  1. +++ b/core/themes/olivero/css/components/comments.pcss.css
    @@ -0,0 +1,245 @@
    +.comments {
    +  > .comment {
    ...
    +    ~ .comment {
    

    Could we provide a CSS class indicating whether the comment is on the main level or not instead of using CSS? Technically this is against BEM since block elements shouldn't depend on other elements on the page.

  2. +++ b/core/themes/olivero/css/components/comments.pcss.css
    @@ -0,0 +1,245 @@
    +  .text-content {
    ...
    +  .links {
    

    Can we customize the markup so that either .links and .text-content become their own blocks or they are rendered as elements inside .comment?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#45 interdiff-41-45.txt4.56 KBmherchel
#45 3173007-45.patch15.33 KBmherchel
#44 interdiff-41-44.txt4.56 KBmherchel
#44 3173007-44.patch20.22 KBmherchel
#41 interdiff-35-41.txt2.29 KBmherchel
#41 3173007-41.patch11.29 KBmherchel
#35 interdiff-3173007-28-35.txt3.7 KBmherchel
#35 3173007-35.patch12.21 KBmherchel
#34 Screen_Shot_2021-01-08_at_9_33_00_AM.jpg344.01 KBproeung
#28 interdiff_26-28.txt5.15 KBraman.b
#28 3173007-28.patch12.51 KBraman.b
#26 reroll_diff_24-26.txt5.18 KBraman.b
#26 3173007-26.patch8.66 KBraman.b
#24 3173007-24.patch8.55 KBpaulocs
#24 interdiff-18-24.txt1.44 KBpaulocs
#18 interdiff_14-18.txt1.96 KBkishor_kolekar
#18 3173007-18.patch8.55 KBkishor_kolekar
#17 interdiff_14-16.txt1.96 KBkishor_kolekar
#17 3173007-16.patch8.55 KBkishor_kolekar
#14 interdiff_12-14.txt496 byteskomalk
#14 3173007-14.patch8.28 KBkomalk
#12 interdiff_7-12.txt1.48 KBkomalk
#12 3173007-12.patch8.28 KBkomalk
#7 interdiff_5-7.txt593 byteskishor_kolekar
#7 3173007-7.patch8.27 KBkishor_kolekar
#5 interdiff_3-5.txt3.42 KBkostyashupenko
#5 3173007-5.patch8.21 KBkostyashupenko
#3 3173007-3.patch6.72 KBkostyashupenko
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

proeung created an issue. See original summary.

proeung’s picture

Issue summary: View changes
kostyashupenko’s picture

Project: Olivero » Drupal core
Version: 8.x-1.x-dev » 9.2.x-dev
Component: Code » Olivero theme
Status: Active » Needs review
FileSize
6.72 KB
mherchel’s picture

Status: Needs review » Needs work

Patch applies and works great. I have a couple code questions:

+++ b/core/themes/olivero/css/components/comments.pcss.css
@@ -73,45 +71,45 @@
+.comment .text-content {

Why are you breaking out the .text-content into its own code block here? Why not leave nested?

+++ b/core/themes/olivero/css/components/comments.pcss.css
@@ -73,45 +71,45 @@
+.comment .links {

Same question as above.

kostyashupenko’s picture

Status: Needs work » Needs review
FileSize
8.21 KB
3.42 KB

No excuses :) but now i guess my patch is finished

mherchel’s picture

Status: Needs review » Needs work

This looks great! I have a couple of pretty minor changes before it is RTBC. Thanks for working on this!

  1. +++ b/core/themes/olivero/olivero.theme
    @@ -337,6 +337,10 @@ function olivero_preprocess_field(&$variables) {
    +    if ($variables['entity_type'] == 'comment') {
    

    Should this be using the identical operator ===?

  2. +++ b/core/themes/olivero/olivero.theme
    @@ -337,6 +337,10 @@ function olivero_preprocess_field(&$variables) {
    +      $variables['attributes']['class'][] = 'comment__text';
    

    Let's change this class to comment_text-content, so it's obvious what it's doing within the CSS.

kishor_kolekar’s picture

Status: Needs work » Needs review
FileSize
8.27 KB
593 bytes

Worked on comment #6

Status: Needs review » Needs work

The last submitted patch, 7: 3173007-7.patch, failed testing. View results

mherchel’s picture

+++ b/core/themes/olivero/olivero.theme
@@ -338,8 +339,8 @@
+      $variables['attributes']['class'][] = 'comment__text-content';

If we change the selector here, we also need to change the selector within the stylesheet (or it won't apply the styles).

kostyashupenko’s picture

As i remember we already have comment__text-content selector somewhere in tree

komalk’s picture

Assigned: Unassigned » komalk
komalk’s picture

Assigned: komalk » Unassigned
Status: Needs work » Needs review
FileSize
8.28 KB
1.48 KB

Worked on #9.
Review the patch.

komalk’s picture

forgot to add #6.1 in the previous patch.

komalk’s picture

FileSize
8.28 KB
496 bytes
mherchel’s picture

Status: Needs review » Needs work

From @kostyashupenko in #10

As i remember we already have comment__text-content selector somewhere in tree

Yep. You're completely correct. However, the selector isn't being used. It's on line 83 of core/themes/olivero/templates/content/comment.html.twig.

We should change this to comment__content-wrapper, since that seems to be this particular div's function. The rest of the patch in #14 is looking good.

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar
kishor_kolekar’s picture

Assigned: kishor_kolekar » Unassigned
Status: Needs work » Needs review
FileSize
8.55 KB
1.96 KB

Worked on Comment #15

kishor_kolekar’s picture

FileSize
8.55 KB
1.96 KB

please avoid the previous patch.

mherchel’s picture

Status: Needs review » Needs work

#18, we should change the instance of the current comment__text-content to comment__text-wrapper and then add the new class in

Santosh_Verma’s picture

Assigned: Unassigned » Santosh_Verma
Santosh_Verma’s picture

@mherchel I have checked patch #18, as per my understanding it's all done as you asked or maybe I am missing, can you please explain little bit more

mherchel’s picture

The patch in #18 adds the class `comment__text-wrapper`. Instead of doing this, we should be adding `comment__text-content`. But before we do that, we need to change the current name of `comment__text-content` (in the twig file) to `comment__text-wrapper`

paulocs’s picture

Assigned: Santosh_Verma » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
1.44 KB
8.55 KB

I created a new patch.

kostyashupenko’s picture

Status: Needs review » Reviewed & tested by the community

Previous patch lgtm

raman.b’s picture

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/olivero/css/components/comments.pcss.css
@@ -73,45 +71,49 @@
+  & a {
...
+  & li {

+++ b/core/themes/olivero/olivero.theme
@@ -584,3 +588,10 @@ function olivero_preprocess_search_result(&$variables) {
+function olivero_preprocess_links__comment(&$variables) {
+  $variables['attributes']['class'][] = 'comment__links';
+}

We could override links--comment.html.twig to add classes for these elements.

raman.b’s picture

Status: Needs work » Needs review
FileSize
12.51 KB
5.15 KB

Overriding twig templates and removing classes from preprocess

mherchel’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #28 looks perfect. Thanks!

mansoor20’s picture

Looks good. RTBC +1

mherchel’s picture

Patch still applies and still looks good.

mherchel’s picture

Credit looks good.

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

Talked to @lauriii within code sprint.

We need to add BEM classes onto the comment links (reply, etc)

proeung’s picture

As @mherchel noted, we need to apply classes to the <li> and <a> tags to keep the consistency with BEM methodology for the unordered list. We might need to add a preprocess function to apply an attribute to the links array in order to expose these classes.

mherchel’s picture

Status: Needs work » Needs review
FileSize
12.21 KB
3.7 KB

Updated the comment link selectors per the previous comments.

Note that while doing this, I discovered a number of the CSS styles were redundant, so I was able to remove them.

proeung’s picture

Status: Needs review » Needs work
Issue tags: +technical debt

@mherchel Thanks for submitting this revised patch and removing redundant styles. I just have minor feedback for the patch in #35.

+++ b/core/themes/olivero/olivero.theme
@@ -584,3 +584,13 @@ function olivero_preprocess_search_result(&$variables) {
+    $link['link']['#options']['attributes']['class'][] = 'comment__links-link';

A bit of nitpicking, but IMHO this class naming convention (.comment__links-link) doesn't fit the BEM tree. I would use .comment__links__link use instead for link classname. Also, see below of an unordered list BEM tree.

<ul class="comment__links">
        <li class="comment__links__item">
            <a class="comment__links__link" href="url">Link Example 01</a>
        </li>
        <li class="comment__linksr__item">
            <a class="comment__links__link" href="url">Link Example 02</a>
        </li>
    </ul>
mherchel’s picture

Status: Needs work » Needs review

I'm pretty sure that we should not include each level in the class name. I was looking for Drupal documentation on that, but can't find it.

I did find this info from https://seesparkbox.com/foundry/bem_by_example

If your component has child elements several levels deep, don’t try to represent each level in the class name. BEM is not intended to communicate structural depth. A BEM class name representing a child element in the component should only include the base/block name and the one element name.

I'd love to get @lauriii's input on this.

kostyashupenko’s picture

My 50 cents:
The classname comment__links-link looks kinda weird to me, so the element name is links-link, which is not obvious.

The next classname, proposed in #36 comment__links__link looks not obvious aswell, you can't have block of the block. The construction should be simple and common: block__element--modifier

If you want to handle another block, then it's better replace comment__links__link by comment-links__link, so blockName becomes comment-links

Also, about #35 - for templates field--comment-body.html.twig and links--comment.html.twig not possible to avoid overriding templates and manage everything on hook?

lauriii’s picture

I don't think comment__links__link is allowed. I'm fine with I comment__links-link or we could even simplify that to comment__link.

bnjmnm’s picture

  1. I prefer simplifying to comment__link as suggested in #39
  2. +++ b/core/themes/olivero/templates/content/comment.html.twig
    @@ -68,6 +68,7 @@
         'js-comment',
    +    not parent_comment ? 'comment--first-level',
         status != 'published' ? 'comment--' ~ status,
    

    Since we're not dealing with levels beyond first, would is-parent be more accurate/useful?

    If level is preferred, may be worth switching to "level-1" instead of "first-level" so it's consistent with nav class naming.

  3. For the next patch, could you add -C -C when you generate it? git diff 9.2.x -C -C > patch.patch? This may make it easier to distinguish the Olivero-specific changes to those templates vs the contents that were pasted in from a broader template.
  4. I assume you've already noticed the CS issue in olivero.theme that custom commands caught.

Re #38

field--comment-body.html.twig and links--comment.html.twig not possible to avoid overriding templates and manage everything on hook?

The expectation for core is to do this in templates whenever possible. Details on the decision here: [#2325067]. The preprocess preference is an understandable one, though 🙂.

mherchel’s picture

I ended up going with a comment--level-1 class to keep consistency across the codebase (we do something similar for menus).

Updated patch attached!

bnjmnm’s picture

The patch itself looks good so I had a look at what might need changing that isn't in the patch. Only spotted one thing:

Looks like there's a non-bem .comment-picture being added in a few templates and used for this style

.add-comment__picture-wrapper.comment-picture {
  inset-block-start: calc(var(--line-height-base) + var(--sp0-5));
}

It seems like it should be possible to get rid of .comment-picture everywhere and not have to worry about BEM-ifying it. That would also address some of the classname confusion that is happening like in commment.html.twig, where there's a div with .comment-picture div with a child div that has .comment__picture

<div class="comment__picture-wrapper comment-picture">
    <div class="comment__picture comment-picture__image">
      {{ user_picture }}
    </div>
  </div>
mherchel’s picture

Status: Needs review » Needs work
mherchel’s picture

Status: Needs work » Needs review
FileSize
20.22 KB
4.56 KB

Updated patch that resolves #42 attached!

mherchel’s picture

Ugh. The last patch included the interdiff! Updated patch attached :D

proeung’s picture

Status: Needs review » Reviewed & tested by the community

The updated patch from #45 looks good.

RTBC +1

  • lauriii committed bb59259 on 9.2.x
    Issue #3173007 by mherchel, kishor_kolekar, komalk, raman.b,...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed bb59259 and pushed to 9.2.x. Thanks!

Status: Fixed » Closed (fixed)

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