app-studio 0.8.0 → 0.8.2

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 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
  ---
@@ -81,6 +82,53 @@ import { View, Text, Button, ThemeProvider, ResponsiveProvider } from 'app-studi
81
82
 
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.
83
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
+
84
132
  ---
85
133
 
86
134
  # Core Concepts
@@ -281,7 +329,9 @@ function MyStyledElement() {
281
329
  }
282
330
  ```
283
331
 
284
- In addition to global theming via `ThemeProvider`, the `Element` component offers granular control through the `themeMode`, `colors`, and `theme` props. When specified, these props locally override the context provided by `ThemeProvider` for this specific element instance and how its style props (like `backgroundColor="theme-primary"` or `color="color-blue-500"`) resolve color values. `themeMode` forces 'light' or 'dark' mode resolution, `colors` provides a custom `{ main, palette }` object, and `theme` supplies custom token mappings (e.g., `{ primary: 'color-purple-500' }`). This allows creating distinctly styled sections or components without altering the global theme, useful for sidebars, specific UI states, or component variations.
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.
285
335
 
286
336
  **Example (Local Theme Override):**
287
337
 
@@ -289,35 +339,21 @@ In addition to global theming via `ThemeProvider`, the `Element` component offer
289
339
  import { Element, Text } from 'app-studio';
290
340
 
291
341
  function LocallyThemedSection() {
292
- // Assume the global theme is currently 'light' mode.
293
-
294
- // Define a local override theme and colors for this specific section
295
- const localThemeOverride = { primary: 'color-orange-500', secondary: 'color-teal-300' };
296
- const localDarkColorsOverride = {
297
- main: {
298
- white: '#EEE'
299
- }
300
- }; // Using defaults for demonstration
301
-
302
342
  return (
303
343
  <Element
304
344
  padding={20}
305
345
  marginVertical={10}
306
- // Force dark mode and provide specific theme/color definitions JUST for this Element
307
- themeMode="dark"
308
- theme={localThemeOverride}
309
- colors={localDarkColorsOverride}
310
- // Styles below will resolve using the LOCAL dark theme override defined above:
311
- backgroundColor="theme-secondary" // Resolves to 'color-teal-300' via localThemeOverride in dark mode
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"
312
352
  borderRadius={8}
313
353
  >
314
- <Text color="color-white"
315
- colors={localDarkColorsOverride}> {/* 'color-white' from localDarkColorsOverride.main */}
316
- 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.
317
356
  </Text>
318
- <Element marginTop={8} padding={10} backgroundColor="color-gray-700"> {/* Uses local dark palette */}
319
- <Text color="theme-primary">Nested Primary (Orange)</Text> {/* Still uses local override */}
320
- </Element>
321
357
  </Element>
322
358
  );
323
359
  }
@@ -739,18 +775,25 @@ Manages the application's theme, including color palettes, light/dark modes, and
739
775
 
740
776
  **Props:**
741
777
 
742
- | Prop | Type | Default | Description |
743
- | :------ | :----------------- | :---------------------------------- | :-------------------------------------------------------------------------------- |
744
- | `theme` | `object` | `{ primary: 'color-black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
745
- | `mode` | `'light' \| 'dark'`| `'light'` | Sets the initial theme mode. |
746
- | `dark` | `Colors` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
747
- | `light` | `Colors` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
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. |
748
786
 
749
787
  **Context Values (via `useTheme`)**
750
788
 
751
- * `getColor(colorName, mode?)`: Resolves a color string (e.g., `color-blue-500`, `theme-primary`, `blackAlpha-500`) to its CSS value for the specified or current theme mode. Most of the time you don't need this — App-Studio components resolve color strings passed as props automatically. Use `getColor` only when you need the raw CSS value (e.g., for non-App-Studio elements or computed styles).
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.
752
794
  * `theme`: The merged theme configuration object.
753
- * `themeMode`: The current mode ('light' or 'dark').
795
+ * `colors`: The current mode's resolved `{ main, palette }` color objects.
796
+ * `themeMode`: The current mode (`'light'` or `'dark'`).
754
797
  * `setThemeMode(mode)`: Function to change the theme mode.
755
798
 
756
799
  ## ResponsiveProvider
@@ -929,13 +972,14 @@ Explore our comprehensive documentation to learn more about App-Studio:
929
972
  - [Getting Started](docs/README.md) - Quick start guide and core concepts
930
973
  - [Components](docs/Components.md) - Detailed documentation of all available components
931
974
  - [Hooks](docs/Hooks.md) - Guide to the React hooks provided by App-Studio
932
- - [Theming](docs/Theming.md) - Color systems, theme colors, palettes, and light/dark modes
975
+ - [Theming](docs/Theming.md) - Color systems, theme tokens, palettes, light/dark modes, and component-level sub-theming via the `theme` prop
933
976
  - [Styling](docs/Styling.md) - Advanced guide to state modifiers, pseudo-elements, media queries, and CSS system
934
977
  - [Animation](docs/Animation.md) - Creating animations with App-Studio
935
978
  - [Responsive Design](docs/Responsive.md) - Building responsive layouts
936
979
  - [Design System](docs/Design.md) - Understanding the design system
937
980
  - [Event Handling](docs/Events.md) - Working with events and interactions
938
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
939
983
  - [Migration Guide](codemod/README.md) - Migrating to App-Studio
940
984
 
941
985
  ---