All Projects → sandrina-p → Postcss Start To End

sandrina-p / Postcss Start To End

Licence: mit
PostCSS plugin that lets you control your layout (LTR or RTL) through logical rather than physical rules

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postcss Start To End

Postcss Aspect Ratio Mini
A PostCSS plugin to fix an element's dimensions to an aspect ratio
Stars: ✭ 123 (+583.33%)
Mutual labels:  postcss, postcss-plugins
Postcss Rtl
PostCSS plugin for RTL-adaptivity
Stars: ✭ 143 (+694.44%)
Mutual labels:  rtl, postcss
Rucksack
A little bag of CSS superpowers, built on PostCSS
Stars: ✭ 1,861 (+10238.89%)
Mutual labels:  postcss, postcss-plugins
Postcss Plugins
The "officially unofficial" consolidated list of PostCSS plugins in a ready-to-use package
Stars: ✭ 107 (+494.44%)
Mutual labels:  postcss, postcss-plugins
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (+0%)
Mutual labels:  postcss, postcss-plugins
Postcss High Contrast
Create high contrast version of your project with ease.
Stars: ✭ 108 (+500%)
Mutual labels:  postcss, postcss-plugins
Rtlcss
Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL)
Stars: ✭ 1,363 (+7472.22%)
Mutual labels:  rtl, postcss
Stencil Postcss
Autoprefixer plugin for Stencil
Stars: ✭ 19 (+5.56%)
Mutual labels:  postcss, postcss-plugins
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (+27.78%)
Mutual labels:  postcss, postcss-plugins
laggard
Automatically generate CSS fallbacks for legacy browsers, built on PostCSS
Stars: ✭ 23 (+27.78%)
Mutual labels:  postcss, postcss-plugins
Postcss Font Family System Ui
PostCSS plugin to transform W3C CSS font-family: system-ui to a practical font-family list
Stars: ✭ 91 (+405.56%)
Mutual labels:  postcss, postcss-plugins
Postcss Utilities
PostCSS plugin to add a collection of mixins, shortcuts, helpers and tools for your CSS
Stars: ✭ 293 (+1527.78%)
Mutual labels:  postcss, postcss-plugins
Postcss At Rules Variables
PostCss plugin to use CSS Custom Properties in at-rule @each, @for, @if, @else and more...
Stars: ✭ 52 (+188.89%)
Mutual labels:  postcss, postcss-plugins
Postcss Instagram
📷 PostCSS plugin for using Instagram filters in CSS
Stars: ✭ 111 (+516.67%)
Mutual labels:  postcss, postcss-plugins
Postcss Selector Not
PostCSS plugin to transform :not() W3C CSS level 4 pseudo class to more compatible CSS (multiple css3 :not() selectors)
Stars: ✭ 49 (+172.22%)
Mutual labels:  postcss, postcss-plugins
Stylefmt
stylefmt is a tool that automatically formats stylesheets.
Stars: ✭ 2,123 (+11694.44%)
Mutual labels:  postcss, postcss-plugins
postcss-if-media
A PostCSS plugin to inline or nest media queries within CSS rules & properties.
Stars: ✭ 35 (+94.44%)
Mutual labels:  postcss, postcss-plugins
postcss-bidirection
PostCSS plugin that polyfill Bi-directional CSS properties and values to suppot rtl and ltr rules in all browsers
Stars: ✭ 24 (+33.33%)
Mutual labels:  postcss, rtl
Postcss Cssnext
`postcss-cssnext` has been deprecated in favor of `postcss-preset-env`.
Stars: ✭ 5,388 (+29833.33%)
Mutual labels:  postcss, postcss-plugins
Postcss Cli
CLI for postcss
Stars: ✭ 621 (+3350%)
Mutual labels:  postcss

PostCSS Start To End

npm version Build Status

PostCSS plugin that lets you control your layout (ltr or rtl) through logical rather than direction / physical rules.

Inspired by Flexbox and CSS Grid syntax, use start or end to output left or right depending on document direction (rtl or ltr).

Input

.foo {
    padding-start: 1rem;
    border-end: 1rem solid teal;
}

Output

.foo {
   padding-left: 1rem;
   border-right: 1rem solid teal;
}

Usage

