Refactor Claro's pager stylesheet

Created on 10 January 2023, over 1 year ago
Updated 13 March 2023, over 1 year ago

Problem/Motivation

This is a child of 🌱 [META] Update Claro CSS with new coding standards Active and part of 🌱 [PLAN] Drupal CSS Modernization Initiative Active .

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.

📌 Task
Status

Fixed

Version

10.1 ✨

Component
Claro  →

Last updated about 9 hours ago

Created by

🇺🇸United States Stockfoot

Live updates comments and jobs are added and updated live.
  • CSS

    It involves the content or handling of Cascading Style Sheets.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States hotsaucedesign

    I am working on this.

  • @hotsaucedesign opened merge request.
  • 🇮🇳India Gauravvv Delhi, India
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Gauravvv Delhi, India

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

    After patch:

  • 🇮🇳India Aziza Anwari Gujarat

    Checked changes - looks good

    +RTBC

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Patch #5 appears good.

    Thanks for the screenshots!

  • @hotsaucedesign opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States hotsaucedesign

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

  • 🇮🇳India Gauravvv Delhi, India

    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

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

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

  • Status changed to Needs work over 1 year ago
  • 🇫🇮Finland lauriii Finland
  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    RTL seems working

    • ckrina → committed 30a1e232 on 10.1.x
      Issue #3332430 by hot_sauce, Gauravvvv, smustgrave, Stockfoot, lauriii:...
  • Status changed to Fixed over 1 year ago
  • 🇪🇸Spain ckrina Barcelona

    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.

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

Production build 0.69.0 2024