Socket
Socket
Sign inDemoInstall

postcss-janus

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-janus

PostCSS plugin plugin to create RTL rules using CSSJanus


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Install size
1.33 MB
Created
Weekly downloads
 

Changelog

Source

1.0.2

  • Small corrections

Readme

Source

PostCSS Janus

PostCSS plugin to create RTL rules using CSSJanus.

Install

npm
nmp install postcss-janus --save-dev
yarn
yarn add postcss-janus -d

Examples

input
.example {
  background-color: #FFF;
  background-image: url("/folder/subfolder/icons/ltr/chevron.png");
  border-radius: 0 2px 0 8px;
  color: #666;
  padding-right: 20px;
  text-align: left;
  transform: translate(-50%, 50%);
  width: 100%;
}
output
.example {
  background-color: #FFF;
  background-image: url("/folder/subfolder/icons/ltr/chevron.png");
  border-radius: 0 2px 0 8px;
  color: #666;
  padding-right: 20px;
  text-align: left;
  transform: translate(-50%, 50%);
  width: 100%;
}
.rtl .example  {
    border-radius: 2px 0 8px 0;
    padding-right: unset;
    padding-left: 20px;
    text-align: right;
    transform: translate(50%, 50%);
}

Basic usage

Using postcss JavaScript API
const postcss = require('postcss');
const cssJanus = require('postcss-janus');

postcss( [ cssJanus(options) ] );
Using postcss-loader in Webpack
rules: [
    {
        test: /\.css$/,
        use: [
            { loader: 'style-loader' },
            { loader: 'css-loader' },
            {
                loader: 'postcss-loader',
                options: {
                    ident: 'postcss',
                    plugins: () => [ require('postcss-janus')(options) ]
                }
            }
        ]
    }
]

Options

OptionDefaultTypeDescription
prefixes.rtlstring or arrayIndicates the prefixes that should be added to the RTL rules
swapLtrRtlInUrlfalsebooleanSwap ltr and rtl strings in URLs
swapLeftRightInUrlfalsebooleanSwap left and right strings in URLs

Directives

Directives should be added as comments before a CSS rule block or a property, e.g:

/* @ruleDirective */
.example {
    /* @propertyDirective */
    color: white;
}
DirectiveDescription
@noflipAvoid flipping certain CSS property or an entire rule block
@swapLtrRtlInUrlSwap ltr and rtl strings in a certain property (it will ignore the global swapLtrRtlInUrl option
@swapLeftRightInUrlSwap left and right strings in a certain property (it will ignore the global swapLeftRightInUrl option

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Keywords

FAQs

Last updated on 01 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc