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
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 3312966-error.png | 523.06 KB | nayana_mvr |
Issue fork drupal-3312966
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
Comment #3
longwaveThere is an npm package that lets us enforce this in Stylelint: https://www.npmjs.com/package/stylelint-use-logical-spec
Running this against core gives 4263 errors and some of these are likely false positives, we might need to break this up into different CSS rules.
Comment #4
longwaveComment #5
mherchelIs there a way to only enforce it for CSS properties that are in the diff?
Comment #6
mherchelNote that if/when we implement this, we need to allow certain non-logical rules including
floatandclearto accommodate #3313146: PostCSS Logical not transpiling flow relative properties (e.g. float: inline-start) which are not supported by Chrome and SafariIt looks like stylelint-use-logical-spec supports this (see https://github.com/Jordan-Hall/stylelint-use-logical-spec#except)
Comment #7
alexpottI was looking at using the fixer but unfortunately we fall over on https://github.com/Jordan-Hall/stylelint-use-logical-spec/issues/28
Comment #8
mherchelComment #9
longwaveThe issue linked in #7 was closed by stylelint-use-logical-spec v5.0.0, so hopefully it's time to revisit this.
Comment #12
alexpottHiding patches.
Comment #13
xjmI postponed #2485497: Clean up locale CSS in line with our CSS standards on this issue.
Comment #17
quietone commented@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
Comment #18
nod_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
Here when in RTL, we add the equivalent of a
padding-left, not the wantedpadding-right!And the proper fix is:
Comment #19
nod_seems the config of the lint check is broken
Comment #20
nod_It's easier to revert the last commit, fix the config and rerun the linter
Comment #21
quietone commented@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.
Comment #23
nod_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).
Comment #24
quietone commented@nod_, I think the choice is yours to make. Which do you prefer?
Comment #25
nod_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.
Comment #27
quietone commentedShall we break this into smaller child issues? What is a good way to do that for this type of change?
Comment #28
nod_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.
Comment #30
nayana_mvr commentedI think the comment
added as part of the ticket https://www.drupal.org/project/drupal/issues/3313146 is no longer required since the issue (https://github.com/csstools/postcss-plugins/issues/632) mentioned in that comment is already closed.
Comment #31
quietone commented@nayana_mvr, Can you explain how you found the 'missing ,css files' ?
Comment #32
nayana_mvr commentedThere 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:cssin core folder and found that the .css files corresponding to the .pcss.css files shown in the error are not pushed to the branch.