Problem/Motivation

This is a child of #3324398: [META] Update Claro CSS with new coding standards and part of #3254529: [PLAN] Drupal CSS Modernization Initiative.

Steps to reproduce

The stylesheet at https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/themes/clar... needs to be refactored to make use of modern CSS and Drupal core's PostCSS tooling.

@todo: Add clear testing instructions to test this manually on the UI.

Proposed resolution

  • Use CSS Logical Properties where appropriate.
  • Use CSS nesting where appropriate.
  • Use existing variables (variables.pcss.css) where appropriate. Follow the proposed Drupal CSS coding standards to name the variables.
    • Add a comment when there's a value where there is not a variable like font-size: 1.23rem; /* @todo One off value. */
    • When possible, set variables at the root of the component and then map them to global theme variables:
      .entity-meta {
                --entity-meta-title-font-size: var(--font-size-h5);
      
                ... more style
              }
      
              .entity-meta__title {
                font-size: var(--entity-meta-title-font-size);
              }

Out of scope

  • Changing CSS classes
  • Drupal 9 patches

User interface changes

None. There should be no visual differences.
Please post before/after screenshots and make sure they look the same.

Issue fork drupal-3332430

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Stockfoot created an issue. See original summary.

hot_sauce’s picture

Assigned: Unassigned » hot_sauce

I am working on this.

gauravvvv’s picture

Version: 10.0.x-dev » 10.1.x-dev
gauravvvv’s picture

Status: Active » Needs review
StatusFileSize
new4.12 KB
new37.29 KB
new26.09 KB

I have attached the patch and before/after screenshots for reference. please review
Before patch:

After patch:

aziza_a’s picture

Checked changes - looks good

+RTBC

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Patch #5 appears good.

Thanks for the screenshots!

hot_sauce’s picture

Status: Reviewed & tested by the community » Needs review

@Gauravvv

Thank you for the work on your patch. I was working on an MR as part of Florida DrupalCamp last week and got around to finally pushing it up today.

In comparing my MR with your patch, I think there is still room for improvement on this to help modernize the CSS more.

- For .pager__link, .pager__item--current we can do more conversion to CSS Logical properties by changing min-width and height to min-inline-size and block-size respectively

- We can move the CSS variables out of :root and into the .pager class since all of these will apply to anything within pager since it's best practice to not use :root if we don't have to

- In addition, the naming conventions for the pager variables wasn't consistent. Some used one - and some used two, so I adjusted that for consistency sake.

- We can also make CSS variables out of the background images for the .pager__item classes, and then further consolidate the @media (forced-colors: active) query to use these for the mask-image as well like this

.pager__item--first .pager__link::before {
  --background-image: url(../../images/icons/545560/pager-first.svg);
}
.pager__item--previous .pager__link::before {
  --background-image: url(../../images/icons/545560/pager-prev.svg);
}
.pager__item--next .pager__link::after {
  --background-image: url(../../images/icons/545560/pager-next.svg);
}
.pager__item--last .pager__link::after {
  --background-image: url(../../images/icons/545560/pager-last.svg);
}
.pager__item--first .pager__link::before,
.pager__item--previous .pager__link::before,
.pager__item--next .pager__link::after,
.pager__item--last .pager__link::after {
  position: relative;
  display: inline-block;
  inline-size: 1rem;
  block-size: 1rem;
  content: "";
  background-image: var(--background-image);
  background-repeat: no-repeat;
  background-position: center;
}

@media (forced-colors: active) {
  .pager__item--first .pager__link::before,
  .pager__item--previous .pager__link::before,
  .pager__item--next .pager__link::after,
  .pager__item--last .pager__link::after {
    background-color: linktext;
    background-image: none;
    mask-image: var(--background-image);
    mask-repeat: no-repeat;
    mask-position: center;
  }
}

This is, admittedly, my first contribution to Drupal directly but I think that with some tweaking between the patch and the MR we can find the best solutions here.

gauravvvv’s picture

Hi @hotsaucedesign, You have assigned the issue to yourself and there were no updates for the last 5 days. So I picked up the issue. I will make sure to ask first then only I will pick issues. thankyou

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new5.08 KB
new22.25 KB
new26.82 KB

Nesting looks good. Adding some screenshots to show they have not broken anything (that I see).

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
hot_sauce’s picture

Status: Needs work » Needs review

@laurii

Thank you for the review, I've pushed up the fixes and commented on a couple of things, please let me know if this warrants any further work!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new234.65 KB

RTL seems working

rtl

  • ckrina committed 30a1e232 on 10.1.x
    Issue #3332430 by hot_sauce, Gauravvvv, smustgrave, Stockfoot, lauriii:...
ckrina’s picture

Status: Reviewed & tested by the community » Fixed

Committed 30a1e23 and pushed to 10.1.x. Thanks!

Note about the unresolved comment by @lauriii about the background image: the answer given by @hot_sauce about making it easier to theme forced-colors made sense to me, plus discussed with @lauriii and he's OK with the existing state.

Status: Fixed » Closed (fixed)

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