Skip to content

Proposal for postcss-logical #736

@romainmenke

Description

@romainmenke

The current plugin re-writes selectors with :dir().
But it is incorrect because it only considers ltr and rtl and it also changes selector specificity which can lead to bugs.

I don't think the goal must be to have a true polyfill.
This will never work without causing issues.

We can however create a really good fallback.

https://drafts.csswg.org/css-logical/#intro

The plugin inputs are :

  • block direction
  • inline direction

For English this is :

  • block: top to bottom
  • inline: left to right

For Chinese :

  • block: right to left
  • inline: top to bottom

For this CSS in English

magin-block-start: 20px;
  • block -> top to bottom
  • start -> top
  • top -> margin-top: 20px;

In Chinese :

  • block -> right to left
  • start -> right
  • right -> margin-right: 20px;

The plugin doesn't do anything more than this :

  • user configures their fallback mode
  • plugin maps to that fallback

The downside is that you can not switch modes in the same document.
But here it is important to remember that it is a fallback.
The aim is to have a readable document in both old and new browsers, not to match the full feature.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions