@flipova/foundation 2.1.1 → 2.2.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/CHANGELOG.md +14 -0
- package/README.md +42 -3
- package/components/ui/gluestack-ui-provider/index.tsx +62 -26
- package/components/ui/gluestack-ui-provider/theme-context.ts +16 -0
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +6 -2
- package/design/documentation.xml +60 -3
- package/design/tools/design.js +6 -1
- package/design/tools/npm.js +104 -3
- package/dist/{chunk-LV4UIEQN.js → chunk-JVHJUIXV.js} +35 -23
- package/dist/chunk-JVHJUIXV.js.map +1 -0
- package/dist/{chunk-WNVU3BM2.mjs → chunk-RPLDFHEZ.mjs} +33 -24
- package/dist/chunk-RPLDFHEZ.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +300 -288
- package/dist/index.mjs +1 -1
- package/dist/ui/index.d.mts +571 -533
- package/dist/ui/index.d.ts +571 -533
- package/dist/ui/index.js +300 -288
- package/dist/ui/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-LV4UIEQN.js.map +0 -1
- package/dist/chunk-WNVU3BM2.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cce3ac0: the provider publishes its theme colours in a context and useGluestackColors reads the mounted theme first, so an app that adopted the registries reads its own branding and not the package palette
|
|
8
|
+
|
|
9
|
+
## 2.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- cce3ac0: flipova-design adopt: an app copies the design registries into design/ (and only the registries), the manifest outputs are rewritten to theme/config.ts and theme/tokens.js, and theme/provider.tsx is created
|
|
14
|
+
createGluestackUIProvider(theme) is exported from @flipova/foundation/ui, so an app mounts a provider built from its own generated theme; GluestackUIProvider remains the package theme
|
|
15
|
+
design.js resolves the Python sources from the package instead of the registry directory, so an adopted copy without tools/ has a working generator
|
|
16
|
+
|
|
3
17
|
## 2.1.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -67,15 +67,54 @@ command only injects the app-level wiring that the package cannot own:
|
|
|
67
67
|
| :--- | :--- |
|
|
68
68
|
| `npx flipova-design where` | print the resolved registries/artifacts paths |
|
|
69
69
|
| `npx flipova-design inject` | re-run the injection only |
|
|
70
|
+
| `npx flipova-design adopt` | copy the registries into the project and own them |
|
|
70
71
|
| `npx flipova-design gen [--check]` | compile the registries into `config.ts` + `tokens.js` |
|
|
71
72
|
| `npx flipova-design lint` | XSD-validate the registries |
|
|
72
73
|
|
|
73
74
|
`gen` writes into the resolved output root, i.e. straight into the installed
|
|
74
75
|
package (`node_modules/@flipova/foundation/components/ui/gluestack-ui-provider`),
|
|
75
76
|
so the artifacts consumed by `@flipova/foundation/tokens` and
|
|
76
|
-
`@flipova/foundation/ui` are always the ones the pipeline produced.
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
`@flipova/foundation/ui` are always the ones the pipeline produced.
|
|
78
|
+
|
|
79
|
+
## Own the design system
|
|
80
|
+
|
|
81
|
+
An app that wants its own branding adopts the registries:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx flipova-design adopt
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
That copies `manifest.xml`, `schema.xsd`, `tokens.xml`, `themes.xml`,
|
|
88
|
+
`documentation.xml` and `canonical.index.txt` into `design/` - and **not** the
|
|
89
|
+
toolchain, which stays in `node_modules`. It rewrites the manifest outputs to
|
|
90
|
+
`theme/config.ts` and `theme/tokens.js`, and creates `theme/provider.tsx`.
|
|
91
|
+
|
|
92
|
+
From then on the project is the source of truth:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# edit design/tokens.xml and design/themes.xml - the colours, the scales, the roles
|
|
96
|
+
npm run design:gen # -> theme/config.ts + theme/tokens.js
|
|
97
|
+
npm run design:verify # the registries are in step with the artifacts
|
|
98
|
+
npm run design:check # determinism + XSD, on YOUR registries
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Wire the two artifacts into the app:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
// tailwind.config.js
|
|
105
|
+
const tokens = require('./theme/tokens');
|
|
106
|
+
module.exports = { presets: [require('nativewind/preset')], theme: { extend: tokens.theme } };
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
// theme/provider.tsx (generated by adopt)
|
|
111
|
+
import { createGluestackUIProvider } from '@flipova/foundation/ui';
|
|
112
|
+
import { config } from './config';
|
|
113
|
+
export const AppThemeProvider = createGluestackUIProvider(config);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The package still provides the components, the generator and every token the app
|
|
117
|
+
does not override. `npx flipova-design where` always says which side is in charge.
|
|
79
118
|
|
|
80
119
|
The generated theme is wired into your Tailwind config (app-level files are not
|
|
81
120
|
shipped by the package):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import { config } from './config';
|
|
2
|
+
import { config, colors } from './config';
|
|
3
3
|
import { View, ViewProps } from 'react-native';
|
|
4
4
|
import { OverlayProvider } from '@gluestack-ui/core/overlay/creator';
|
|
5
5
|
import { ToastProvider } from '@gluestack-ui/core/toast/creator';
|
|
@@ -8,40 +8,76 @@ import {
|
|
|
8
8
|
useGluestackColors as useGluestackColorsHook,
|
|
9
9
|
useCalendarTheme as useCalendarThemeHook,
|
|
10
10
|
} from './useGluestackColors';
|
|
11
|
+
import { ThemeContext } from './theme-context';
|
|
12
|
+
|
|
13
|
+
export { ThemeContext, useMountedColors } from './theme-context';
|
|
11
14
|
|
|
12
15
|
export type ModeType = 'light' | 'dark' | 'system';
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The theme a provider is built from: the same shape `config.ts` generates, so
|
|
19
|
+
* the file an app regenerates from its own registries is accepted as it is.
|
|
20
|
+
*/
|
|
21
|
+
export type GluestackThemeConfig = Record<string, Record<string, string>>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What a provider is built from: the `colors` the generated theme exports, and
|
|
25
|
+
* optionally the matching `vars()` config. Passing the whole module works:
|
|
26
|
+
* `createGluestackUIProvider({ colors, config })`.
|
|
27
|
+
*/
|
|
28
|
+
export interface GluestackTheme {
|
|
29
|
+
colors: GluestackThemeConfig;
|
|
30
|
+
config?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
14
33
|
// Re-export color hooks
|
|
15
34
|
export const useGluestackColors = useGluestackColorsHook;
|
|
16
35
|
export const useCalendarTheme = useCalendarThemeHook;
|
|
17
36
|
export type { GluestackColors } from './useGluestackColors';
|
|
18
37
|
|
|
19
|
-
export
|
|
20
|
-
mode = 'light',
|
|
21
|
-
...props
|
|
22
|
-
}: {
|
|
38
|
+
export interface GluestackUIProviderProps {
|
|
23
39
|
mode?: ModeType;
|
|
24
40
|
children?: React.ReactNode;
|
|
25
41
|
style?: ViewProps['style'];
|
|
26
|
-
}) {
|
|
27
|
-
const { colorScheme, setColorScheme } = useColorScheme();
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
setColorScheme(mode);
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
}, [mode]);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<View
|
|
36
|
-
style={[
|
|
37
|
-
config[colorScheme!],
|
|
38
|
-
{ flex: 1, height: '100%', width: '100%' },
|
|
39
|
-
props.style,
|
|
40
|
-
]}
|
|
41
|
-
>
|
|
42
|
-
<OverlayProvider>
|
|
43
|
-
<ToastProvider>{props.children}</ToastProvider>
|
|
44
|
-
</OverlayProvider>
|
|
45
|
-
</View>
|
|
46
|
-
);
|
|
47
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build a provider around a theme.
|
|
46
|
+
*
|
|
47
|
+
* This is what lets an app own its design system: it copies the registries with
|
|
48
|
+
* `flipova-design adopt`, edits them, regenerates `theme/config.ts`, and mounts
|
|
49
|
+
* the result here. The exported `GluestackUIProvider` is this factory applied to
|
|
50
|
+
* the package's own theme, so nothing changes for an app that did not adopt.
|
|
51
|
+
*/
|
|
52
|
+
export function createGluestackUIProvider(theme: GluestackTheme) {
|
|
53
|
+
const vars = theme.config ?? theme.colors;
|
|
54
|
+
return function ThemedProvider({
|
|
55
|
+
mode = 'light',
|
|
56
|
+
...props
|
|
57
|
+
}: GluestackUIProviderProps) {
|
|
58
|
+
const { colorScheme, setColorScheme } = useColorScheme();
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setColorScheme(mode);
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
}, [mode]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View
|
|
67
|
+
style={[
|
|
68
|
+
(vars as Record<string, unknown>)[colorScheme!] as ViewProps['style'],
|
|
69
|
+
{ flex: 1, height: '100%', width: '100%' },
|
|
70
|
+
props.style,
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
<ThemeContext.Provider value={theme.colors}>
|
|
74
|
+
<OverlayProvider>
|
|
75
|
+
<ToastProvider>{props.children}</ToastProvider>
|
|
76
|
+
</OverlayProvider>
|
|
77
|
+
</ThemeContext.Provider>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const GluestackUIProvider = createGluestackUIProvider({ colors, config });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The colour maps of the theme that is actually mounted.
|
|
5
|
+
*
|
|
6
|
+
* `useGluestackColors` used to close over the config this package generates,
|
|
7
|
+
* so an app that adopted the registries and mounted its own provider still read
|
|
8
|
+
* the package colours - the branding would have been cosmetic. The provider
|
|
9
|
+
* publishes what it was built with here instead, and the hook reads this first.
|
|
10
|
+
*/
|
|
11
|
+
export type ThemeColors = Record<string, Record<string, string>>;
|
|
12
|
+
|
|
13
|
+
export const ThemeContext = createContext<ThemeColors | null>(null);
|
|
14
|
+
|
|
15
|
+
/** The mounted theme, or null when the package's own provider is not in the tree. */
|
|
16
|
+
export const useMountedColors = (): ThemeColors | null => useContext(ThemeContext);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useColorScheme } from 'nativewind';
|
|
2
2
|
import { colors } from './config';
|
|
3
|
+
import { useMountedColors } from './theme-context';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Convert CSS variable name to camelCase
|
|
@@ -40,12 +41,15 @@ function rgbToHex(rgbString: string): string {
|
|
|
40
41
|
*/
|
|
41
42
|
export function useGluestackColors(): Record<string, string> {
|
|
42
43
|
const { colorScheme } = useColorScheme();
|
|
43
|
-
|
|
44
|
+
// The mounted theme wins: an app that adopted the registries and built its own
|
|
45
|
+
// provider must read its own colours, not the ones shipped with the package.
|
|
46
|
+
const theme = useMountedColors() ?? colors;
|
|
47
|
+
const palette = theme[colorScheme || 'light'];
|
|
44
48
|
|
|
45
49
|
// Dynamically convert all CSS variables to camelCase hex colors
|
|
46
50
|
const result: Record<string, string> = {};
|
|
47
51
|
|
|
48
|
-
Object.entries(
|
|
52
|
+
Object.entries(palette).forEach(([key, value]) => {
|
|
49
53
|
const camelKey = toCamelCase(key);
|
|
50
54
|
result[camelKey] = rgbToHex(value as string);
|
|
51
55
|
});
|
package/design/documentation.xml
CHANGED
|
@@ -51,9 +51,66 @@ cannot own:
|
|
|
51
51
|
Use `npx flipova-design where` at any time to print the resolved paths, and
|
|
52
52
|
`npx flipova-design inject` to re-run only the injection.
|
|
53
53
|
|
|
54
|
-
If you deliberately want to
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
If you deliberately want to own the design system - your own branding, your own
|
|
55
|
+
scales and roles - run:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx flipova-design adopt
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
It copies the **registries only** (`manifest.xml`, `schema.xsd`, `tokens.xml`,
|
|
62
|
+
`themes.xml`, `documentation.xml`, `canonical.index.txt`) into `design/`. The
|
|
63
|
+
toolchain stays in `node_modules`: the package keeps generating, validating and
|
|
64
|
+
building, and only the source of truth moves to the app.
|
|
65
|
+
|
|
66
|
+
`adopt` also rewrites the manifest outputs to `theme/config.ts` and
|
|
67
|
+
`theme/tokens.js`, and creates `theme/provider.tsx`.
|
|
68
|
+
|
|
69
|
+
### Wire your own theme into the app
|
|
70
|
+
|
|
71
|
+
Two artifacts, two consumers:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
// tailwind.config.js
|
|
75
|
+
const tokens = require('./theme/tokens');
|
|
76
|
+
|
|
77
|
+
/** @type {import('tailwindcss').Config} */
|
|
78
|
+
module.exports = {
|
|
79
|
+
content: ['./app/**/*.{tsx,ts,jsx,js}'],
|
|
80
|
+
presets: [require('nativewind/preset')],
|
|
81
|
+
important: 'html',
|
|
82
|
+
theme: { extend: tokens.theme },
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
// theme/provider.tsx - created by `adopt`
|
|
88
|
+
import { createGluestackUIProvider } from '@flipova/foundation/ui';
|
|
89
|
+
import { config } from './config';
|
|
90
|
+
|
|
91
|
+
export const AppThemeProvider = createGluestackUIProvider(config);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`createGluestackUIProvider` is the same provider the package exports, built
|
|
95
|
+
around *your* theme. `GluestackUIProvider` is that factory applied to the
|
|
96
|
+
package's own theme, so an app that never adopts anything keeps working
|
|
97
|
+
unchanged.
|
|
98
|
+
|
|
99
|
+
From then on the normal pipeline applies to your branding, on your files:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm run design:gen # design/*.xml -> theme/config.ts + theme/tokens.js
|
|
103
|
+
npm run design:verify # the registries are in step with the artifacts
|
|
104
|
+
npm run design:check # determinism rules + XSD, on YOUR registries
|
|
105
|
+
npm run design:lint
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`npx flipova-design where` always says which side is in charge:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
registries …/my-app/design (adopted by this project)
|
|
112
|
+
artifacts …/my-app/theme (owned by this project)
|
|
113
|
+
```
|
|
57
114
|
|
|
58
115
|
## Wire the theme into your Tailwind config
|
|
59
116
|
|
package/design/tools/design.js
CHANGED
|
@@ -43,7 +43,12 @@ const TOOLS_DIR = __dirname;
|
|
|
43
43
|
const DESIGN_DIR = process.env.FOUNDATION_DESIGN_DIR
|
|
44
44
|
? path.resolve(process.env.FOUNDATION_DESIGN_DIR)
|
|
45
45
|
: path.join(TOOLS_DIR, '..');
|
|
46
|
-
|
|
46
|
+
// The tools always come from the package that runs them. `DESIGN_DIR` is the
|
|
47
|
+
// registry root, and an app that adopts the registries owns them without owning
|
|
48
|
+
// the toolchain: deriving the sources from it meant `sources/` had to be copied
|
|
49
|
+
// too, which is the duplication the CLI exists to avoid - and a copy without
|
|
50
|
+
// `tools/` simply had no generator to run.
|
|
51
|
+
const SOURCES_DIR = path.join(TOOLS_DIR, 'sources');
|
|
47
52
|
const REPO_ROOT = process.env.FOUNDATION_PROJECT_ROOT
|
|
48
53
|
? path.resolve(process.env.FOUNDATION_PROJECT_ROOT)
|
|
49
54
|
: path.join(DESIGN_DIR, '..');
|
package/design/tools/npm.js
CHANGED
|
@@ -185,13 +185,110 @@ function inject(force) {
|
|
|
185
185
|
process.stdout.write(' 3. npx flipova-design lint # verify\n');
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/* ------------------------------------------------------------------ *
|
|
189
|
+
* Adopting the registries (owning the design system)
|
|
190
|
+
* ------------------------------------------------------------------ */
|
|
191
|
+
|
|
192
|
+
// The registries and nothing else: the toolchain stays in the package, which is
|
|
193
|
+
// the whole point of the split. `tools/` is what must never be copied.
|
|
194
|
+
const REGISTRY_FILES = [
|
|
195
|
+
'manifest.xml',
|
|
196
|
+
'schema.xsd',
|
|
197
|
+
'tokens.xml',
|
|
198
|
+
'themes.xml',
|
|
199
|
+
'documentation.xml',
|
|
200
|
+
// The emitted index of the registries: without it `verify` reports the copy as
|
|
201
|
+
// drifting, which is the opposite of what adopting them should feel like.
|
|
202
|
+
'canonical.index.txt',
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
const ADOPTED_OUTPUTS = {
|
|
206
|
+
gluestackConfig: 'theme/config.ts',
|
|
207
|
+
gluestackTokens: 'theme/tokens.js',
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const PROVIDER = `// theme/provider.tsx
|
|
211
|
+
// Generated by \`npx flipova-design adopt\` -- safe to edit.
|
|
212
|
+
//
|
|
213
|
+
// The theme is regenerated from your own registries (design/*.xml) into
|
|
214
|
+
// theme/config.ts and theme/tokens.js. This provider is the wiring between them
|
|
215
|
+
// and the components of @flipova/foundation.
|
|
216
|
+
import { createGluestackUIProvider } from '@flipova/foundation/ui';
|
|
217
|
+
import * as theme from './config';
|
|
218
|
+
|
|
219
|
+
export const AppThemeProvider = createGluestackUIProvider(theme);
|
|
220
|
+
export default AppThemeProvider;
|
|
221
|
+
`;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Copy the registries into the project and point their outputs at the project.
|
|
225
|
+
*
|
|
226
|
+
* An app that adopts them owns its design system: it edits design/tokens.xml and
|
|
227
|
+
* design/themes.xml, runs the pipeline, and gets its own theme/config.ts and
|
|
228
|
+
* theme/tokens.js instead of the package's. The package still provides the
|
|
229
|
+
* components, the generator and every token it does not override.
|
|
230
|
+
*/
|
|
231
|
+
function adopt(force) {
|
|
232
|
+
if (fs.existsSync(PROJECT_DESIGN) && !force) {
|
|
233
|
+
process.stderr.write(`A design directory already exists at ${PROJECT_DESIGN}.\n`);
|
|
234
|
+
process.stderr.write('Nothing was copied. Remove it first, or pass --force to overwrite it.\n');
|
|
235
|
+
process.exit(2);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
fs.mkdirSync(PROJECT_DESIGN, { recursive: true });
|
|
239
|
+
const created = [];
|
|
240
|
+
for (const file of REGISTRY_FILES) {
|
|
241
|
+
const from = path.join(PACKAGE_DESIGN, file);
|
|
242
|
+
if (!fs.existsSync(from)) continue;
|
|
243
|
+
fs.copyFileSync(from, path.join(PROJECT_DESIGN, file));
|
|
244
|
+
created.push(`design/${file}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// The manifest keeps declaring the package's own outputs; a project that owns
|
|
248
|
+
// the registries must write its own artifacts, so the two paths are rewritten
|
|
249
|
+
// here rather than by hand afterwards.
|
|
250
|
+
const manifestPath = path.join(PROJECT_DESIGN, 'manifest.xml');
|
|
251
|
+
const manifest = fs.readFileSync(manifestPath, 'utf8');
|
|
252
|
+
const rewritten = manifest.replace(
|
|
253
|
+
/<(gluestackConfig|gluestackTokens)>[^<]*<\/\1>/g,
|
|
254
|
+
(line, kind) => `<${kind}>${ADOPTED_OUTPUTS[kind]}</${kind}>`,
|
|
255
|
+
);
|
|
256
|
+
if (rewritten !== manifest) {
|
|
257
|
+
fs.writeFileSync(manifestPath, rewritten, 'utf8');
|
|
258
|
+
created.push('design/manifest.xml (outputs -> theme/)');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// The wiring the app-level files need, created only when missing for the same
|
|
262
|
+
// reason `init` never overwrites: these are the app's files.
|
|
263
|
+
fs.mkdirSync(path.join(PROJECT_ROOT, 'theme'), { recursive: true });
|
|
264
|
+
const providerPath = path.join(PROJECT_ROOT, 'theme', 'provider.tsx');
|
|
265
|
+
if (fs.existsSync(providerPath) && !force) created.push('theme/provider.tsx (kept)');
|
|
266
|
+
else {
|
|
267
|
+
fs.writeFileSync(providerPath, PROVIDER, 'utf8');
|
|
268
|
+
created.push('theme/provider.tsx');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
process.stdout.write(`Adopted the design registries into ${PROJECT_DESIGN}\n`);
|
|
272
|
+
for (const what of created) process.stdout.write(` created : ${what}\n`);
|
|
273
|
+
process.stdout.write('\nNext steps:\n');
|
|
274
|
+
process.stdout.write(' 1. edit design/tokens.xml and design/themes.xml - that is now your design system\n');
|
|
275
|
+
process.stdout.write(' 2. npm run design:gen -> theme/config.ts + theme/tokens.js\n');
|
|
276
|
+
process.stdout.write(' 3. tailwind.config.js -> require(\'./theme/tokens\')\n');
|
|
277
|
+
process.stdout.write(' 4. wrap the app in <AppThemeProvider mode="system"> from ./theme/provider\n');
|
|
278
|
+
process.stdout.write(' 5. npm run design:verify -> the registries are in step with the artifacts\n');
|
|
279
|
+
}
|
|
280
|
+
|
|
188
281
|
function printWhere() {
|
|
189
282
|
const { override, designDir, outputRoot } = resolution();
|
|
190
283
|
process.stdout.write(`package ${PACKAGE_ROOT}\n`);
|
|
191
284
|
process.stdout.write(`version ${readPackageVersion()}\n`);
|
|
192
285
|
process.stdout.write(`project ${PROJECT_ROOT}\n`);
|
|
193
|
-
process.stdout.write(`registries ${designDir}${override ? ' (project
|
|
194
|
-
process.stdout.write(
|
|
286
|
+
process.stdout.write(`registries ${designDir}${override ? ' (adopted by this project)' : ' (node_modules)'}\n`);
|
|
287
|
+
process.stdout.write(
|
|
288
|
+
override
|
|
289
|
+
? `artifacts ${path.join(outputRoot, 'theme')} (owned by this project)\n`
|
|
290
|
+
: `artifacts ${path.join(outputRoot, 'components', 'ui', 'gluestack-ui-provider')}\n`,
|
|
291
|
+
);
|
|
195
292
|
process.stdout.write(`tool ${TOOL}\n`);
|
|
196
293
|
process.stdout.write(`python ${process.env.FOUNDATION_PYTHON || '(auto-detect)'}\n`);
|
|
197
294
|
}
|
|
@@ -232,9 +329,13 @@ function main() {
|
|
|
232
329
|
printWhere();
|
|
233
330
|
process.exit(0);
|
|
234
331
|
}
|
|
332
|
+
if (command === 'adopt') {
|
|
333
|
+
adopt(args.includes('--force'));
|
|
334
|
+
process.exit(0);
|
|
335
|
+
}
|
|
235
336
|
if (command === undefined) {
|
|
236
337
|
process.stderr.write(
|
|
237
|
-
'Usage: npx flipova-design <init|inject|where|gen|check|verify|canonical|lint|doc|edit|run|pipeline>\n');
|
|
338
|
+
'Usage: npx flipova-design <init|inject|adopt|where|gen|check|verify|canonical|lint|doc|edit|run|pipeline>\n');
|
|
238
339
|
process.exit(2);
|
|
239
340
|
}
|
|
240
341
|
runTool(command, args);
|
|
@@ -3850,6 +3850,10 @@ var config = {
|
|
|
3850
3850
|
light: nativewind.vars(colors.light),
|
|
3851
3851
|
dark: nativewind.vars(colors.dark)
|
|
3852
3852
|
};
|
|
3853
|
+
var ThemeContext = React48.createContext(null);
|
|
3854
|
+
var useMountedColors = () => React48.useContext(ThemeContext);
|
|
3855
|
+
|
|
3856
|
+
// components/ui/gluestack-ui-provider/useGluestackColors.ts
|
|
3853
3857
|
function toCamelCase(str) {
|
|
3854
3858
|
return str.replace(/^--/, "").replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
3855
3859
|
}
|
|
@@ -3865,9 +3869,10 @@ function rgbToHex(rgbString) {
|
|
|
3865
3869
|
}
|
|
3866
3870
|
function useGluestackColors() {
|
|
3867
3871
|
const { colorScheme } = nativewind.useColorScheme();
|
|
3868
|
-
const theme =
|
|
3872
|
+
const theme = useMountedColors() ?? colors;
|
|
3873
|
+
const palette = theme[colorScheme || "light"];
|
|
3869
3874
|
const result = {};
|
|
3870
|
-
Object.entries(
|
|
3875
|
+
Object.entries(palette).forEach(([key, value]) => {
|
|
3871
3876
|
const camelKey = toCamelCase(key);
|
|
3872
3877
|
result[camelKey] = rgbToHex(value);
|
|
3873
3878
|
});
|
|
@@ -3894,26 +3899,30 @@ function useCalendarTheme() {
|
|
|
3894
3899
|
}
|
|
3895
3900
|
var useGluestackColors2 = useGluestackColors;
|
|
3896
3901
|
var useCalendarTheme2 = useCalendarTheme;
|
|
3897
|
-
function
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
setColorScheme(
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3902
|
+
function createGluestackUIProvider(theme) {
|
|
3903
|
+
const vars2 = theme.config ?? theme.colors;
|
|
3904
|
+
return function ThemedProvider({
|
|
3905
|
+
mode = "light",
|
|
3906
|
+
...props
|
|
3907
|
+
}) {
|
|
3908
|
+
const { colorScheme, setColorScheme } = nativewind.useColorScheme();
|
|
3909
|
+
React48.useEffect(() => {
|
|
3910
|
+
setColorScheme(mode);
|
|
3911
|
+
}, [mode]);
|
|
3912
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3913
|
+
reactNative.View,
|
|
3914
|
+
{
|
|
3915
|
+
style: [
|
|
3916
|
+
vars2[colorScheme],
|
|
3917
|
+
{ flex: 1, height: "100%", width: "100%" },
|
|
3918
|
+
props.style
|
|
3919
|
+
],
|
|
3920
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: theme.colors, children: /* @__PURE__ */ jsxRuntime.jsx(creator$d.OverlayProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(creator$o.ToastProvider, { children: props.children }) }) })
|
|
3921
|
+
}
|
|
3922
|
+
);
|
|
3923
|
+
};
|
|
3916
3924
|
}
|
|
3925
|
+
var GluestackUIProvider = createGluestackUIProvider({ colors, config });
|
|
3917
3926
|
var gridBaseStyle = nativewindUtils.isWeb ? "grid grid-cols-12" : "box-border flex-row flex-wrap justify-start";
|
|
3918
3927
|
var gridItemBaseStyle = nativewindUtils.isWeb ? "w-auto col-span-1" : "";
|
|
3919
3928
|
var gridStyle = nativewindUtils.tva({
|
|
@@ -9703,6 +9712,7 @@ exports.TabsTriggerText = TabsTriggerText;
|
|
|
9703
9712
|
exports.Text = Text21;
|
|
9704
9713
|
exports.Textarea = Textarea;
|
|
9705
9714
|
exports.TextareaInput = TextareaInput;
|
|
9715
|
+
exports.ThemeContext = ThemeContext;
|
|
9706
9716
|
exports.ThreeDotsIcon = ThreeDotsIcon;
|
|
9707
9717
|
exports.Toast = Toast;
|
|
9708
9718
|
exports.ToastDescription = ToastDescription;
|
|
@@ -9722,9 +9732,11 @@ exports.UISlider = UISlider;
|
|
|
9722
9732
|
exports.UITooltip = UITooltip;
|
|
9723
9733
|
exports.UnlockIcon = UnlockIcon;
|
|
9724
9734
|
exports.VStack = VStack;
|
|
9735
|
+
exports.createGluestackUIProvider = createGluestackUIProvider;
|
|
9725
9736
|
exports.createIconUI = createIconUI;
|
|
9726
9737
|
exports.useCalendarTheme = useCalendarTheme2;
|
|
9727
9738
|
exports.useGluestackColors = useGluestackColors2;
|
|
9739
|
+
exports.useMountedColors = useMountedColors;
|
|
9728
9740
|
exports.useToast = useToast;
|
|
9729
|
-
//# sourceMappingURL=chunk-
|
|
9730
|
-
//# sourceMappingURL=chunk-
|
|
9741
|
+
//# sourceMappingURL=chunk-JVHJUIXV.js.map
|
|
9742
|
+
//# sourceMappingURL=chunk-JVHJUIXV.js.map
|