postcss([
    require('postcss-start-to-end'),
    require('postcss-reporter') // show warnings - check options to know more
])

With some options

postcss([
    require('postcss-start-to-end')({
        direction: 'RTL',
        warnings: false,
    }),
    require('postcss-reporter')
]);

Options

direction

Default writing mode of CSS. Type: string Default: 'LTR' Values: 'LTR', 'RTL'

Input

.item {
    border-start: 1px solid teal;
    padding: 0 3rem 0 0;
}

output with direction: 'LTR'

.item {
    border-left: 1px solid teal;
    padding: 0 3rem 0 0;
}

output with direction: 'RTL'

.item {
    border-right: 1px solid teal;
    padding: 0 0 0 3rem;
}

warnings

Output on CLI warnings about properties / rules found that don't follow start-to-end syntax. Type: boolean Default: true Values: true, false

Example

.item {
    margin-left: 10%;
}

Console warning if direction: ltr:

margin-left: 10%; found on line 2. Replace it by margin-start to support LTR and RTL directions.

Console warning if direction: rtl:

margin-left: 10%; found on line 2. Replace it by margin-end to support LTR and RTL directions.

ignoreNodeModules

Ignore any CSS file inside /node_modules folder. Type: boolean Default: true Values: true, false

Rules supported

Input Output LTR output RTL
Alignment
text-align: start; text-align: left; text-align: right;
text-align: end; text-align: right; text-align: left;
Clear
clear: start; clear: left; clear: right;
clear: end; clear: right; clear: left;
Float
float: start; float: left; float: right;
float: end; float: right; float: left;
Border
border-start border-left border-right
border-end border-right border-left
border-top-start border-top-left border-top-right
border-top-end border-top-right border-top-left
border-bottom-end border-bottom-right border-bottom-left
border-bottom-start border-bottom-left border-bottom-right
Margin
margin-start margin-left margin-right
margin-end margin-right margin-left
margin: 0 2rem 0 3rem; margin: 0 2rem 0 3rem; margin: 0 3rem 0 2rem;
Padding
padding-start padding-left padding-right
padding-end padding-right padding-left
padding: 0 1rem 0 4rem; padding: 0 1rem 0 4rem; padding: 0 4rem 0 1rem;
Position
start: 1rem; left: 1rem; right: 1rem;
end: 1rem; right: 1rem; left: 1rem;

BONUS: Convert your existing code to this syntax

Don't you feel like find/replace rules in each one of your *.css files?

No worries, I built a simple tool that does that for you. You just need to tell where you want to run the converter (folder or file.css). By default it runs in src folder

Input

.item {
    padding-left: 5rem;
    margin-right : 1rem;
    float:left;
}

Convert from LTR layout

Convert by default runs on src folder node node_modules/postcss-start-to-end/convert

Set a specific folder to run: node node_modules/postcss-start-to-end/convert src/components

Set a specific file to run: node node_modules/postcss-start-to-end/convert styles/index.css

Output

.item {
    padding-start: 5rem;
    margin-end : 1rem;
    float:start;
}

Convert RTL layout

Convert by default runs on src folder node node_modules/postcss-start-to-end/convert --rtl

Set a specific folder to run: node node_modules/postcss-start-to-end/convert src/components --rtl

Set a specific file to run: node node_modules/postcss-start-to-end/convert styles/index.css --rtl

Output

.item {
    padding-end: 5rem;
    margin-start : 1rem;
    float:end;
}

F.A.Q.

Why should I use this instead of plugins that convert *-left to *-right and vice-versa?

This is not a replacement of those kind of plugins.

This is a plugin to let you write code with a logical thought in mind rather than a physical/direction one.

Then if you need to convert the outputted CSS to the opposite direction you might want to try postcss-rtl.

Is this tested?

  • The PostCSS Plugin has 100% coverage test with all possible scenarios that crossed my mind.
  • The Converter tests will be added soon!
  • Don't fear: Travis-ci is doing it's job!

Motivation | References

There is a CSS Draft Spec about CSS Logical Properties in Level 1. Because this technology's specification has not stabilized, I decided to keep this plugin syntax simple and straight following what is already defined without adding more sugar.

Contribute

Any doubts or suggestions you may have, feel free to create an issue on github repository.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].