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/node-teaser.pcss.css
    @@ -0,0 +1,124 @@
    +  .field--name-field-image {
    

    Can we untie this from the image machine name?

  2. +++ b/core/themes/olivero/css/components/node.pcss.css
    @@ -0,0 +1,72 @@
    +  .field--name-user-picture img {
    

    Can we untie this from user_picture field?

Comments

proeung created an issue. See original summary.

chrisfree’s picture

This looks as good a ticket as any to try and jump in on...

Can we untie this from the image machine name?

What is more desirable here? Would this selector be better?
& .field--type-image It would match the existing field's default markup and any other of type image added to the teaser display mode in the future.

Can we untie this from user_picture field?

In this case, would it be fine to assume that images rendered within the .node__meta could all be similarly styled? Would & img work? Or would that be too broad a selector?

mherchel’s picture

Yeah, from my point of view, both selectors need to be tied to the machine name of the field.

In the first case (with field--name-field-image ), it might be possible to add additional images onto the article content type. We only want to apply this style to field--name-field-image .

The second case is very much the same. The user may have multiple image fields attached to it, but we only want to style one.

lauriii’s picture

I agree that we probably don't want to tie it to the field type either. We should probably add a new template (with some classes specific to this use case) for this, which could be extended so that it could be used by fields with other machine name.

chrisfree’s picture

Additional templates for these use-cases makes a lot more sense. Even better if the classes that style the relevant elements are written in a more generic fashion.

mherchel’s picture

Title: [Code Review] Address code feedback for the Node .pcss.css partials » Address code feedback for Olivero's node.pcss.css partials
Project: Olivero » Drupal core
Version: 8.x-1.x-dev » 9.1.x-dev
Component: Code » Olivero theme
mherchel’s picture

Version: 9.1.x-dev » 9.2.x-dev
Status: Active » Needs review
Issue tags: +CSS
StatusFileSize
new7.1 KB
new164.38 KB

Patched attached.

A couple notes:

  • For .field--name-field-image, I created a custom class called primary image. When this class is inside of the teaser it will inherit the teaser styles.
  • For .field--name-user-picture img, i added a wrapper in the node.html.twig file with a BEM style name. This image is a slightly different use case than the primary image. This is the author's pic that can appear above the post.

djsagar’s picture

Status: Needs review » Needs work
StatusFileSize
new148.74 KB
new63.56 KB

Hi @mherchel,

i'm getting error while applying patch #7.
please check the attachment and let me know what am i doing wrong.

Thanks you!

gauravvvv’s picture

StatusFileSize
new91.83 KB

Patch #7 working fine in 9.2.

It updates the class field--name-user-picture to node__author-image.
Adding an after-patch screenshot for reference.

Moving to RTBC.

gauravvvv’s picture

Status: Needs work » Needs review

Patch #7, is passing the drupal CI test so there are issues with your local setup not with the patch. Don't change the status to NW when any patch passes CI.

gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community
mherchel’s picture

mherchel’s picture

lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3296fcb and pushed to 9.2.x. Thanks!

  • lauriii committed 3296fcb on 9.2.x
    Issue #3173016 by mherchel, djsagar, Gauravmahlawat, chrisfree, proeung...

Status: Fixed » Closed (fixed)

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