penobit/css-flip

Flips css codes from ltr to rtl (or rtl to ltr)

v1.1 2021-07-12 17:19 UTC

This package is auto-updated.

Last update: 2024-11-13 01:11:40 UTC


README

Build Status Latest Stable Version Total Downloads Downloads Month Petreon donation PayPal donation

Flip css/scss direction from ltr to rtl or rtl to ltr with single line php code!

Installation

Install this package via Composer.

composer require penobit/css-flip

You can also download latest release from Github and include src/CSSFlip.php manually but i recommend using composer to stay up to date and easier install and usage

Usage

Create CSSFlip object

use Penobit\CSSFlip\CSSFlip;

$cssFlip = new CSSFlip();
$cssCode = <<<CSS
body{
  direction: ltr;
}
div{
  text-align:left;
  margin-left: 20px;
  margin-right: 2rem;
}
span{
  padding: 10px 15px 20px 25px;
}
CSS;

$flippedCssCode = $cssFlip->transform($cssCode);

/* 
# Output of above code will be
body{
  direction: rtl;
}
div{
  text-align:right;
  margin-right: 20px;
  margin-left: 2rem;
}
span{
  padding: 10px 15px 20px 25px;
  padding: 10px 25px 20px 15px;
}
*/