app-studio 0.7.18 → 0.8.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/README.md +87 -33
- package/dist/native/index.cjs +3360 -0
- package/dist/native/index.cjs.map +1 -0
- package/dist/native/index.d.mts +251 -0
- package/dist/native/index.d.ts +251 -0
- package/dist/native/index.js +3268 -0
- package/dist/native/index.js.map +1 -0
- package/dist/viewAnimation-B4BIoOwQ.d.mts +2246 -0
- package/dist/viewAnimation-B4BIoOwQ.d.ts +2246 -0
- package/dist/web/app-studio.umd.production.min.global.js +28 -0
- package/dist/web/app-studio.umd.production.min.global.js.map +1 -0
- package/dist/web/index.cjs +6109 -0
- package/dist/web/index.cjs.map +1 -0
- package/dist/web/index.d.mts +638 -0
- package/dist/web/index.d.ts +638 -0
- package/dist/web/index.js +6008 -0
- package/dist/web/index.js.map +1 -0
- package/docs/Animation.md +2 -0
- package/docs/Components.md +12 -0
- package/docs/Design.md +2 -0
- package/docs/Events.md +2 -0
- package/docs/Hooks.md +2 -0
- package/docs/IframeSupport.md +2 -0
- package/docs/Native.md +428 -0
- package/docs/Providers.md +2 -0
- package/docs/README.md +14 -1
- package/docs/Responsive.md +2 -0
- package/docs/Styling.md +2 -0
- package/docs/Theming.md +53 -0
- package/package.json +76 -14
- package/dist/app-studio.cjs.development.js +0 -6754
- package/dist/app-studio.cjs.development.js.map +0 -1
- package/dist/app-studio.cjs.production.min.js +0 -2
- package/dist/app-studio.cjs.production.min.js.map +0 -1
- package/dist/app-studio.esm.js +0 -6650
- package/dist/app-studio.esm.js.map +0 -1
- package/dist/app-studio.umd.development.js +0 -6757
- package/dist/app-studio.umd.development.js.map +0 -1
- package/dist/app-studio.umd.production.min.js +0 -2
- package/dist/app-studio.umd.production.min.js.map +0 -1
- package/dist/components/Form.d.ts +0 -17
- package/dist/components/Image.d.ts +0 -7
- package/dist/components/Skeleton.d.ts +0 -3
- package/dist/components/Text/Text.props.d.ts +0 -27
- package/dist/components/Text/Text.type.d.ts +0 -3
- package/dist/components/Text/Text.utils.d.ts +0 -2
- package/dist/components/Text/Text.view.d.ts +0 -20
- package/dist/components/Text.d.ts +0 -5
- package/dist/components/View.d.ts +0 -16
- package/dist/components/Wrapper.d.ts +0 -4
- package/dist/element/Animation.d.ts +0 -1164
- package/dist/element/Element.d.ts +0 -4
- package/dist/element/Element.types.d.ts +0 -123
- package/dist/element/css.d.ts +0 -50
- package/dist/element/utils.d.ts +0 -4
- package/dist/hooks/useActive.d.ts +0 -2
- package/dist/hooks/useClickOutside.d.ts +0 -6
- package/dist/hooks/useElementPosition.d.ts +0 -39
- package/dist/hooks/useFocus.d.ts +0 -2
- package/dist/hooks/useHover.d.ts +0 -2
- package/dist/hooks/useIframeStyles.d.ts +0 -41
- package/dist/hooks/useInView.d.ts +0 -11
- package/dist/hooks/useKeyPress.d.ts +0 -1
- package/dist/hooks/useMount.d.ts +0 -1
- package/dist/hooks/useOnScreen.d.ts +0 -6
- package/dist/hooks/useResponsive.d.ts +0 -59
- package/dist/hooks/useScroll.d.ts +0 -49
- package/dist/hooks/useWindowSize.d.ts +0 -4
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -8
- package/dist/providers/Analytics.d.ts +0 -9
- package/dist/providers/Responsive.d.ts +0 -58
- package/dist/providers/StyleRegistry.d.ts +0 -32
- package/dist/providers/Theme.d.ts +0 -46
- package/dist/providers/WindowSize.d.ts +0 -11
- package/dist/stories/AnimateOn.stories.d.ts +0 -30
- package/dist/stories/Animation.stories.d.ts +0 -35
- package/dist/stories/BorderColor.stories.d.ts +0 -4
- package/dist/stories/Color.stories.d.ts +0 -4
- package/dist/stories/ColorAlpha.stories.d.ts +0 -5
- package/dist/stories/Component.stories.d.ts +0 -7
- package/dist/stories/CrossBrowserCompatibility.stories.d.ts +0 -6
- package/dist/stories/CssCascadeOrder.stories.d.ts +0 -10
- package/dist/stories/EmptyBeforeExample.stories.d.ts +0 -7
- package/dist/stories/EventHandlers.stories.d.ts +0 -6
- package/dist/stories/GradientColors.stories.d.ts +0 -6
- package/dist/stories/GroupPeer.stories.d.ts +0 -7
- package/dist/stories/Hooks.stories.d.ts +0 -17
- package/dist/stories/IframeCSSSupport.stories.d.ts +0 -28
- package/dist/stories/IframeSupport.stories.d.ts +0 -20
- package/dist/stories/Image.stories.d.ts +0 -6
- package/dist/stories/Scroll.stories.d.ts +0 -9
- package/dist/stories/ScrollAnimation.stories.d.ts +0 -36
- package/dist/stories/ScrollTimeline.stories.d.ts +0 -6
- package/dist/stories/Skeleton.stories.d.ts +0 -5
- package/dist/stories/Text.stories.d.ts +0 -18
- package/dist/stories/VendorPrefix.stories.d.ts +0 -6
- package/dist/stories/View.stories.d.ts +0 -10
- package/dist/stories/ViewAnimation.stories.d.ts +0 -33
- package/dist/test/CssVariablesTest.d.ts +0 -3
- package/dist/test/LowercaseVendorPrefixTest.d.ts +0 -3
- package/dist/test/VendorPrefixTest.d.ts +0 -3
- package/dist/test/WebkitTextStrokeTest.d.ts +0 -3
- package/dist/types/scrollAnimation.types.d.ts +0 -75
- package/dist/utils/colors.d.ts +0 -21
- package/dist/utils/constants.d.ts +0 -24
- package/dist/utils/cssProperties.d.ts +0 -8
- package/dist/utils/env.d.ts +0 -15
- package/dist/utils/hash.d.ts +0 -4
- package/dist/utils/shadow.d.ts +0 -10
- package/dist/utils/style.d.ts +0 -22
- package/dist/utils/typography.d.ts +0 -45
- package/dist/utils/vendorPrefixes.d.ts +0 -19
- package/dist/utils/viewAnimation.d.ts +0 -138
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ App-Studio is a React library designed to streamline the development of modern w
|
|
|
12
12
|
* **Animation System:** A declarative `Animation` object for easily applying and sequencing CSS animations and transitions, including scroll-driven effects.
|
|
13
13
|
* **Helpful Hooks:** A collection of hooks for managing state, detecting interactions (`useHover`, `useActive`, `useFocus`), tracking viewport status (`useInView`, `useOnScreen`), handling events (`useClickOutside`, `useKeyPress`), and more.
|
|
14
14
|
* **Analytics Integration:** `AnalyticsProvider` to easily integrate event tracking.
|
|
15
|
+
* **React Native Support:** A dedicated native build ships alongside the web build. Metro picks it automatically through the `react-native` export condition — the same import paths and prop API work on iOS, Android, and web, with web-only props (`_hover`, pseudo-elements, CSS animations) accepted as no-ops on native.
|
|
15
16
|
* **TypeScript Support:** Fully typed for a better development experience.
|
|
16
17
|
|
|
17
18
|
---
|
|
@@ -71,6 +72,63 @@ Get started with App-Studio by installing it via npm and setting up the necessar
|
|
|
71
72
|
export default App;
|
|
72
73
|
```
|
|
73
74
|
|
|
75
|
+
### React Native
|
|
76
|
+
|
|
77
|
+
The same package name works in React Native 0.79+ through Metro package exports:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { View, Text, Button, ThemeProvider, ResponsiveProvider } from 'app-studio';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Metro resolves `app-studio` to the native build automatically. The explicit `app-studio/native` and `app-studio/web` subpaths are also available for debugging or tooling. Native supports the cross-platform primitives and providers; web-only styling props such as `_hover`, pseudo-elements, CSS animations, and HTML `as` values are accepted as no-ops in React Native.
|
|
84
|
+
|
|
85
|
+
A typical RN entrypoint looks identical to the web one — same providers, same import paths:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import React from 'react';
|
|
89
|
+
import {
|
|
90
|
+
ThemeProvider,
|
|
91
|
+
ResponsiveProvider,
|
|
92
|
+
WindowSizeProvider,
|
|
93
|
+
View,
|
|
94
|
+
Text,
|
|
95
|
+
Button,
|
|
96
|
+
} from 'app-studio';
|
|
97
|
+
|
|
98
|
+
export default function App() {
|
|
99
|
+
return (
|
|
100
|
+
<ThemeProvider>
|
|
101
|
+
<WindowSizeProvider>
|
|
102
|
+
<ResponsiveProvider>
|
|
103
|
+
<View padding={20} backgroundColor="theme-primary" widthHeight="100%">
|
|
104
|
+
<Text color="color-white" fontSize={20} fontWeight="bold" maxLines={1}>
|
|
105
|
+
Hello, native!
|
|
106
|
+
</Text>
|
|
107
|
+
<Button
|
|
108
|
+
marginTop={16}
|
|
109
|
+
paddingHorizontal={20}
|
|
110
|
+
paddingVertical={12}
|
|
111
|
+
backgroundColor="color-white"
|
|
112
|
+
borderRadius={8}
|
|
113
|
+
shadow={0.3}
|
|
114
|
+
onPress={() => console.log('Pressed')}
|
|
115
|
+
>
|
|
116
|
+
<Text color="theme-primary" fontWeight="bold">Press me</Text>
|
|
117
|
+
</Button>
|
|
118
|
+
</View>
|
|
119
|
+
</ResponsiveProvider>
|
|
120
|
+
</WindowSizeProvider>
|
|
121
|
+
</ThemeProvider>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**What carries over from web:** direct style props, the `media` map, theme/palette color strings (`theme-primary`, `color-blue-500`, `light-white`, `dark-red-200`, alpha shorthand like `theme-primary-300`), the `widthHeight` and `shadow` shorthands, `data-testid` (rewritten to `testID`), `aria-label` (rewritten to `accessibilityLabel`), all four providers, and the `useResponsive` / `useWindowSize` / `useBreakpoint` / `useTheme` hooks.
|
|
127
|
+
|
|
128
|
+
**What's web-only on native (silently dropped):** state modifiers (`_hover`, `_focus`, `_active`, `_disabled`, …), pseudo-elements (`_before`, `_after`, …), the `on={{ hover, focus, ... }}` map, raw-string `css`, the `as` prop, `className`, and the `Animation.*` / `animate` system. Hooks that depend on DOM APIs (`useHover`, `useFocus`, `useClickOutside`, `useScroll`, `useInView`, `useOnScreen`, `useElementPosition`, `useKeyPress`, `useIframeStyles`) are exported as safe stubs so shared component code keeps compiling — but you should branch when meaningful interaction state is needed.
|
|
129
|
+
|
|
130
|
+
For the full component mapping table, native-only props, per-hook breakdown, and a side-by-side web/native cheat sheet, see [docs/Native.md](docs/Native.md).
|
|
131
|
+
|
|
74
132
|
---
|
|
75
133
|
|
|
76
134
|
# Core Concepts
|
|
@@ -271,7 +329,9 @@ function MyStyledElement() {
|
|
|
271
329
|
}
|
|
272
330
|
```
|
|
273
331
|
|
|
274
|
-
In addition to global theming via `ThemeProvider`,
|
|
332
|
+
In addition to global theming via `ThemeProvider`, every component that extends `Element` (`View`, `Text`, `Button`, etc.) accepts a `theme` prop that remaps `theme-*` tokens **for that single component**, without altering the global theme. This is useful for creating distinctly styled sections or one-off branded components (a launch button, a callout card, a status chip) while the rest of the UI keeps the global palette.
|
|
333
|
+
|
|
334
|
+
The `theme` prop takes a `Partial<Theme>` mapping any of the global theme slots (`primary`, `secondary`, `success`, `error`, `warning`, `disabled`, `loading`) to another color token (`'color-red-500'`, `'theme-secondary'`) or a raw color string (`'#ff0000'`). See [docs/Theming.md](docs/Theming.md#component-level-sub-theming) for the full reference, including dark-mode behavior and scope caveats.
|
|
275
335
|
|
|
276
336
|
**Example (Local Theme Override):**
|
|
277
337
|
|
|
@@ -279,35 +339,21 @@ In addition to global theming via `ThemeProvider`, the `Element` component offer
|
|
|
279
339
|
import { Element, Text } from 'app-studio';
|
|
280
340
|
|
|
281
341
|
function LocallyThemedSection() {
|
|
282
|
-
// Assume the global theme is currently 'light' mode.
|
|
283
|
-
|
|
284
|
-
// Define a local override theme and colors for this specific section
|
|
285
|
-
const localThemeOverride = { primary: 'color-orange-500', secondary: 'color-teal-300' };
|
|
286
|
-
const localDarkColorsOverride = {
|
|
287
|
-
main: {
|
|
288
|
-
white: '#EEE'
|
|
289
|
-
}
|
|
290
|
-
}; // Using defaults for demonstration
|
|
291
|
-
|
|
292
342
|
return (
|
|
293
343
|
<Element
|
|
294
344
|
padding={20}
|
|
295
345
|
marginVertical={10}
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
theme
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
346
|
+
// Remap theme-primary / theme-secondary just for this Element:
|
|
347
|
+
theme={{ primary: 'color-orange-500', secondary: 'color-teal-300' }}
|
|
348
|
+
backgroundColor="theme-secondary" // -> color-teal-300
|
|
349
|
+
borderColor="theme-primary" // -> color-orange-500
|
|
350
|
+
borderWidth={2}
|
|
351
|
+
borderStyle="solid"
|
|
302
352
|
borderRadius={8}
|
|
303
353
|
>
|
|
304
|
-
<Text color="color-white"
|
|
305
|
-
|
|
306
|
-
This section forces dark mode with an orange primary, even if the app is light-
|
|
354
|
+
<Text color="color-white">
|
|
355
|
+
This section uses an orange primary, even though the global theme is unchanged.
|
|
307
356
|
</Text>
|
|
308
|
-
<Element marginTop={8} padding={10} backgroundColor="color-gray-700"> {/* Uses local dark palette */}
|
|
309
|
-
<Text color="theme-primary">Nested Primary (Orange)</Text> {/* Still uses local override */}
|
|
310
|
-
</Element>
|
|
311
357
|
</Element>
|
|
312
358
|
);
|
|
313
359
|
}
|
|
@@ -729,18 +775,25 @@ Manages the application's theme, including color palettes, light/dark modes, and
|
|
|
729
775
|
|
|
730
776
|
**Props:**
|
|
731
777
|
|
|
732
|
-
| Prop
|
|
733
|
-
|
|
|
734
|
-
| `theme`
|
|
735
|
-
| `mode`
|
|
736
|
-
| `dark`
|
|
737
|
-
| `light`
|
|
778
|
+
| Prop | Type | Default | Description |
|
|
779
|
+
| :------------- | :------------------ | :---------------------------------- | :-------------------------------------------------------------------------------- |
|
|
780
|
+
| `theme` | `Partial<Theme>` | `{ primary: 'color-black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
|
|
781
|
+
| `mode` | `'light' \| 'dark'` | `'light'` | Sets the initial theme mode. |
|
|
782
|
+
| `dark` | `Partial<Colors>` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
|
|
783
|
+
| `light` | `Partial<Colors>` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
|
|
784
|
+
| `strict` | `boolean` | `false` | When `true`, logs a console warning whenever a color prop is passed a value that isn't a dash-notation token (`color-*`, `theme-*`, `light-*`, `dark-*`). Useful in dev to catch raw hex/CSS colors leaking into the design system. |
|
|
785
|
+
| `targetWindow` | `Window` | `undefined` | When set, the generated `<style>` tag with CSS variables is injected into the given window's document instead of the current one. Used for iframe support — pass the iframe's `contentWindow` so its `data-theme` selectors see the variables. |
|
|
738
786
|
|
|
739
787
|
**Context Values (via `useTheme`)**
|
|
740
788
|
|
|
741
|
-
* `getColor(
|
|
789
|
+
* `getColor(name, override?)`: Resolves a color token (e.g., `color-blue-500`, `theme-primary`, `color-blue-500-200`) to its CSS value. Returns a `var(--…)` reference for palette/theme tokens, a `color-mix(...)` expression for alpha-suffixed tokens, or the raw value for direct colors (`#hex`, `rgb()`). The optional `override` is `{ theme?, colors?, themeMode? }` — pass it to resolve a token against a one-off theme/palette/mode without mutating the global one. Most of the time you don't need to call this directly — App-Studio components resolve color strings passed as props automatically. Use it for non-App-Studio elements or computed styles.
|
|
790
|
+
* `getColorHex(name, override?)`: Resolves a token down to a concrete `#rrggbb[aa]` hex string. Useful when a third-party library demands a literal color (no `var(--…)`).
|
|
791
|
+
* `getColorRGBA(name, alpha?, override?)`: Same idea as `getColorHex`, but returns `rgba(r, g, b, a)`. The optional `alpha` is on the 0–1000 scale (matches the alpha-suffix syntax).
|
|
792
|
+
* `getColorScheme(name, override?)`: Given a token or a hex literal, returns the closest palette name (`'blue'`, `'rose'`, …) or `undefined`. Useful for picking matching icons/illustrations from a color.
|
|
793
|
+
* `getContrastColor(name, override?)`: Returns `'black'` or `'white'` for the most readable foreground on the given background color, using the WCAG luminance formula.
|
|
742
794
|
* `theme`: The merged theme configuration object.
|
|
743
|
-
* `
|
|
795
|
+
* `colors`: The current mode's resolved `{ main, palette }` color objects.
|
|
796
|
+
* `themeMode`: The current mode (`'light'` or `'dark'`).
|
|
744
797
|
* `setThemeMode(mode)`: Function to change the theme mode.
|
|
745
798
|
|
|
746
799
|
## ResponsiveProvider
|
|
@@ -919,13 +972,14 @@ Explore our comprehensive documentation to learn more about App-Studio:
|
|
|
919
972
|
- [Getting Started](docs/README.md) - Quick start guide and core concepts
|
|
920
973
|
- [Components](docs/Components.md) - Detailed documentation of all available components
|
|
921
974
|
- [Hooks](docs/Hooks.md) - Guide to the React hooks provided by App-Studio
|
|
922
|
-
- [Theming](docs/Theming.md) - Color systems, theme
|
|
975
|
+
- [Theming](docs/Theming.md) - Color systems, theme tokens, palettes, light/dark modes, and component-level sub-theming via the `theme` prop
|
|
923
976
|
- [Styling](docs/Styling.md) - Advanced guide to state modifiers, pseudo-elements, media queries, and CSS system
|
|
924
977
|
- [Animation](docs/Animation.md) - Creating animations with App-Studio
|
|
925
978
|
- [Responsive Design](docs/Responsive.md) - Building responsive layouts
|
|
926
979
|
- [Design System](docs/Design.md) - Understanding the design system
|
|
927
980
|
- [Event Handling](docs/Events.md) - Working with events and interactions
|
|
928
981
|
- [Providers](docs/Providers.md) - Context providers for global state
|
|
982
|
+
- [React Native](docs/Native.md) - Using App-Studio in React Native projects: component mapping, native-only props, hook differences, and a web/native cheat sheet
|
|
929
983
|
- [Migration Guide](codemod/README.md) - Migrating to App-Studio
|
|
930
984
|
|
|
931
985
|
---
|
|
@@ -967,4 +1021,4 @@ Contributions are welcome! Please follow standard procedures:
|
|
|
967
1021
|
* Basic components: `View`, `Text`, `Image`, `Form`, `Skeleton`.
|
|
968
1022
|
* Hooks for interactions, viewport, and responsiveness.
|
|
969
1023
|
* Providers for Theme, Responsiveness, Analytics, WindowSize.
|
|
970
|
-
* Animation system via `Animation` object.
|
|
1024
|
+
* Animation system via `Animation` object.
|