app-studio 0.7.2 → 0.7.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.
- package/README.md +35 -35
- package/dist/app-studio.cjs.development.js +144 -165
- package/dist/app-studio.cjs.development.js.map +1 -1
- package/dist/app-studio.cjs.production.min.js +1 -1
- package/dist/app-studio.esm.js +144 -165
- package/dist/app-studio.esm.js.map +1 -1
- package/dist/app-studio.umd.development.js +144 -165
- package/dist/app-studio.umd.development.js.map +1 -1
- package/dist/app-studio.umd.production.min.js +1 -1
- package/dist/stories/ScrollAnimation.stories.d.ts +1 -1
- package/docs/Animation.md +3 -3
- package/docs/Components.md +8 -8
- package/docs/Design.md +2 -2
- package/docs/Events.md +30 -30
- package/docs/Hooks.md +6 -6
- package/docs/README.md +31 -31
- package/docs/Responsive.md +3 -3
- package/docs/Theming.md +183 -150
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,9 +91,9 @@ App-Studio generates CSS utility classes based on the props you provide to `Elem
|
|
|
91
91
|
|
|
92
92
|
## Theming
|
|
93
93
|
|
|
94
|
-
Use `ThemeProvider` to define global theme settings, including light/dark mode colors and custom theme tokens (e.g., `primary`, `secondary`). The `useTheme` hook provides access to the current theme mode (`themeMode`), theme configuration (`theme`), a function to switch modes (`setThemeMode`), and the essential `getColor` function to resolve color strings (like `color
|
|
94
|
+
Use `ThemeProvider` to define global theme settings, including light/dark mode colors and custom theme tokens (e.g., `primary`, `secondary`). The `useTheme` hook provides access to the current theme mode (`themeMode`), theme configuration (`theme`), a function to switch modes (`setThemeMode`), and the essential `getColor` function to resolve color strings (like `color-blue.500` or `theme.primary`) into actual CSS color values for the current mode.
|
|
95
95
|
|
|
96
|
-
You can also directly access specific theme mode colors using the `light
|
|
96
|
+
You can also directly access specific theme mode colors using the `light-` or `dark-` prefix (e.g., `light-white` or `dark-red.200`), which will always use that specific theme mode's color regardless of the current theme setting.
|
|
97
97
|
|
|
98
98
|
## Responsiveness
|
|
99
99
|
|
|
@@ -140,10 +140,10 @@ function MyStyledElement() {
|
|
|
140
140
|
<Element
|
|
141
141
|
as="section"
|
|
142
142
|
padding={16}
|
|
143
|
-
backgroundColor="color
|
|
143
|
+
backgroundColor="color-blue-500"
|
|
144
144
|
borderRadius={8}
|
|
145
|
-
color="color
|
|
146
|
-
on={{ hover: { backgroundColor: 'color
|
|
145
|
+
color="color-white"
|
|
146
|
+
on={{ hover: { backgroundColor: 'color-blue-600' } }}
|
|
147
147
|
media={{ mobile: { padding: 8 } }}
|
|
148
148
|
>
|
|
149
149
|
This is a styled section.
|
|
@@ -152,7 +152,7 @@ function MyStyledElement() {
|
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
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
|
|
155
|
+
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.
|
|
156
156
|
|
|
157
157
|
**Example (Local Theme Override):**
|
|
158
158
|
|
|
@@ -163,7 +163,7 @@ function LocallyThemedSection() {
|
|
|
163
163
|
// Assume the global theme is currently 'light' mode.
|
|
164
164
|
|
|
165
165
|
// Define a local override theme and colors for this specific section
|
|
166
|
-
const localThemeOverride = { primary: 'color
|
|
166
|
+
const localThemeOverride = { primary: 'color-orange-500', secondary: 'color-teal-300' };
|
|
167
167
|
const localDarkColorsOverride = {
|
|
168
168
|
main: {
|
|
169
169
|
white: '#EEE'
|
|
@@ -179,14 +179,14 @@ function LocallyThemedSection() {
|
|
|
179
179
|
theme={localThemeOverride}
|
|
180
180
|
colors={localDarkColorsOverride}
|
|
181
181
|
// Styles below will resolve using the LOCAL dark theme override defined above:
|
|
182
|
-
backgroundColor="theme.secondary" // Resolves to 'color
|
|
182
|
+
backgroundColor="theme.secondary" // Resolves to 'color-teal-300' via localThemeOverride in dark mode
|
|
183
183
|
borderRadius={8}
|
|
184
184
|
>
|
|
185
|
-
<Text color="color
|
|
186
|
-
colors={localDarkColorsOverride}> {/* 'color
|
|
187
|
-
This section forces dark mode with an orange primary, even if the app is light
|
|
185
|
+
<Text color="color-white"
|
|
186
|
+
colors={localDarkColorsOverride}> {/* 'color-white' from localDarkColorsOverride.main */}
|
|
187
|
+
This section forces dark mode with an orange primary, even if the app is light-
|
|
188
188
|
</Text>
|
|
189
|
-
<Element marginTop={8} padding={10} backgroundColor="color
|
|
189
|
+
<Element marginTop={8} padding={10} backgroundColor="color-gray-700"> {/* Uses local dark palette */}
|
|
190
190
|
<Text color="theme.primary">Nested Primary (Orange)</Text> {/* Still uses local override */}
|
|
191
191
|
</Element>
|
|
192
192
|
</Element>
|
|
@@ -221,9 +221,9 @@ import { View, Horizontal, Text } from 'app-studio';
|
|
|
221
221
|
|
|
222
222
|
function MyLayout() {
|
|
223
223
|
return (
|
|
224
|
-
<View padding={16} backgroundColor="color
|
|
224
|
+
<View padding={16} backgroundColor="color-gray-100">
|
|
225
225
|
<Horizontal gap={8} alignItems="center">
|
|
226
|
-
<View width={50} height={50} backgroundColor="color
|
|
226
|
+
<View width={50} height={50} backgroundColor="color-red-500" borderRadius="50%" />
|
|
227
227
|
<Text fontSize="lg" fontWeight="bold">Item Title</Text>
|
|
228
228
|
</Horizontal>
|
|
229
229
|
</View>
|
|
@@ -302,7 +302,7 @@ function MyImage() {
|
|
|
302
302
|
<Image src="logo.png" alt="Company Logo" width={100} height={50} objectFit="contain" />
|
|
303
303
|
|
|
304
304
|
<ImageBackground src="hero.jpg" height={200} width="100%" display="flex" alignItems="center" justifyContent="center">
|
|
305
|
-
<Text color="color
|
|
305
|
+
<Text color="color-white" fontSize="2xl">Overlay Text</Text>
|
|
306
306
|
</ImageBackground>
|
|
307
307
|
</>
|
|
308
308
|
);
|
|
@@ -346,9 +346,9 @@ function MyForm() {
|
|
|
346
346
|
|
|
347
347
|
return (
|
|
348
348
|
<Form onSubmit={handleSubmit} display="flex" flexDirection="column" gap={12}>
|
|
349
|
-
<Input name="username" placeholder="Username" padding={8} borderRadius={4} border="1px solid color
|
|
350
|
-
<Input name="password" type="password" placeholder="Password" padding={8} borderRadius={4} border="1px solid color
|
|
351
|
-
<Button type="submit" backgroundColor="color
|
|
349
|
+
<Input name="username" placeholder="Username" padding={8} borderRadius={4} border="1px solid color-gray-300" />
|
|
350
|
+
<Input name="password" type="password" placeholder="Password" padding={8} borderRadius={4} border="1px solid color-gray-300" />
|
|
351
|
+
<Button type="submit" backgroundColor="color-blue-500" color="color-white" padding={10} borderRadius={4} cursor="pointer">
|
|
352
352
|
Log In
|
|
353
353
|
</Button>
|
|
354
354
|
</Form>
|
|
@@ -406,7 +406,7 @@ function AnimatedComponent() {
|
|
|
406
406
|
<View
|
|
407
407
|
animate={Animation.fadeIn({ duration: '0.5s' })}
|
|
408
408
|
padding={20}
|
|
409
|
-
backgroundColor="color
|
|
409
|
+
backgroundColor="color-blue-200"
|
|
410
410
|
>
|
|
411
411
|
Fades In
|
|
412
412
|
</View>
|
|
@@ -454,7 +454,7 @@ function SequencedAnimation() {
|
|
|
454
454
|
<View
|
|
455
455
|
animate={sequence}
|
|
456
456
|
padding={20}
|
|
457
|
-
backgroundColor="color
|
|
457
|
+
backgroundColor="color-green-200"
|
|
458
458
|
>
|
|
459
459
|
Sequence
|
|
460
460
|
</View>
|
|
@@ -508,7 +508,7 @@ function ResponsiveAnimation() {
|
|
|
508
508
|
return (
|
|
509
509
|
<View
|
|
510
510
|
padding={20}
|
|
511
|
-
backgroundColor="color
|
|
511
|
+
backgroundColor="color-purple-200"
|
|
512
512
|
media={{
|
|
513
513
|
mobile: {
|
|
514
514
|
animate: Animation.fadeIn({ duration: '1s' })
|
|
@@ -556,7 +556,7 @@ import { View } from './components/View'; // Assuming View component path
|
|
|
556
556
|
function HoverComponent() {
|
|
557
557
|
const [hoverRef, isHovered] = useHover();
|
|
558
558
|
return (
|
|
559
|
-
<View ref={hoverRef} padding={20} backgroundColor={isHovered ? 'color
|
|
559
|
+
<View ref={hoverRef} padding={20} backgroundColor={isHovered ? 'color-gray-200' : 'color-white'}>
|
|
560
560
|
Hover over me!
|
|
561
561
|
</View>
|
|
562
562
|
);
|
|
@@ -571,8 +571,8 @@ function ResponsiveComponent() {
|
|
|
571
571
|
return (
|
|
572
572
|
<View>
|
|
573
573
|
<Text>Current Screen: {screen}, Orientation: {orientation}</Text>
|
|
574
|
-
{on('mobile') && <Text color="color
|
|
575
|
-
{on('desktop') && <Text color="color
|
|
574
|
+
{on('mobile') && <Text color="color-red-500">This only shows on mobile!</Text>}
|
|
575
|
+
{on('desktop') && <Text color="color-blue-500">This only shows on desktop!</Text>}
|
|
576
576
|
{/* Check specific breakpoint */}
|
|
577
577
|
{on('md') && <Text>Medium screen size detected.</Text>}
|
|
578
578
|
</View>
|
|
@@ -587,7 +587,7 @@ function LazyLoadComponent() {
|
|
|
587
587
|
const { ref, inView } = useInView({ triggerOnce: true, threshold: 0.1 });
|
|
588
588
|
|
|
589
589
|
return (
|
|
590
|
-
<View ref={ref} height={200} backgroundColor="color
|
|
590
|
+
<View ref={ref} height={200} backgroundColor="color-gray-100">
|
|
591
591
|
{inView ? (
|
|
592
592
|
<View animate={Animation.fadeIn()}>Content loaded!</View>
|
|
593
593
|
) : (
|
|
@@ -612,14 +612,14 @@ Manages the application's theme, including color palettes, light/dark modes, and
|
|
|
612
612
|
|
|
613
613
|
| Prop | Type | Default | Description |
|
|
614
614
|
| :------ | :----------------- | :---------------------------------- | :-------------------------------------------------------------------------------- |
|
|
615
|
-
| `theme` | `object` | `{ primary: 'color
|
|
615
|
+
| `theme` | `object` | `{ primary: 'color-black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
|
|
616
616
|
| `mode` | `'light' \| 'dark'`| `'light'` | Sets the initial theme mode. |
|
|
617
617
|
| `dark` | `Colors` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
|
|
618
618
|
| `light` | `Colors` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
|
|
619
619
|
|
|
620
620
|
**Context Values (via `useTheme`)**
|
|
621
621
|
|
|
622
|
-
* `getColor(colorName, mode?)`: Resolves a color string (e.g., `color
|
|
622
|
+
* `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.
|
|
623
623
|
* `theme`: The merged theme configuration object.
|
|
624
624
|
* `themeMode`: The current mode ('light' or 'dark').
|
|
625
625
|
* `setThemeMode(mode)`: Function to change the theme mode.
|
|
@@ -694,8 +694,8 @@ function ThemedComponent() {
|
|
|
694
694
|
return (
|
|
695
695
|
<View
|
|
696
696
|
backgroundColor={getColor('theme.primary')} // Get theme color
|
|
697
|
-
color={getColor('color
|
|
698
|
-
borderColor={getColor('color
|
|
697
|
+
color={getColor('color-white')} // Get singleton color
|
|
698
|
+
borderColor={getColor('color-blue-300')} // Get palette color
|
|
699
699
|
padding={10}
|
|
700
700
|
>
|
|
701
701
|
My Themed Content
|
|
@@ -732,16 +732,16 @@ function ResponsiveCard() {
|
|
|
732
732
|
<View
|
|
733
733
|
flexDirection={on('mobile') ? 'column' : 'row'} // Stack on mobile, row otherwise
|
|
734
734
|
padding={16}
|
|
735
|
-
backgroundColor="color
|
|
735
|
+
backgroundColor="color-white"
|
|
736
736
|
borderRadius={8}
|
|
737
737
|
shadow={2} // Apply shadow level 2
|
|
738
738
|
gap={on('mobile') ? 12 : 20}
|
|
739
739
|
>
|
|
740
740
|
<View flex={1}> {/* Use flex for layout control */}
|
|
741
741
|
<Text fontWeight="bold" fontSize="lg">Card Title</Text>
|
|
742
|
-
<Text color="color
|
|
742
|
+
<Text color="color-gray-600">Some descriptive content here.</Text>
|
|
743
743
|
</View>
|
|
744
|
-
<View width={on('mobile') ? '100%' : 100} height={100} backgroundColor="color
|
|
744
|
+
<View width={on('mobile') ? '100%' : 100} height={100} backgroundColor="color-blue-100" borderRadius={4}>
|
|
745
745
|
{/* Image or placeholder */}
|
|
746
746
|
</View>
|
|
747
747
|
</View>
|
|
@@ -759,14 +759,14 @@ function AnimatedButton() {
|
|
|
759
759
|
<Button
|
|
760
760
|
paddingHorizontal={20}
|
|
761
761
|
paddingVertical={10}
|
|
762
|
-
backgroundColor="color
|
|
763
|
-
color="color
|
|
762
|
+
backgroundColor="color-green-500"
|
|
763
|
+
color="color-white"
|
|
764
764
|
borderRadius={5}
|
|
765
765
|
fontWeight="bold"
|
|
766
766
|
animate={Animation.fadeIn({ duration: '0.5s' })}
|
|
767
767
|
on={{
|
|
768
768
|
hover: {
|
|
769
|
-
backgroundColor: 'color
|
|
769
|
+
backgroundColor: 'color-green-600',
|
|
770
770
|
animate: Animation.pulse({ duration: '0.8s', iterationCount: 2 })
|
|
771
771
|
},
|
|
772
772
|
active: {
|