Enforce the use of CSS Logical Properties in core

Created on 30 September 2022, about 2 years ago
Updated 20 August 2024, 4 months ago

Problem/Motivation

CSS Logical Properties enable one-line CSS declarations that work in both left-to-right and right-to-left languages.

Instead of writing

.selector {
  padding-left: 10px;
}

[dir="rtl"] .selector {
  padding-right: 10px;
}

We will now write

.selector {
  padding-inline-start: 10px;
}

Logical properties are supported by all of Drupal 10's supported browsers, and now will ship them without transpiling (as of #3312481: Update core's browserlist โ†’ ).

Steps to reproduce

Proposed resolution

We should enforce the use of logical properties through automation. This will ensure that RTL styles are not neglected, and it will also result in a smaller CSS bundle (as opposed to writing our using the dir attribute).

Remaining tasks

Failing tests:
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php
core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
CSSย  โ†’

Last updated 10 days ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    The issue linked in #7 was closed by stylelint-use-logical-spec v5.0.0, so hopefully it's time to revisit this.

  • Merge request !7761Resolve #3312966 "Logical properties" โ†’ (Open) created by alexpott
  • Pipeline finished with Failed
    8 months ago
    Total: 178s
    #157308
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Hiding patches.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    I postponed ๐Ÿ“Œ Clean up locale CSS in line with our CSS standards Postponed on this issue.

  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 260s
    #163587
  • Merge request !7903Resolve #3312966 Logical properties โ†’ (Open) created by Unnamed author
  • Pipeline finished with Failed
    8 months ago
    Total: 210s
    #163598
  • First commit to issue fork.
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @Gauravvvv, why did you make a second MR?

    I rebased MR 7761. The I ran the automated fixes. There are now 2 failing tests.

    core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php
    core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    It's nice to have a rule and automated fix for this one.

    MR needs quite a bit of work (only did 1/3 of the changed files). Essentially we need to make sure that any [dir="rtl"] rule is still needed and remove all the associated /* LTR */ comments in the CSS.

    The manual cleanup is needed because if you have

    .myclass {
      padding-left: 10px;
    }
    [dir="rtl"] .myclass {
      padding-left: 0;
      padding-right: 10px;
    }
    
  • Pipeline finished with Failed
    5 months ago
    Total: 870s
    #242719
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    seems the config of the lint check is broken

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    It's easier to revert the last commit, fix the config and rerun the linter

  • Pipeline finished with Failed
    5 months ago
    Total: 158s
    #243317
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @nod_, thanks for the review!

    While I don't know CSS very well I accepted the suggestions because they made sense to me. I then tried just a few to see if I truly understand. I look forward to feedback on those few changes.

    Still more work to do here.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    alexpott โ†’ changed the visibility of the branch 3312966-enforce-css-logical-properties to hidden.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    Thanks, the fix you tried are accurate. One thing is that the last autofix changed all the values for float/border but they are supposed to be excluded from the config. So either we change the config to remove all exceptions, or we change the code to follow the exceptions (ie. revert the last autofix commit).

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @nod_, I think the choice is yours to make. Which do you prefer?

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    I pinged folks on slack to get some more views on this. I think I'd rather go all-in we used to have a problem with postcss and the float logical values, it might be fixed by now.

  • Pipeline finished with Failed
    5 months ago
    Total: 81s
    #244977
  • First commit to issue fork.
  • Pipeline finished with Failed
    5 months ago
    Total: 149s
    #245487
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Shall we break this into smaller child issues? What is a good way to do that for this type of change?

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    breaking it down would be first automatic transform of all the css files that do not have a [dir=] rule, since automated replacement is safe.

    Then it's a little bit of case by case. Might need to see what's left to know how to split things up.

  • First commit to issue fork.
  • Pipeline finished with Failed
    3 months ago
    Total: 226s
    #300654
  • Pipeline finished with Failed
    3 months ago
    Total: 1488s
    #300754
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    I think the comment

    /**
    * Chromium and Webkit do not yet support flow relative logical properties,
    * such as float: inline-end. However, PostCSS Logical does not compile this
    * value, so we accommodate by not using these.
    *
    * @see https://caniuse.com/mdn-css_properties_clear_flow_relative_values
    * @see https://github.com/csstools/postcss-plugins/issues/632
    */

    added as part of the ticket https://www.drupal.org/project/drupal/issues/3313146 ๐Ÿ› PostCSS Logical not transpiling flow relative properties (e.g. float: inline-start) which are not supported by Chrome and Safari Fixed is no longer required since the issue (https://github.com/csstools/postcss-plugins/issues/632) mentioned in that comment is already closed.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @nayana_mvr, Can you explain how you found the 'missing ,css files' ?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    There was a pipeline error as shown below,

    It says .pcss.css file from line no. 273 is not updated. This happens when .css (compiled) file corresponding to .pcss.css file is not updated with the changes. I have faced similar issue before. Thatโ€™s why I tried the command yarn run build:css in core folder and found that the .css files corresponding to the .pcss.css files shown in the error are not pushed to the branch.

Production build 0.71.5 2024