@kbach/native 0.1.2 → 0.1.4
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/README.md +22 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Tailwind-like utility classes for **React Native and Expo**. One package includes everything: the core engine, JSX runtime, Babel plugin for compile-time optimization, and Metro config helper.
|
|
4
4
|
|
|
5
|
-
```
|
|
5
|
+
```
|
|
6
6
|
import { View, Text, TouchableOpacity } from 'react-native';
|
|
7
7
|
import { styled } from '@kbach/native';
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ export default function Screen() {
|
|
|
27
27
|
|
|
28
28
|
## Install
|
|
29
29
|
|
|
30
|
-
```
|
|
30
|
+
```
|
|
31
31
|
npm install @kbach/native
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -37,14 +37,14 @@ That's it. Core engine, Babel plugin, and Metro helpers are bundled — nothing
|
|
|
37
37
|
|
|
38
38
|
### 1. babel.config.js
|
|
39
39
|
|
|
40
|
-
```
|
|
40
|
+
```
|
|
41
41
|
const { createKbachConfig } = require('@kbach/native');
|
|
42
42
|
module.exports = createKbachConfig();
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
If you need to keep an existing Babel config:
|
|
46
46
|
|
|
47
|
-
```
|
|
47
|
+
```
|
|
48
48
|
const { withKbachBabel } = require('@kbach/native');
|
|
49
49
|
|
|
50
50
|
module.exports = withKbachBabel({
|
|
@@ -55,7 +55,7 @@ module.exports = withKbachBabel({
|
|
|
55
55
|
|
|
56
56
|
### 2. metro.config.js
|
|
57
57
|
|
|
58
|
-
```
|
|
58
|
+
```
|
|
59
59
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
60
60
|
const { withKbach } = require('@kbach/native');
|
|
61
61
|
|
|
@@ -65,7 +65,7 @@ module.exports = withKbach(config);
|
|
|
65
65
|
|
|
66
66
|
### 3. Wrap your app
|
|
67
67
|
|
|
68
|
-
```
|
|
68
|
+
```
|
|
69
69
|
import { ThemeProvider } from '@kbach/native';
|
|
70
70
|
|
|
71
71
|
export default function App() {
|
|
@@ -79,7 +79,7 @@ export default function App() {
|
|
|
79
79
|
|
|
80
80
|
After changing `babel.config.js` or `metro.config.js`, clear the Metro cache:
|
|
81
81
|
|
|
82
|
-
```
|
|
82
|
+
```
|
|
83
83
|
npx expo start --clear
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -89,7 +89,7 @@ npx expo start --clear
|
|
|
89
89
|
|
|
90
90
|
Works on any React Native component — View, Text, TouchableOpacity, TextInput, and third-party components.
|
|
91
91
|
|
|
92
|
-
```
|
|
92
|
+
```
|
|
93
93
|
<View className="flex-1 bg-gray-2 dark:bg-gray-11 p-4" />
|
|
94
94
|
<Text className="text-lg font-bold text-gray-10 dark:text-white" />
|
|
95
95
|
<TouchableOpacity className="bg-blue-7 pressed:bg-blue-8 rounded-xl px-6 py-3" />
|
|
@@ -99,7 +99,7 @@ Works on any React Native component — View, Text, TouchableOpacity, TextInput,
|
|
|
99
99
|
|
|
100
100
|
Pre-style any component. Handles interaction states (pressed, focus, etc.) automatically.
|
|
101
101
|
|
|
102
|
-
```
|
|
102
|
+
```
|
|
103
103
|
import { styled } from '@kbach/native';
|
|
104
104
|
import { View, Text, TouchableOpacity, TextInput } from 'react-native';
|
|
105
105
|
|
|
@@ -117,7 +117,7 @@ const Input = styled(
|
|
|
117
117
|
|
|
118
118
|
Pass extra classes at use time with the `tw` prop:
|
|
119
119
|
|
|
120
|
-
```
|
|
120
|
+
```
|
|
121
121
|
<Card tw="mt-4 mb-2">
|
|
122
122
|
<Title tw="text-3xl">Hello</Title>
|
|
123
123
|
</Card>
|
|
@@ -127,7 +127,7 @@ Pass extra classes at use time with the `tw` prop:
|
|
|
127
127
|
|
|
128
128
|
Resolve classes to a style object inside a component. Use this when you need a value for the `style` prop.
|
|
129
129
|
|
|
130
|
-
```
|
|
130
|
+
```
|
|
131
131
|
import { useStyles } from '@kbach/native';
|
|
132
132
|
import { View, Text } from 'react-native';
|
|
133
133
|
|
|
@@ -145,9 +145,9 @@ function Badge() {
|
|
|
145
145
|
|
|
146
146
|
### tw(classes)
|
|
147
147
|
|
|
148
|
-
Resolve classes outside a component, for use in
|
|
148
|
+
Resolve classes outside a component, for use in StyleSheet.create() or static contexts.
|
|
149
149
|
|
|
150
|
-
```
|
|
150
|
+
```
|
|
151
151
|
import { StyleSheet } from 'react-native';
|
|
152
152
|
import { tw } from '@kbach/native';
|
|
153
153
|
|
|
@@ -161,7 +161,7 @@ const styles = StyleSheet.create({
|
|
|
161
161
|
|
|
162
162
|
Conditionally join class strings. Falsy values are ignored.
|
|
163
163
|
|
|
164
|
-
```
|
|
164
|
+
```
|
|
165
165
|
import { cx } from '@kbach/native';
|
|
166
166
|
|
|
167
167
|
<View className={cx(
|
|
@@ -173,7 +173,7 @@ import { cx } from '@kbach/native';
|
|
|
173
173
|
|
|
174
174
|
### useTheme()
|
|
175
175
|
|
|
176
|
-
```
|
|
176
|
+
```
|
|
177
177
|
import { useTheme } from '@kbach/native';
|
|
178
178
|
|
|
179
179
|
const { mode, resolvedMode, isDark, setMode, toggle } = useTheme();
|
|
@@ -191,7 +191,7 @@ const { mode, resolvedMode, isDark, setMode, toggle } = useTheme();
|
|
|
191
191
|
|
|
192
192
|
Drop-in toggle component that works on both web and native.
|
|
193
193
|
|
|
194
|
-
```
|
|
194
|
+
```
|
|
195
195
|
<ThemeToggle /> // button (default)
|
|
196
196
|
<ThemeToggle variant="switch" /> // toggle switch
|
|
197
197
|
<ThemeToggle variant="icon-button" /> // icon button
|
|
@@ -211,14 +211,14 @@ Up to 3 modifiers can be chained in any order.
|
|
|
211
211
|
| active: | Element active |
|
|
212
212
|
| disabled: | Element disabled |
|
|
213
213
|
|
|
214
|
-
```
|
|
214
|
+
```
|
|
215
215
|
<View className="dark:bg-gray-10" />
|
|
216
216
|
<TouchableOpacity className="dark:pressed:bg-indigo-8" />
|
|
217
217
|
```
|
|
218
218
|
|
|
219
219
|
## Arbitrary values
|
|
220
220
|
|
|
221
|
-
```
|
|
221
|
+
```
|
|
222
222
|
<View className="bg-[#6366f1]" />
|
|
223
223
|
<View className="p-[14px]" />
|
|
224
224
|
<Text className="text-[18px]" />
|
|
@@ -228,14 +228,14 @@ Up to 3 modifiers can be chained in any order.
|
|
|
228
228
|
|
|
229
229
|
## Negative values
|
|
230
230
|
|
|
231
|
-
```
|
|
231
|
+
```
|
|
232
232
|
<View className="-mt-4" /> // marginTop: -16
|
|
233
233
|
<View className="-mx-2" /> // marginHorizontal: -8
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
## Color with opacity
|
|
237
237
|
|
|
238
|
-
```
|
|
238
|
+
```
|
|
239
239
|
<View className="bg-blue-6/50" /> // 50% opacity
|
|
240
240
|
<View className="bg-gray-10/75" /> // 75% opacity
|
|
241
241
|
```
|
|
@@ -267,7 +267,7 @@ Available families: slate, gray, zinc, neutral, stone, red, orange, amber, yello
|
|
|
267
267
|
|
|
268
268
|
## Configuration
|
|
269
269
|
|
|
270
|
-
```
|
|
270
|
+
```
|
|
271
271
|
// kbach.config.js
|
|
272
272
|
module.exports = {
|
|
273
273
|
darkMode: 'attribute', // 'attribute' | 'class' | 'media'
|
|
@@ -298,7 +298,7 @@ module.exports = {
|
|
|
298
298
|
|
|
299
299
|
Apply at runtime:
|
|
300
300
|
|
|
301
|
-
```
|
|
301
|
+
```
|
|
302
302
|
import { updateConfig } from '@kbach/native';
|
|
303
303
|
|
|
304
304
|
updateConfig({ extend: { theme: { colors: { brand: { 6: '#6366f1' } } } } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Single-package Kbach install for React Native and Expo — includes core, components, Babel plugin, and Metro config",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@kbach/core": "0.1.0",
|
|
37
|
-
"@kbach/react": "0.1.
|
|
37
|
+
"@kbach/react": "0.1.4",
|
|
38
38
|
"babel-plugin-kbach": "0.1.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|