项目作者: aelafifi

项目描述 :
PHP CSS Flipper for supporting RTL designs
高级语言: PHP
项目地址: git://github.com/aelafifi/CssFlipper.git
创建时间: 2017-08-08T17:12:39Z
项目社区:https://github.com/aelafifi/CssFlipper

开源协议:MIT License

下载


CssFlipper

PHP CSS Flipper for supporting RTL designs

Based on twitter/css-flip Rules

How to use?!

  1. <?php
  2. require_once '/path/to/CssFlipper.php';
  3. $css = "Some Code...";
  4. $flipped_code = CssFlipper::flipCss($css);
  5. ?>

Flip what??

Properites:

  • border-left <-> border-right
  • border-bottom-left-radius <-> border-bottom-right-radius
  • border-top-left-radius <-> border-top-right-radius
  • border-left-color <-> border-right-color
  • border-left-style <-> border-right-style
  • border-left-width <-> border-right-width
  • left <-> right
  • margin-left <-> margin-right
  • padding-left <-> padding-right

Values:

  1. .some-element {
  2. /* x, y */
  3. background-position: left top; /* <-> */ background-position: right top;
  4. background-position: 10% 10%; /* <-> */ background-position: 90% 10%;
  5. background-position: -10% -10%; /* <-> */ background-position: 110% -10%;
  6. background-position: 10px 20px; /* not supported yet! */
  7. /* same as "background-position" */
  8. background-position-x: left; /* <-> */ background-position-x: right;
  9. transform-origin: left top; /* <-> */ transform-origin: right top;
  10. perspective-origin: left top; /* <-> */ perspective-origin: right top;
  11. /* not supported! */
  12. background: url(bla_bla_bla) no-repeat left top / cover;
  13. /* (top-left and bottom-right), (top-right and bottom-left) */
  14. border-radius: 1px 2px; /* <-> */ border-radius: 2px 1px;
  15. /* (top-left), (top-right and bottom-left), (bottom-right) */
  16. border-radius: 1px 2px 3px; /* <-> */ border-radius: 2px 1px 2px 3px;
  17. /* (top-left), (top-right), (bottom-right), (bottom-left) */
  18. border-radius: 1px 2px 3px 4px; /* <-> */ border-radius: 2px 1px 4px 3px;
  19. /* top, right, bottom, left */
  20. border-color: #111 #222 #333 #444; /* <-> */ border-color: #111 #444 #333 #222;
  21. border-style: solid dotted double dashed; /* <-> */ border-style: solid dashed double dotted;
  22. border-width: 1px 2px 3px 4px; /* <-> */border-width: 1px 4px 3px 2px;
  23. margin: 1px 2px 3px 4px; /* <-> */ margin: 1px 4px 3px 2px;
  24. padding: 1px 2px 3px 4px; /* <-> */ padding: 1px 4px 3px 2px;
  25. /* x, y, ... */
  26. box-shadow: 1px 2px 3px #000; /* <-> */ box-shadow: -1px 2px 3px #000;
  27. clear: left; /* <-> */ clear: right;
  28. float: left; /* <-> */ float: right;
  29. text-align: left; /* <-> */ text-align: right;
  30. direction: ltr; /* <-> */ direction: rtl;
  31. transition: left 0.3s; /* <-> */ transition: right 0.3s;
  32. transition-property: left; /* <-> */ transition-property: right;
  33. /* transform : discribed below... */
  34. }

Transform:

  1. .some-element {
  2. /* x */
  3. transform: translateX(50px); /* <-> */ transform: translateX(-50px);
  4. /* x, y */
  5. transform: translate(20px, 60px); /* <-> */ transform: translate(-20px, 60px);
  6. /* x, y, z */
  7. transform: translate3d(20px, 60px, 45px); /* <-> */ transform: translate3d(-20px, 60px, 45px);
  8. /*x-angle, y-angle*/
  9. transform: skew(10deg, -30deg); /* <-> */ transform: skew(-10deg, 30deg);
  10. /* angle*/
  11. transform: skewX(-40deg); /* <-> */ transform: skewX(40deg);
  12. transform: skewY(85deg); /* <-> */ transform: skewY(-85deg);
  13. /* angle */
  14. transform: rotate(37deg); /* <-> */ transform: rotate(-37deg);
  15. transform: rotateX(52deg); /* <-> */ transform: rotateX(-52deg);
  16. transform: rotateY(-70deg); /* <-> */ transform: rotateY(70deg);
  17. transform: rotateZ(112deg); /* <-> */ transform: rotateZ(-112deg);
  18. /* x, y, z, angle */
  19. transform: rotate3d(0, 1, 0, 54deg); /* <-> */ transform: rotate3d(0, 1, 0, -54deg);
  20. /* not supported! */
  21. transform: matrix(...);
  22. transform: matrix3d(...);
  23. }

To-Do List:

  • Support what not supported
  • Support less
  • Use PHPUnit and make tests
  • Color gradient
  • Properties after !important will not be flipped!!! [Bug]

License

Copyright 2017 Ahmed S. El-Afifi ahmed.s.elafifi@gmail.com

Licensed under the MIT License