react-tailwindcss-style 1.0.1
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/.github/workflows/node.js.yml +28 -0
- package/.prettierrc +7 -0
- package/LICENSE +21 -0
- package/README.md +116 -0
- package/babel.config.js +12 -0
- package/cli.sh +1 -0
- package/color.js +10 -0
- package/corePlugins/alignContent.js +10 -0
- package/corePlugins/alignItems.js +9 -0
- package/corePlugins/alignSelf.js +10 -0
- package/corePlugins/backfaceVisibility.js +6 -0
- package/corePlugins/backgroundColor.js +4 -0
- package/corePlugins/borderColor.js +4 -0
- package/corePlugins/borderRadius.js +19 -0
- package/corePlugins/borderRadiusDir.js +11 -0
- package/corePlugins/borderStyle.js +7 -0
- package/corePlugins/borderWidth.js +13 -0
- package/corePlugins/borderWidthDir.js +8 -0
- package/corePlugins/bottom.js +4 -0
- package/corePlugins/boxShadow.js +4 -0
- package/corePlugins/direction.js +7 -0
- package/corePlugins/display.js +6 -0
- package/corePlugins/end.js +4 -0
- package/corePlugins/flex.js +4 -0
- package/corePlugins/flexDirection.js +8 -0
- package/corePlugins/flexGrow.js +4 -0
- package/corePlugins/flexShrink.js +4 -0
- package/corePlugins/flexWrap.js +7 -0
- package/corePlugins/fontFamily.js +4 -0
- package/corePlugins/fontPadding.js +6 -0
- package/corePlugins/fontSize.js +4 -0
- package/corePlugins/fontStyle.js +6 -0
- package/corePlugins/fontWeight.js +13 -0
- package/corePlugins/height.js +4 -0
- package/corePlugins/inset.js +7 -0
- package/corePlugins/insetDir.js +6 -0
- package/corePlugins/justifyContent.js +10 -0
- package/corePlugins/left.js +4 -0
- package/corePlugins/letterSpacing.js +4 -0
- package/corePlugins/lineHeight.js +4 -0
- package/corePlugins/margin.js +13 -0
- package/corePlugins/maxHeight.js +4 -0
- package/corePlugins/maxWidth.js +4 -0
- package/corePlugins/minHeight.js +4 -0
- package/corePlugins/minWidth.js +4 -0
- package/corePlugins/objectFit.js +8 -0
- package/corePlugins/opacity.js +4 -0
- package/corePlugins/overflow.js +7 -0
- package/corePlugins/padding.js +13 -0
- package/corePlugins/position.js +6 -0
- package/corePlugins/resize.js +9 -0
- package/corePlugins/right.js +4 -0
- package/corePlugins/start.js +4 -0
- package/corePlugins/textAlign.js +9 -0
- package/corePlugins/textColor.js +4 -0
- package/corePlugins/textDecoration.js +8 -0
- package/corePlugins/textShadow.js +4 -0
- package/corePlugins/textTransform.js +8 -0
- package/corePlugins/tint.js +4 -0
- package/corePlugins/top.js +4 -0
- package/corePlugins/verticalAlign.js +8 -0
- package/corePlugins/width.js +4 -0
- package/corePlugins/zIndex.js +4 -0
- package/index.d.ts +5327 -0
- package/index.js +15 -0
- package/package.json +38 -0
- package/stubs/defaultConfig.stub.js +583 -0
- package/stubs/simpleConfig.stub.js +5 -0
- package/tailwind.js +121 -0
- package/util/configHandler.js +11 -0
- package/util/generator.js +409 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [10.x, 12.x, 14.x]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v2
|
|
23
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
24
|
+
uses: actions/setup-node@v1
|
|
25
|
+
with:
|
|
26
|
+
node-version: ${{ matrix.node-version }}
|
|
27
|
+
- run: npm i
|
|
28
|
+
- run: npm test
|
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Elias Gao
|
|
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,116 @@
|
|
|
1
|
+
# react-tailwindcss-style [](https://www.npmjs.com/package/react-tailwindcss-style)
|
|
2
|
+
## A react-native styling system, based on [TailwindCSS](https://tailwindcss.com/docs/what-is-tailwind/)
|
|
3
|
+
Easily apply styles to react native components in a <a href='https://tailwindcss.com/docs/what-is-tailwind/'>tailwindCSS</a>-like fashion.
|
|
4
|
+
The utility classes are transformed to valid object names and are all children of an object ( `t`, `tw`, `theme` or `tailwind`).
|
|
5
|
+
|
|
6
|
+
```jsx harmony
|
|
7
|
+
import { t } from 'react-tailwindcss-style';
|
|
8
|
+
|
|
9
|
+
<View style={[t.absolute, t.inset0, t.p4, t.bgBlue500]} />
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Use the `tailwind.config.js` file you know and love, to customize your styles or just use default tailwind styles.
|
|
13
|
+
|
|
14
|
+
In react native, sometimes you only need a color value. We've got you covered.
|
|
15
|
+
The `color` object contains all your defined colors.
|
|
16
|
+
|
|
17
|
+
```jsx harmony
|
|
18
|
+
import { color } from 'react-tailwindcss-style';
|
|
19
|
+
|
|
20
|
+
<StatusBar backgroundColor={color.blue500} />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
React native has no default css styling so there are some *special cases*.
|
|
24
|
+
Some elements like breakpoints, plugins, corePlugin disabling, prefixes, separators, variation and the important toggle are not necessary and are ignored.
|
|
25
|
+
|
|
26
|
+
You should also take a look at some special cases:
|
|
27
|
+
- [separator handling (`-m-5` and `w-1/5`)](#general-conventions)
|
|
28
|
+
- [shadows](#shadows)
|
|
29
|
+
- [directional layout](#directional-layout)
|
|
30
|
+
- [more details](https://tvke.github.io/react-tailwindcss-style/special-cases.html)
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
Install this package
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
# Using npm
|
|
37
|
+
npm install react-tailwindcss-style
|
|
38
|
+
|
|
39
|
+
# Using Yarn
|
|
40
|
+
yarn add react-tailwindcss-style
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Then initialize a new tailwindCSS config file
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npx RNtailwindcss
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
or use an existing one.
|
|
51
|
+
|
|
52
|
+
## Usage with `styled-components`
|
|
53
|
+
|
|
54
|
+
`react-tailwindcss-style` plays nicely with the popular [`styled-components` library](https://styled-components.com/docs/basics#react-native).
|
|
55
|
+
|
|
56
|
+
Simply use the array syntax within the interpolated template literal:
|
|
57
|
+
|
|
58
|
+
```jsx harmony
|
|
59
|
+
import { Text, View } from 'react-native';
|
|
60
|
+
import { t } from 'react-tailwindcss-style';
|
|
61
|
+
import styled from 'styled-components/native';
|
|
62
|
+
|
|
63
|
+
const SView = styled(View)`
|
|
64
|
+
${[t.mB4, t.bgGray200, t.rounded, t.p3]}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
<SView>
|
|
68
|
+
<Text>Some unstyled text in a styled view</Text>
|
|
69
|
+
</SView>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## General Conventions
|
|
73
|
+
|
|
74
|
+
Every 'class' uses the *camelCase* naming convention instead of tailwindCSS's *kebab-case*.
|
|
75
|
+
```
|
|
76
|
+
border-t-2 => t.borderT2
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A `-` in the beginning of a 'class' becomes a `_`.
|
|
80
|
+
```
|
|
81
|
+
-mt-2 => t._mT2
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A `/` also becomes a `_` to separate the numbers.
|
|
85
|
+
```
|
|
86
|
+
w-1/3 => t.w1_3
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- [more information in the docs](https://tvke.github.io/react-tailwindcss-style/translations.html)
|
|
90
|
+
|
|
91
|
+
## Special cases
|
|
92
|
+
|
|
93
|
+
### Shadows
|
|
94
|
+
|
|
95
|
+
- Android does not use the shadow props to cast shadows, just an `elevation` value.
|
|
96
|
+
- The `elevation` value is by default the `shadowRadius / 2`
|
|
97
|
+
- It can be changed by adding the `elevation` value after the shadow separated by a `,`. <br>
|
|
98
|
+
(eg.: `default: '0 1px 3px 0 rgba(0, 0, 0, .1), 5'`)
|
|
99
|
+
|
|
100
|
+
- Text shadows use the same shadows as box shadows
|
|
101
|
+
- Multiple shadows are not supported in React native. (the first shadow will be used)
|
|
102
|
+
- `inner` and `outline` shadows are ignored
|
|
103
|
+
|
|
104
|
+
### Directional Layout
|
|
105
|
+
|
|
106
|
+
When you need directional layout, React Native offers some variations to make life easier.
|
|
107
|
+
Instead of using 'left' or 'right', 'start' and 'end' can be used.
|
|
108
|
+
|
|
109
|
+
`react-tailwindcss-style` offers classes to embrace this way of directional layout.
|
|
110
|
+
Every 'class' with `L` or `R`, also has a corresponding `S` and `E` 'class' for start and end.
|
|
111
|
+
|
|
112
|
+
## Testing
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
npm run test
|
|
116
|
+
```
|
package/babel.config.js
ADDED
package/cli.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cp ../react-tailwindcss-style/stubs/defaultConfig.stub.js tailwind.config.js
|
package/color.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('rounded', 'borderRadius', theme.borderRadius, [
|
|
5
|
+
['t', ['borderTopLeftRadius', 'borderTopRightRadius']],
|
|
6
|
+
['r', ['borderTopRightRadius', 'borderBottomRightRadius']],
|
|
7
|
+
['b', ['borderBottomLeftRadius', 'borderBottomRightRadius']],
|
|
8
|
+
['l', ['borderTopLeftRadius', 'borderBottomLeftRadius']],
|
|
9
|
+
['tl', 'borderTopLeftRadius'],
|
|
10
|
+
['tr', 'borderTopRightRadius'],
|
|
11
|
+
['br', 'borderBottomRightRadius'],
|
|
12
|
+
['bl', 'borderBottomLeftRadius'],
|
|
13
|
+
['e', ['borderTopEndRadius', 'borderBottomEndRadius']],
|
|
14
|
+
['s', ['borderTopStartRadius', 'borderBottomStartRadius']],
|
|
15
|
+
['ts', 'borderTopStartRadius'],
|
|
16
|
+
['te', 'borderTopEndRadius'],
|
|
17
|
+
['be', 'borderBottomEndRadius'],
|
|
18
|
+
['bs', 'borderBottomStartRadius'],
|
|
19
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('rounded-dir', 'borderRadius', theme.borderRadius, [
|
|
5
|
+
['e', ['borderTopEndRadius', 'borderBottomEndRadius']],
|
|
6
|
+
['s', ['borderTopStartRadius', 'borderBottomStartRadius']],
|
|
7
|
+
['ts', 'borderTopStartRadius'],
|
|
8
|
+
['te', 'borderTopEndRadius'],
|
|
9
|
+
['be', 'borderBottomEndRadius'],
|
|
10
|
+
['bs', 'borderBottomStartRadius'],
|
|
11
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('border', 'borderWidth', theme.borderWidth, [
|
|
5
|
+
['x', ['borderRightWidth', 'borderLeftWidth']],
|
|
6
|
+
['y', ['borderTopWidth', 'borderBottomWidth']],
|
|
7
|
+
['t', 'borderTopWidth'],
|
|
8
|
+
['r', 'borderRightWidth'],
|
|
9
|
+
['b', 'borderBottomWidth'],
|
|
10
|
+
['l', 'borderLeftWidth'],
|
|
11
|
+
['e', 'borderEndWidth'],
|
|
12
|
+
['s', 'borderStartWidth'],
|
|
13
|
+
]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('border-dir', 'borderWidth', theme.borderWidth, [
|
|
5
|
+
['x', ['borderEndWidth', 'borderStartWidth']],
|
|
6
|
+
['e', 'borderEndWidth'],
|
|
7
|
+
['s', 'borderStartWidth'],
|
|
8
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
|
|
3
|
+
export default generator.generate('font', 'fontWeight', [
|
|
4
|
+
'normal',
|
|
5
|
+
'bold',
|
|
6
|
+
['hairline', 100],
|
|
7
|
+
['thin', 200],
|
|
8
|
+
['light', 300],
|
|
9
|
+
['medium', 500],
|
|
10
|
+
['semibold', 600],
|
|
11
|
+
['extrabold', 800],
|
|
12
|
+
['black', 900],
|
|
13
|
+
]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
|
|
3
|
+
export default generator.generate('justify', 'justifyContent', [
|
|
4
|
+
['start', 'flex-start'],
|
|
5
|
+
['end', 'flex-end'],
|
|
6
|
+
'center',
|
|
7
|
+
['between', 'space-between'],
|
|
8
|
+
['around', 'space-around'],
|
|
9
|
+
['evenly', 'space-evenly'],
|
|
10
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('m', 'margin', theme.margin, [
|
|
5
|
+
['x', 'marginHorizontal'],
|
|
6
|
+
['y', 'marginVertical'],
|
|
7
|
+
['t', 'marginTop'],
|
|
8
|
+
['r', 'marginRight'],
|
|
9
|
+
['b', 'marginBottom'],
|
|
10
|
+
['l', 'marginLeft'],
|
|
11
|
+
['s', 'marginStart'],
|
|
12
|
+
['e', 'marginEnd'],
|
|
13
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import generator from '../util/generator';
|
|
2
|
+
import theme from '../util/configHandler';
|
|
3
|
+
|
|
4
|
+
export default generator.generate('p', 'padding', theme.padding, [
|
|
5
|
+
['x', 'paddingHorizontal'],
|
|
6
|
+
['y', 'paddingVertical'],
|
|
7
|
+
['t', 'paddingTop'],
|
|
8
|
+
['r', 'paddingRight'],
|
|
9
|
+
['b', 'paddingBottom'],
|
|
10
|
+
['l', 'paddingLeft'],
|
|
11
|
+
['s', 'paddingStart'],
|
|
12
|
+
['e', 'paddingEnd'],
|
|
13
|
+
]);
|