Coder Social home page Coder Social logo

react-inline-styler-processor-rtl's Introduction

npm version Build Status Coverage Status License: MIT

react-inline-styler-processor-rtl

(Right to left / left to right) dynamic inline styles processing.

RTL processor for React inline styler react-inline-styler

This processor adds new syntax for the inline styles mainly, "start" and "end" which are dynamically changed to left or right depending on the wanted app language direction, by specifing isRTL in the ReactInlineStylerProvider.

Getting started

npm install react-inline-styler-processor-rtl

Example Usage

//App.js

import rtlProcessor from 'react-inline-styler-processor-rtl'
// or var rtlProcessor = require('react-inline-styler-processor-rtl')

const pipeline = [rtlProcessor];
const configs = {isRTL: true};

<ReactInlineStylerProvider configs={configs} pipeline={pipeline}>
</ReactInlineStylerProvider>
//styles.js
const styles = function() {
  return {
    rootStyle: {
      float: 'start',
      paddingStart: ...
    }
  }
}

Localization list

localizing styles happens on the key of the attibute, or its value. in LTR configurations start is translated into "left" and "end" is translated into "right". in RTL, the other way around.

Localed Values

  1. float
{
  float: 'start',
  float: 'end',
}
  1. direction
{
  direction: 'start',
  direction: 'end',
}
  1. transformOrigin
{
  transformOrigin: 'start',
  transformOrigin: 'end',
}
  1. transform
{
  transform: translate
  transform: skew
}
  1. textAlign

text-align values' start and end are supported in all browers but not in IE11+ and Edge. Therefore, this transform was added.

{
  textAlign: 'start'
  textAlign: 'end'
}

Localed Keys

  1. margins and paddings
{
  marginStart: ...
  marginEnd: ...
  paddingStart: ...
  paddingEnd: ...
}
  1. positions
{
  start: ...
  end: ...
}
  1. borders
{
  borderStart: ...
  borderStartWidth: ...
  borderStartStyle: ...
  borderStartColor: ...
  borderEnd: ...
  borderEndWidth: ...
  borderEndStyle: ...
  borderEndColor: ...
}
  1. borderRadius
{
  borderTopStartRadius: ...
  borderTopEndRadius: ...
  borderBottomStartRadius: ...
  borderBottomEndRadius: ...
}

react-inline-styler-processor-rtl's People

Contributors

bamieh avatar ilaiwi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.