tailwindthml-flips 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +35 -0
- package/lib/margin.js +24 -0
- package/lib/padding.js +24 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2021] [Rajeesh C V]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<img src="./img/logo.svg" height="60" align="right" />
|
|
2
|
+
|
|
3
|
+
# tailwindcss flip
|
|
4
|
+
|
|
5
|
+
[tailwindcss](https://tailwindcss.com) plugin for adding RTL(right-to-left) support.
|
|
6
|
+
|
|
7
|
+
If your application needs to support multiple languages, then RTL support is a common requirement. Unfortunately, [tailwindcss](https://tailwindcss.com) doesn't have out-of-the-box support for RTL layout. There are few other plugins already exists like [tailwindcss-rtl](https://www.npmjs.com/package/tailwindcss-rtl) and [tailwindcss-dir](https://github.com/RonMelkhior/tailwindcss-dir). Both plugins generate variant styles, and you need to add those classes to the code; which is an additional effort if you already have an existing application.
|
|
8
|
+
|
|
9
|
+
**tailwindcss-flip** takes an approach were, no code change is required instead, we generate utility classes using `[dir=rtl]` html attribute css selector.
|
|
10
|
+
|
|
11
|
+
<img src="./img/demo.gif" />
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
1. Install **tailwindcss-flip** package:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
# Install using NPM
|
|
19
|
+
npm install tailwindcss-flip --save-dev
|
|
20
|
+
|
|
21
|
+
# Install using Yarn
|
|
22
|
+
yarn add tailwindcss-flip --dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. Add plugin to your `tailwind.conf.js` file:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
plugins: [require("tailwindcss-flip")],
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How to use
|
|
32
|
+
|
|
33
|
+
Add `dir=rtl` attribute to the HTML tag or root element of your page. That's it, this plugin will automatically generate all the required utility classes for you.
|
|
34
|
+
|
|
35
|
+
You can check the [example](./example) folder to see the usage in a react application.
|
package/lib/margin.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const flatMap = require("lodash.flatmap");
|
|
4
|
+
|
|
5
|
+
module.exports = function ({ addUtilities, theme, variants }) {
|
|
6
|
+
const generators = [
|
|
7
|
+
(size, modifier) => ({
|
|
8
|
+
[`[dir=rtl] .mr-${modifier}`]: {
|
|
9
|
+
"margin-left": `${size}`,
|
|
10
|
+
"margin-right": "unset",
|
|
11
|
+
},
|
|
12
|
+
[`[dir=rtl] .ml-${modifier}`]: {
|
|
13
|
+
"margin-left": "unset",
|
|
14
|
+
"margin-right": `${size}`,
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const utilities = flatMap(generators, (generator) => {
|
|
20
|
+
return flatMap(theme("margin"), generator);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
addUtilities(utilities, variants("margin"));
|
|
24
|
+
};
|
package/lib/padding.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const flatMap = require("lodash.flatmap");
|
|
4
|
+
|
|
5
|
+
module.exports = function ({ addUtilities, theme, variants }) {
|
|
6
|
+
const generators = [
|
|
7
|
+
(size, modifier) => ({
|
|
8
|
+
[`[dir=rtl] .pr-${modifier}`]: {
|
|
9
|
+
"padding-left": `${size}`,
|
|
10
|
+
"padding-right": "unset",
|
|
11
|
+
},
|
|
12
|
+
[`[dir=rtl] .pl-${modifier}`]: {
|
|
13
|
+
"padding-left": "unset",
|
|
14
|
+
"padding-right": `${size}`,
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const utilities = flatMap(generators, (generator) => {
|
|
20
|
+
return flatMap(theme("padding"), generator);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
addUtilities(utilities, variants("padding"));
|
|
24
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwindthml-flips",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "RTL plugin for tailwindcss",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib/*.js"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/cvrajeesh/tailwindcss-flip.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"tailwindcss",
|
|
18
|
+
"rtl"
|
|
19
|
+
],
|
|
20
|
+
"author": "Rajeesh C V",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/cvrajeesh/tailwindcss-flip/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/cvrajeesh/tailwindcss-flip#readme",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"global": "^4.4.0",
|
|
28
|
+
"lodash.flatmap": "^4.5.0"
|
|
29
|
+
}
|
|
30
|
+
}
|