panelui-native 0.22.3 → 0.22.5

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.
Files changed (3) hide show
  1. package/README.md +113 -23
  2. package/package.json +1 -1
  3. package/theme.css +22 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # PanelUI — React Native UI components for Expo, styled with Tailwind CSS
2
2
 
3
3
  **PanelUI** (`panelui-native`) is an accessible, high-performance React Native component
4
- library for Expo apps. 29 typed components — buttons, bottom sheets, dialogs, selects,
4
+ library for Expo apps. 53 typed components — buttons, bottom sheets, dialogs, selects,
5
5
  toasts, forms — styled with Tailwind CSS v4 and animated on the UI thread with Reanimated.
6
6
  Zero native code, so it runs in Expo Go.
7
7
 
@@ -24,15 +24,35 @@ Zero native code, so it runs in Expo Go.
24
24
  state and labels.
25
25
  - 📦 **TypeScript, tree-shakeable, zero native modules** — works in Expo Go, no prebuild needed.
26
26
 
27
- ## Install
27
+ ## Quick start
28
+
29
+ Needs an Expo SDK 57+ app and Node 20+. No Xcode, no Android Studio, no `prebuild` — PanelUI has
30
+ no native modules, so it runs in Expo Go. No app yet? `npx create-expo-app@latest my-app`.
31
+
32
+ Five steps. The full walkthrough, with a fix for every error people hit, is at
33
+ **[panelui.dev/docs/installation](https://panelui.dev/docs/installation)**.
34
+
35
+ ### 1. Install the packages
28
36
 
29
37
  ```sh
30
- npx expo install panelui-native uniwind tailwindcss react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-svg react-native-worklets
38
+ npx expo install panelui-native uniwind tailwindcss @react-native-masked-view/masked-view expo-linear-gradient react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg react-native-worklets
31
39
  ```
32
40
 
33
- ## Quick start
41
+ Install all of them, including the ones you think you don't need. Metro resolves every import in
42
+ the library when it builds your bundle, so leaving one out fails the **first** bundle with
43
+ `Unable to resolve module …` — for a component you may never use. `npx expo install` (rather than
44
+ `npm install`) picks the versions that match your SDK.
45
+
46
+ Optional, each behind a guarded import: `expo-haptics` (the `haptics` prop), `expo-blur` (blurred
47
+ overlay backdrops), `expo-clipboard` (`useCopyToClipboard`), `react-native-keyboard-controller`
48
+ (keyboard avoidance on Android), `expo-file-system` + `react-native-view-shot` (Signature export),
49
+ `@expo/ui` (native platform controls).
34
50
 
35
- **1. Configure Metro**
51
+ ### 2. Add `metro.config.js`
52
+
53
+ **In the root of your project, next to `package.json`** — not in `app/`, not in `src/`. A Metro
54
+ config anywhere else is silently ignored and none of your classes will do anything. A fresh Expo
55
+ app has no such file; `npx expo customize metro.config.js` writes one.
36
56
 
37
57
  ```js
38
58
  // metro.config.js
@@ -42,49 +62,100 @@ const { withUniwindConfig } = require('uniwind/metro');
42
62
  const config = getDefaultConfig(__dirname);
43
63
 
44
64
  module.exports = withUniwindConfig(config, {
65
+ // In an app made by create-expo-app this is './src/global.css' — see step 3.
45
66
  cssEntryFile: './global.css',
46
67
  dtsFile: './uniwind-types.d.ts',
47
- // Only needed if you use the Moon or Grass themes.
68
+ // Only needed to switch to the Moon or Grass themes at runtime.
48
69
  extraThemes: ['moon', 'moon-dark', 'grass', 'grass-dark'],
49
70
  });
50
71
  ```
51
72
 
52
- **2. Create `global.css`**
73
+ `cssEntryFile` and `dtsFile` are relative to this file.
74
+
75
+ ### 3. Add the imports to `global.css`
76
+
77
+ **Look for this file before you create one** — an app made by `create-expo-app` already has
78
+ `src/global.css`. Add these lines at the top of it and leave the rest below. A second CSS file at
79
+ the project root gives you two entries, only one of which is compiled, and nothing gets styled.
53
80
 
54
81
  ```css
82
+ /* src/global.css */
55
83
  @import 'tailwindcss';
56
84
  @import 'uniwind';
57
85
  @import 'panelui-native/theme.css';
58
86
 
59
- @source './node_modules/panelui-native/src';
87
+ @source '../node_modules/panelui-native/src';
60
88
  ```
61
89
 
62
- **3. Wrap your app**
90
+ `@source` is relative to **the CSS file**, and has to land on `node_modules/panelui-native/src` —
91
+ hence the `../` above, from `src/`. From the project root it is `'./node_modules/…'`, from
92
+ `src/styles/` it is `'../../node_modules/…'`. Get it wrong and your own classes work while
93
+ PanelUI's components come out unstyled. Whichever file you used is what `cssEntryFile` must name.
94
+
95
+ ### 4. Import the CSS and add the provider
96
+
97
+ At the top of your app's entry file. The default template uses Expo Router with routes under
98
+ `src/`, so there is usually no `App.tsx` — the entry is `src/app/_layout.tsx`, and it already
99
+ returns a navigation `ThemeProvider` to wrap rather than replace:
63
100
 
64
101
  ```tsx
65
- // App.tsx
66
- import './global.css';
67
- import { PanelUIProvider, Button, Card } from 'panelui-native';
102
+ // src/app/_layout.tsx
103
+ import '../global.css';
104
+
105
+ import { DarkTheme, DefaultTheme, ThemeProvider } from 'expo-router';
106
+ import { useColorScheme } from 'react-native';
107
+ import { PanelUIProvider } from 'panelui-native';
108
+
109
+ import AppTabs from '@/components/app-tabs';
110
+
111
+ export default function RootLayout() {
112
+ const colorScheme = useColorScheme();
68
113
 
69
- export default function App() {
70
114
  return (
71
115
  <PanelUIProvider>
72
- <Card>
73
- <Card.Header>
74
- <Card.Title>Create project</Card.Title>
75
- <Card.Description>Deploy your new project in one click.</Card.Description>
76
- </Card.Header>
77
- <Card.Footer>
78
- <Button>Deploy</Button>
79
- </Card.Footer>
80
- </Card>
116
+ <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
117
+ <AppTabs />
118
+ </ThemeProvider>
81
119
  </PanelUIProvider>
82
120
  );
83
121
  }
84
122
  ```
85
123
 
124
+ That navigation theme paints over PanelUI's background once you switch themes — see
125
+ [Using Expo Router?](#using-expo-router-read-this) below for the version fed from live tokens.
126
+
86
127
  `PanelUIProvider` sets up the gesture root, the themed page background, the portal host used by
87
- overlays, and the toast viewport.
128
+ overlays, and the toast viewport. One at the root is enough — don't nest a second.
129
+
130
+ You do **not** need a `babel.config.js`; Expo's default preset already wires the worklets plugin
131
+ Reanimated needs.
132
+
133
+ ### 5. Restart
134
+
135
+ ```sh
136
+ npx expo start --clear
137
+ ```
138
+
139
+ Metro reads `metro.config.js`, `global.css` and `extraThemes` once, at startup. After changing any
140
+ of them, stop the dev server and start it again — `--clear` on a running one is not enough.
141
+
142
+ ```tsx
143
+ import { Button, Card } from 'panelui-native';
144
+
145
+ <Card>
146
+ <Card.Header>
147
+ <Card.Title>It works</Card.Title>
148
+ <Card.Description>PanelUI is installed and themed.</Card.Description>
149
+ </Card.Header>
150
+ <Card.Footer>
151
+ <Button>Deploy</Button>
152
+ </Card.Footer>
153
+ </Card>;
154
+ ```
155
+
156
+ A themed background, a card with a border and radius, and a button that dips when pressed means
157
+ you are done. Unstyled text on a white screen means the styles are not reaching the bundle — see
158
+ [Troubleshooting](https://panelui.dev/docs/installation#troubleshooting).
88
159
 
89
160
  ## Components
90
161
 
@@ -246,6 +317,25 @@ the named themes, which the OS `Appearance` API knows nothing about. For the sam
246
317
 
247
318
  ## FAQ
248
319
 
320
+ ### The first bundle fails with `Unable to resolve module …`
321
+
322
+ A required package is missing. Run the [install command](#1-install-the-packages) again — all of
323
+ it, not just the package named in the error. Metro resolves every import in the library, so this
324
+ happens even for components you never use.
325
+
326
+ ### `Cannot use @variant with unknown variant: moon` when building
327
+
328
+ Fixed in 0.22.5 — upgrade with `npx expo install panelui-native`. Before that release the Moon and
329
+ Grass token blocks leaned on variants that only existed in the artifact Uniwind generates from your
330
+ Metro config, so the dev server worked while `npx expo export` and EAS builds failed.
331
+
332
+ ### None of my classes do anything
333
+
334
+ In order of likelihood: `metro.config.js` is not in the project root; it does not wrap the config
335
+ in `withUniwindConfig`; `cssEntryFile` does not point at your CSS file; `import './global.css'` is
336
+ missing from the entry file; or the dev server was running when you changed one of those. Full
337
+ list at [Troubleshooting](https://panelui.dev/docs/installation#troubleshooting).
338
+
249
339
  ### How is PanelUI different from NativeWind?
250
340
 
251
341
  NativeWind is a styling engine; PanelUI is a component library. PanelUI is built on **Uniwind**,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panelui-native",
3
- "version": "0.22.3",
3
+ "version": "0.22.5",
4
4
  "description": "High-performance React Native UI components for Expo. Semantic design tokens, powered by Uniwind (Tailwind v4) and Reanimated.",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",
package/theme.css CHANGED
@@ -16,6 +16,28 @@
16
16
  * @source './node_modules/panelui-native/src';
17
17
  */
18
18
 
19
+ /*
20
+ * The named themes declare their own variants, so this file compiles on its
21
+ * own terms.
22
+ *
23
+ * `light` and `dark` exist wherever Uniwind does. The other four are extra
24
+ * themes, and their variants are otherwise only defined in the artifact
25
+ * Uniwind generates from the theme list in a project's Metro config — which
26
+ * that generation step has to compile *this file* to produce. A fresh install
27
+ * therefore had nothing defining `moon` at the moment it was first used: the
28
+ * dev server got away with it because it registers the themes in memory, while
29
+ * a production bundle failed with `Cannot use @variant with unknown variant`.
30
+ *
31
+ * Declared here, the cycle does not exist and neither does the difference
32
+ * between the two. Registering a theme in `extraThemes` is then only about
33
+ * being able to switch to it at runtime, which is what that option reads like
34
+ * it is for.
35
+ */
36
+ @custom-variant moon (&:where(.moon, .moon *));
37
+ @custom-variant moon-dark (&:where(.moon-dark, .moon-dark *));
38
+ @custom-variant grass (&:where(.grass, .grass *));
39
+ @custom-variant grass-dark (&:where(.grass-dark, .grass-dark *));
40
+
19
41
  @theme {
20
42
  --color-background: unset;
21
43
  --color-foreground: unset;