@app-studio/web 0.9.56 → 0.9.59
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/dist/components/Background/Background/Background.props.d.ts +15 -8
- package/dist/components/Background/Background/Background.style.d.ts +0 -2
- package/dist/components/Background/Background/Background.view.d.ts +2 -1
- package/dist/components/Background/Background.d.ts +1 -0
- package/dist/components/ChatInput/ChatInput/ChatInput.props.d.ts +17 -0
- package/dist/components/Formik/Formik.Uploader.d.ts +1 -1
- package/dist/components/ProgressBar/ProgressBar/ProgressBar.props.d.ts +36 -2
- package/dist/components/ProgressBar/ProgressBar.d.ts +1 -0
- package/dist/components/Title/Title/Title.props.d.ts +0 -5
- package/dist/web.cjs.development.js +153 -108
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +153 -108
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +157 -111
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/app-studio/Animation.md +241 -0
- package/docs/app-studio/Components.md +192 -0
- package/docs/app-studio/Design.md +121 -0
- package/docs/app-studio/Events.md +296 -0
- package/docs/app-studio/Hooks.md +469 -0
- package/docs/app-studio/Providers.md +186 -0
- package/docs/app-studio/README.md +781 -0
- package/docs/app-studio/Responsive.md +135 -0
- package/docs/app-studio/Theming.md +488 -0
- package/docs/components/Background.mdx +2 -2
- package/docs/components/Center.mdx +2 -2
- package/docs/components/ChatInput.mdx +133 -0
- package/docs/components/Vertical.mdx +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
# App-Studio Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the App-Studio documentation. This guide will help you get started with App-Studio and explore its features.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Installation](#installation)
|
|
8
|
+
2. [Core Concepts](#core-concepts)
|
|
9
|
+
3. [Documentation Guides](#documentation-guides)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js (>= 14.x)
|
|
16
|
+
- React (>= 17.x)
|
|
17
|
+
|
|
18
|
+
### Setup
|
|
19
|
+
|
|
20
|
+
1. Install the package:
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save app-studio
|
|
23
|
+
# or
|
|
24
|
+
yarn add app-studio
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. Set up providers:
|
|
28
|
+
```jsx
|
|
29
|
+
import {
|
|
30
|
+
ThemeProvider,
|
|
31
|
+
ResponsiveProvider,
|
|
32
|
+
AnalyticsProvider,
|
|
33
|
+
WindowSizeProvider
|
|
34
|
+
} from 'app-studio';
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<ThemeProvider>
|
|
39
|
+
<ResponsiveProvider>
|
|
40
|
+
<WindowSizeProvider>
|
|
41
|
+
<AnalyticsProvider>
|
|
42
|
+
{/* Your app content */}
|
|
43
|
+
</AnalyticsProvider>
|
|
44
|
+
</WindowSizeProvider>
|
|
45
|
+
</ResponsiveProvider>
|
|
46
|
+
</ThemeProvider>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Core Concepts
|
|
52
|
+
|
|
53
|
+
### Element Component
|
|
54
|
+
|
|
55
|
+
The `Element` component is the foundation of App-Studio. It provides:
|
|
56
|
+
- Direct styling via props
|
|
57
|
+
- Responsive styles through `media` prop
|
|
58
|
+
- State-based styling via `on` prop
|
|
59
|
+
- Animation support
|
|
60
|
+
|
|
61
|
+
### Component Categories
|
|
62
|
+
|
|
63
|
+
- **Layout:** `View`, `Horizontal`, `Vertical`, `Scroll`, `SafeArea`
|
|
64
|
+
- **Typography:** `Text`, `Heading`
|
|
65
|
+
- **Media:** `Image`, `ImageBackground`
|
|
66
|
+
- **Forms:** `Form`, `Input`, `Button`
|
|
67
|
+
- **Feedback:** `Skeleton`, `Spinner`
|
|
68
|
+
|
|
69
|
+
### Style System
|
|
70
|
+
|
|
71
|
+
App-Studio uses a utility-prop system that:
|
|
72
|
+
- Converts props to CSS
|
|
73
|
+
- Supports responsive values
|
|
74
|
+
- Handles pseudo-states
|
|
75
|
+
- Manages animations
|
|
76
|
+
|
|
77
|
+
## Documentation Guides
|
|
78
|
+
|
|
79
|
+
Explore these guides to learn more about App-Studio:
|
|
80
|
+
|
|
81
|
+
- [Components](Components.md) - Detailed documentation of all available components
|
|
82
|
+
- [Hooks](Hooks.md) - Guide to the React hooks provided by App-Studio
|
|
83
|
+
- [Theming](Theming.md) - How to customize the look and feel of your app
|
|
84
|
+
- [Animation](Animation.md) - Creating animations with App-Studio
|
|
85
|
+
- [Responsive Design](Responsive.md) - Building responsive layouts
|
|
86
|
+
- [Design System](Design.md) - Understanding the design system
|
|
87
|
+
- [Event Handling](Events.md) - Working with events and interactions
|
|
88
|
+
- [Providers](Providers.md) - Context providers for global state
|
|
89
|
+
- [Migration Guide](../codemod/README.md) - Migrating to App-Studio
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# Components
|
|
94
|
+
|
|
95
|
+
App-Studio provides a set of reusable components built on the `Element` base.
|
|
96
|
+
|
|
97
|
+
## Element
|
|
98
|
+
|
|
99
|
+
The fundamental building block. Renders as a specified HTML tag (`as` prop, defaults to `div`) and accepts extensive styling props.
|
|
100
|
+
|
|
101
|
+
**Key Props:**
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Description |
|
|
104
|
+
| :-------- | :------------------------------------- | :--------------------------------------------------------------------------------------------------------- |
|
|
105
|
+
| `as` | `keyof JSX.IntrinsicElements` | HTML element tag to render (default: 'div'). |
|
|
106
|
+
| `style` | `CSSProperties` | Standard React style object. |
|
|
107
|
+
| `css` | `CSSProperties` or `string` | Apply custom CSS styles or raw CSS strings. |
|
|
108
|
+
| `media` | `Record<string, CssProps>` | Defines styles for specific breakpoints or devices (e.g., `mobile`, `tablet`, `lg`). |
|
|
109
|
+
| `on` | `Record<string, CssProps>` | Defines styles for interaction states (e.g., `hover`, `focus`, `active`). Includes `animate` support here. |
|
|
110
|
+
| `animate` | `AnimationProps` or `AnimationProps[]` | Applies one or more animations from the `Animation` system. |
|
|
111
|
+
| `size` | `number` or `string` | Sets equal `width` and `height`. |
|
|
112
|
+
| `shadow` | `boolean` or `number` | Applies a pre-defined box-shadow effect (levels 0-9). |
|
|
113
|
+
| `blend` | `boolean` | Explicitly applies `mix-blend-mode: difference`. **Default:** Active if `color` is undefined. |
|
|
114
|
+
| `...rest` | `CssProps` | Accepts numerous CSS properties directly as props (e.g., `backgroundColor`, `padding`, `fontSize`, etc.). |
|
|
115
|
+
|
|
116
|
+
**Example:**
|
|
117
|
+
|
|
118
|
+
```jsx
|
|
119
|
+
import { Element } from 'app-studio';
|
|
120
|
+
|
|
121
|
+
function MyStyledElement() {
|
|
122
|
+
return (
|
|
123
|
+
<Element
|
|
124
|
+
as="section"
|
|
125
|
+
padding={16}
|
|
126
|
+
backgroundColor="color.blue.500"
|
|
127
|
+
borderRadius={8}
|
|
128
|
+
color="color.white"
|
|
129
|
+
on={{ hover: { backgroundColor: 'color.blue.600' } }}
|
|
130
|
+
media={{ mobile: { padding: 8 } }}
|
|
131
|
+
>
|
|
132
|
+
This is a styled section.
|
|
133
|
+
</Element>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## View
|
|
139
|
+
|
|
140
|
+
A versatile container component extending `Element`, primarily used for layout. Defaults to `div`.
|
|
141
|
+
|
|
142
|
+
**Key Features:**
|
|
143
|
+
|
|
144
|
+
* Inherits all `Element` props.
|
|
145
|
+
* Ideal for structuring UI and applying layout styles (Flexbox, Grid).
|
|
146
|
+
|
|
147
|
+
**Variants:**
|
|
148
|
+
|
|
149
|
+
* `Horizontal`: A `View` with `display: flex`, `flexDirection: row`.
|
|
150
|
+
* `Vertical`: A `View` with `display: flex`, `flexDirection: column`.
|
|
151
|
+
* `HorizontalResponsive`: Switches from `row` to `column` on `mobile`.
|
|
152
|
+
* `VerticalResponsive`: Switches from `column` to `row` on `mobile`.
|
|
153
|
+
* `Scroll`: Basic scrollable view (might need explicit overflow styles).
|
|
154
|
+
* `SafeArea`: A view with `overflow: auto`.
|
|
155
|
+
* `Div`, `Span`: Aliases for `Element` rendering `div` and `span` respectively.
|
|
156
|
+
|
|
157
|
+
**Example:**
|
|
158
|
+
|
|
159
|
+
```jsx
|
|
160
|
+
import { View, Horizontal, Text } from 'app-studio';
|
|
161
|
+
|
|
162
|
+
function MyLayout() {
|
|
163
|
+
return (
|
|
164
|
+
<View padding={16} backgroundColor="color.gray.100">
|
|
165
|
+
<Horizontal gap={8} alignItems="center">
|
|
166
|
+
<View width={50} height={50} backgroundColor="color.red.500" borderRadius="50%" />
|
|
167
|
+
<Text fontSize="lg" fontWeight="bold">Item Title</Text>
|
|
168
|
+
</Horizontal>
|
|
169
|
+
</View>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Text
|
|
175
|
+
|
|
176
|
+
A component for rendering text content, extending `Element`. Defaults to `span`.
|
|
177
|
+
|
|
178
|
+
**Key Features:**
|
|
179
|
+
|
|
180
|
+
* Inherits all `Element` props.
|
|
181
|
+
* Applies typography styles easily (`fontSize`, `fontWeight`, `lineHeight`, `textAlign`, etc.).
|
|
182
|
+
* Supports `toUpperCase` prop.
|
|
183
|
+
|
|
184
|
+
**Key Props (in addition to Element props):**
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Description |
|
|
187
|
+
| :------------ | :-------- | :---------------------------------- |
|
|
188
|
+
| `as` | `string` | HTML element tag (default: 'span'). |
|
|
189
|
+
| `toUpperCase` | `boolean` | Converts text content to uppercase. |
|
|
190
|
+
| `...rest` | `CssProps` | Typography props like `fontSize`, `fontWeight`, `color`, etc. |
|
|
191
|
+
|
|
192
|
+
**Example:**
|
|
193
|
+
|
|
194
|
+
```jsx
|
|
195
|
+
import { Text } from 'app-studio';
|
|
196
|
+
|
|
197
|
+
function MyText() {
|
|
198
|
+
return (
|
|
199
|
+
<Text
|
|
200
|
+
fontSize="xl"
|
|
201
|
+
fontWeight="bold"
|
|
202
|
+
color="theme.primary"
|
|
203
|
+
textAlign="center"
|
|
204
|
+
toUpperCase
|
|
205
|
+
>
|
|
206
|
+
Important Heading
|
|
207
|
+
</Text>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Image
|
|
213
|
+
|
|
214
|
+
An optimized image component extending `Element`. Renders an `<img>` tag.
|
|
215
|
+
|
|
216
|
+
**Key Features:**
|
|
217
|
+
|
|
218
|
+
* Inherits `Element` props relevant to images.
|
|
219
|
+
* Supports standard `src`, `alt` attributes.
|
|
220
|
+
* Potentially supports features like lazy loading or fallbacks (verify implementation specifics if needed).
|
|
221
|
+
|
|
222
|
+
**Key Props (in addition to relevant Element props):**
|
|
223
|
+
|
|
224
|
+
| Prop | Type | Description |
|
|
225
|
+
| :-------- | :------- | :---------------------------------------------- |
|
|
226
|
+
| `src` | `string` | Image source URL. |
|
|
227
|
+
| `alt` | `string` | Alternative text for accessibility. |
|
|
228
|
+
| `...rest` | `CssProps` | Styling props like `width`, `height`, `borderRadius`, `objectFit`. |
|
|
229
|
+
|
|
230
|
+
**Variant:**
|
|
231
|
+
|
|
232
|
+
* `ImageBackground`: Renders an `Element` (`div`) with the image applied as a `backgroundImage` (covers and no-repeat). Takes `src` prop.
|
|
233
|
+
|
|
234
|
+
**Example:**
|
|
235
|
+
|
|
236
|
+
```jsx
|
|
237
|
+
import { Image, ImageBackground, Text } from 'app-studio';
|
|
238
|
+
|
|
239
|
+
function MyImage() {
|
|
240
|
+
return (
|
|
241
|
+
<>
|
|
242
|
+
<Image src="logo.png" alt="Company Logo" width={100} height={50} objectFit="contain" />
|
|
243
|
+
|
|
244
|
+
<ImageBackground src="hero.jpg" height={200} width="100%" display="flex" alignItems="center" justifyContent="center">
|
|
245
|
+
<Text color="color.white" fontSize="2xl">Overlay Text</Text>
|
|
246
|
+
</ImageBackground>
|
|
247
|
+
</>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Form
|
|
253
|
+
|
|
254
|
+
Simplifies form creation and handling. Extends `Element` and renders a `<form>` tag.
|
|
255
|
+
|
|
256
|
+
**Key Features:**
|
|
257
|
+
|
|
258
|
+
* Inherits `Element` props.
|
|
259
|
+
* Handles form submission via `onSubmit`.
|
|
260
|
+
* Includes styled sub-components `Form.Input` and `Form.Button`.
|
|
261
|
+
|
|
262
|
+
**Sub-components:**
|
|
263
|
+
|
|
264
|
+
* `Input`: Extends `Element`, renders an `<input>` tag. Accepts standard input attributes (`name`, `type`, `placeholder`, `value`, `onChange`, etc.) and styling props.
|
|
265
|
+
* `Button`: Extends `Element`, renders a `<button>` tag. Accepts standard button attributes (`type`, `disabled`, etc.) and styling props. Handles `onClick`.
|
|
266
|
+
|
|
267
|
+
**Key Props (Form):**
|
|
268
|
+
|
|
269
|
+
| Prop | Type | Description |
|
|
270
|
+
| :--------- | :--------- | :---------------------------------------- |
|
|
271
|
+
| `onSubmit` | `function` | Callback function executed on submission. |
|
|
272
|
+
| `...rest` | `CssProps` | Styling props for the form container. |
|
|
273
|
+
|
|
274
|
+
**Example:**
|
|
275
|
+
|
|
276
|
+
```jsx
|
|
277
|
+
import { Form, Input, Button } from 'app-studio';
|
|
278
|
+
|
|
279
|
+
function MyForm() {
|
|
280
|
+
const handleSubmit = (event) => {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
const formData = new FormData(event.target);
|
|
283
|
+
const data = Object.fromEntries(formData.entries());
|
|
284
|
+
console.log('Form Data:', data);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<Form onSubmit={handleSubmit} display="flex" flexDirection="column" gap={12}>
|
|
289
|
+
<Input name="username" placeholder="Username" padding={8} borderRadius={4} border="1px solid color.gray.300" />
|
|
290
|
+
<Input name="password" type="password" placeholder="Password" padding={8} borderRadius={4} border="1px solid color.gray.300" />
|
|
291
|
+
<Button type="submit" backgroundColor="color.blue.500" color="color.white" padding={10} borderRadius={4} cursor="pointer">
|
|
292
|
+
Log In
|
|
293
|
+
</Button>
|
|
294
|
+
</Form>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Skeleton
|
|
300
|
+
|
|
301
|
+
Displays a placeholder loading state, often with a shimmer animation. Extends `View`.
|
|
302
|
+
|
|
303
|
+
**Key Props (in addition to View props):**
|
|
304
|
+
|
|
305
|
+
| Prop | Type | Default | Description |
|
|
306
|
+
| :--------------- | :----------------- | :--------- | :------------------------------------------- |
|
|
307
|
+
| `width` | `string \| number` | `100%` | Width of the skeleton placeholder. |
|
|
308
|
+
| `height` | `string \| number` | `20px` | Height of the skeleton placeholder. |
|
|
309
|
+
| `duration` | `string` | `'2s'` | Duration of the shimmer animation. |
|
|
310
|
+
| `timingFunction` | `string` | `'linear'` | Timing function of the shimmer animation. |
|
|
311
|
+
| `iterationCount` | `string \| number` | `infinite` | How many times the shimmer animation repeats. |
|
|
312
|
+
|
|
313
|
+
**Example:**
|
|
314
|
+
|
|
315
|
+
```jsx
|
|
316
|
+
import { Skeleton } from 'app-studio';
|
|
317
|
+
|
|
318
|
+
function UserProfileLoading() {
|
|
319
|
+
return (
|
|
320
|
+
<View display="flex" alignItems="center" gap={12}>
|
|
321
|
+
<Skeleton width={50} height={50} borderRadius="50%" />
|
|
322
|
+
<View flex={1} display="flex" flexDirection="column" gap={8}>
|
|
323
|
+
<Skeleton height={20} width="60%" />
|
|
324
|
+
<Skeleton height={16} width="80%" />
|
|
325
|
+
</View>
|
|
326
|
+
</View>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
# Animation System
|
|
334
|
+
|
|
335
|
+
App-Studio provides a powerful and declarative way to add animations using the `Animation` object and the `animate` prop on `Element`-based components.
|
|
336
|
+
|
|
337
|
+
**Basic Usage**
|
|
338
|
+
|
|
339
|
+
Import the `Animation` object and pass animation configurations to the `animate` prop.
|
|
340
|
+
|
|
341
|
+
```jsx
|
|
342
|
+
import { View, Animation } from 'app-studio';
|
|
343
|
+
|
|
344
|
+
function AnimatedComponent() {
|
|
345
|
+
return (
|
|
346
|
+
<View
|
|
347
|
+
animate={Animation.fadeIn({ duration: '0.5s' })}
|
|
348
|
+
padding={20}
|
|
349
|
+
backgroundColor="color.blue.200"
|
|
350
|
+
>
|
|
351
|
+
Fades In
|
|
352
|
+
</View>
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Event-Based Animations**
|
|
358
|
+
|
|
359
|
+
Trigger animations on interaction states using the `on` prop.
|
|
360
|
+
|
|
361
|
+
```jsx
|
|
362
|
+
import { Button, Animation } from 'app-studio';
|
|
363
|
+
|
|
364
|
+
function HoverButton() {
|
|
365
|
+
return (
|
|
366
|
+
<Button
|
|
367
|
+
padding={10}
|
|
368
|
+
on={{
|
|
369
|
+
hover: {
|
|
370
|
+
animate: Animation.pulse({ duration: '1s', iterationCount: 'infinite' })
|
|
371
|
+
}
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
Hover Over Me
|
|
375
|
+
</Button>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Animation Sequences**
|
|
381
|
+
|
|
382
|
+
Pass an array of animation configurations to the `animate` prop to create sequences. Delays are automatically calculated based on previous animation durations and delays.
|
|
383
|
+
|
|
384
|
+
```jsx
|
|
385
|
+
import { View, Animation } from 'app-studio';
|
|
386
|
+
|
|
387
|
+
function SequencedAnimation() {
|
|
388
|
+
const sequence = [
|
|
389
|
+
Animation.fadeIn({ duration: '1s' }), // Fades in over 1s
|
|
390
|
+
Animation.slideInRight({ duration: '0.5s', delay: '0.2s' }) // Slides in 0.2s after fade-in finishes
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<View
|
|
395
|
+
animate={sequence}
|
|
396
|
+
padding={20}
|
|
397
|
+
backgroundColor="color.green.200"
|
|
398
|
+
>
|
|
399
|
+
Sequence
|
|
400
|
+
</View>
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**Available Animations (`Animation.*`)**
|
|
406
|
+
|
|
407
|
+
A wide range of pre-defined animations are available (check `element/Animation.tsx` for the full list and options):
|
|
408
|
+
|
|
409
|
+
* **Fades:** `fadeIn`, `fadeOut`, `fadeInDown`, `fadeInUp`, etc.
|
|
410
|
+
* **Slides:** `slideInLeft`, `slideInRight`, `slideOutLeft`, `slideOutRight`, etc.
|
|
411
|
+
* **Zooms:** `zoomIn`, `zoomOut`, `zoomInDown`, etc.
|
|
412
|
+
* **Bounces:** `bounce`, `bounceIn`, `bounceOut`.
|
|
413
|
+
* **Rotations:** `rotate`, `flip`, `flipInX`, `flipInY`.
|
|
414
|
+
* **Attention Seekers:** `pulse`, `shake`, `swing`, `tada`, `jello`, `heartBeat`, `headShake`, `wobble`, `flash`.
|
|
415
|
+
* **Special Effects:** `shimmer`, `lightSpeedIn`, `lightSpeedOut`, `hinge`, `jackInTheBox`, `rollIn`, `rollOut`.
|
|
416
|
+
* **Scroll-Driven:** `fadeInScroll`, `slideInLeftScroll`, `scaleDownScroll`, etc. (These often require specific CSS setups like `animation-timeline`).
|
|
417
|
+
|
|
418
|
+
**Animation Properties**
|
|
419
|
+
|
|
420
|
+
Each animation function accepts an options object:
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
interface AnimationProps {
|
|
424
|
+
from?: CSSProperties | any; // Starting styles (for keyframes)
|
|
425
|
+
to?: CSSProperties | any; // Ending styles (for keyframes)
|
|
426
|
+
'0%'?: CSSProperties | any; // Specific keyframe styles
|
|
427
|
+
// ... other percentage keys like '50%'
|
|
428
|
+
duration?: string; // e.g., '1s', '500ms'
|
|
429
|
+
timingFunction?: string; // e.g., 'ease', 'linear', 'ease-in-out', 'steps(N)'
|
|
430
|
+
delay?: string; // e.g., '0.2s', '100ms'
|
|
431
|
+
iterationCount?: string | number; // e.g., '1', 'infinite'
|
|
432
|
+
direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
|
|
433
|
+
fillMode?: 'none' | 'forwards' | 'backwards' | 'both';
|
|
434
|
+
playState?: 'running' | 'paused';
|
|
435
|
+
timeline?: string; // For scroll-driven animations (e.g., 'scroll()', 'view()', '--custom-timeline')
|
|
436
|
+
range?: string; // For scroll-driven animations (e.g., 'cover 0% cover 50%', 'entry', 'exit')
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Responsive Animations**
|
|
441
|
+
|
|
442
|
+
Combine `animate` with the `media` prop for different animations on different screen sizes.
|
|
443
|
+
|
|
444
|
+
```jsx
|
|
445
|
+
import { View, Animation } from 'app-studio';
|
|
446
|
+
|
|
447
|
+
function ResponsiveAnimation() {
|
|
448
|
+
return (
|
|
449
|
+
<View
|
|
450
|
+
padding={20}
|
|
451
|
+
backgroundColor="color.purple.200"
|
|
452
|
+
media={{
|
|
453
|
+
mobile: {
|
|
454
|
+
animate: Animation.fadeIn({ duration: '1s' })
|
|
455
|
+
},
|
|
456
|
+
tablet: {
|
|
457
|
+
animate: Animation.slideInLeft({ duration: '0.8s' })
|
|
458
|
+
}
|
|
459
|
+
}}
|
|
460
|
+
>
|
|
461
|
+
Responsive Animation
|
|
462
|
+
</View>
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
# Hooks
|
|
470
|
+
|
|
471
|
+
App-Studio provides hooks for common UI logic and state management needs.
|
|
472
|
+
|
|
473
|
+
*(Note: Descriptions below are based on the provided code structure. Verify specific usage details.)*
|
|
474
|
+
|
|
475
|
+
| Hook | Returns | Description |
|
|
476
|
+
| :---------------- | :-------------- | :--------------------------------------------------------------------- |
|
|
477
|
+
| `useActive` | `[ref, boolean]` | Detects if the referenced element is active (pressed/touched). |
|
|
478
|
+
| `useClickOutside` | `[ref, boolean]` | Detects if a click occurred outside the referenced element. |
|
|
479
|
+
| `useFocus` | `[ref, boolean]` | Tracks the focus state of the referenced element. |
|
|
480
|
+
| `useHover` | `[ref, boolean]` | Detects if the mouse cursor is hovering over the referenced element. |
|
|
481
|
+
| `useInView` | `{ ref, inView }`| Detects if the referenced element is within the viewport using `IntersectionObserver`. Options allow `triggerOnce`. |
|
|
482
|
+
| `useKeyPress` | `boolean` | Takes a `targetKey` string and returns `true` if that key is currently pressed. |
|
|
483
|
+
| `useMount` | `void` | Takes a callback function and runs it once when the component mounts. |
|
|
484
|
+
| `useOnScreen` | `[ref, boolean]` | Similar to `useInView`, detects if the referenced element is on screen using `IntersectionObserver`. |
|
|
485
|
+
| `useResponsive` | `ScreenConfig & { on: func, is: func }` | Provides screen size (`screen`), device (`currentDevice`), orientation, and helper functions (`on`, `is`) to check against breakpoints/devices. |
|
|
486
|
+
| `useScroll` | `ScrollPosition` | Tracks scroll position (`x`, `y`) and progress (`xProgress`, `yProgress`) of the window or a specified container. Options include `throttleMs`, `container`, `offset`. |
|
|
487
|
+
| `useWindowSize` | `{ width, height }` | Tracks the current width and height of the browser window. |
|
|
488
|
+
|
|
489
|
+
**Examples:**
|
|
490
|
+
|
|
491
|
+
```jsx
|
|
492
|
+
// useHover Example
|
|
493
|
+
import { useHover } from 'app-studio';
|
|
494
|
+
import { View } from './components/View'; // Assuming View component path
|
|
495
|
+
|
|
496
|
+
function HoverComponent() {
|
|
497
|
+
const [hoverRef, isHovered] = useHover();
|
|
498
|
+
return (
|
|
499
|
+
<View ref={hoverRef} padding={20} backgroundColor={isHovered ? 'color.gray.200' : 'color.white'}>
|
|
500
|
+
Hover over me!
|
|
501
|
+
</View>
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// useResponsive Example
|
|
506
|
+
import { useResponsive } from 'app-studio';
|
|
507
|
+
import { View, Text } from './components/Components'; // Assuming component paths
|
|
508
|
+
|
|
509
|
+
function ResponsiveComponent() {
|
|
510
|
+
const { screen, orientation, on } = useResponsive();
|
|
511
|
+
return (
|
|
512
|
+
<View>
|
|
513
|
+
<Text>Current Screen: {screen}, Orientation: {orientation}</Text>
|
|
514
|
+
{on('mobile') && <Text color="color.red.500">This only shows on mobile!</Text>}
|
|
515
|
+
{on('desktop') && <Text color="color.blue.500">This only shows on desktop!</Text>}
|
|
516
|
+
{/* Check specific breakpoint */}
|
|
517
|
+
{on('md') && <Text>Medium screen size detected.</Text>}
|
|
518
|
+
</View>
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// useInView Example
|
|
523
|
+
import { useInView } from 'app-studio';
|
|
524
|
+
import { View, Animation } from './components/Components'; // Assuming component paths
|
|
525
|
+
|
|
526
|
+
function LazyLoadComponent() {
|
|
527
|
+
const { ref, inView } = useInView({ triggerOnce: true, threshold: 0.1 });
|
|
528
|
+
|
|
529
|
+
return (
|
|
530
|
+
<View ref={ref} height={200} backgroundColor="color.gray.100">
|
|
531
|
+
{inView ? (
|
|
532
|
+
<View animate={Animation.fadeIn()}>Content loaded!</View>
|
|
533
|
+
) : (
|
|
534
|
+
'Waiting to scroll into view...'
|
|
535
|
+
)}
|
|
536
|
+
</View>
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
# Providers
|
|
544
|
+
|
|
545
|
+
Providers wrap parts of your application to offer context and global state.
|
|
546
|
+
|
|
547
|
+
## ThemeProvider
|
|
548
|
+
|
|
549
|
+
Manages the application's theme, including color palettes, light/dark modes, and theme tokens.
|
|
550
|
+
|
|
551
|
+
**Props:**
|
|
552
|
+
|
|
553
|
+
| Prop | Type | Default | Description |
|
|
554
|
+
| :------ | :----------------- | :---------------------------------- | :-------------------------------------------------------------------------------- |
|
|
555
|
+
| `theme` | `object` | `{ primary: 'color.black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
|
|
556
|
+
| `mode` | `'light' \| 'dark'`| `'light'` | Sets the initial theme mode. |
|
|
557
|
+
| `dark` | `Colors` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
|
|
558
|
+
| `light` | `Colors` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
|
|
559
|
+
|
|
560
|
+
**Context Values (via `useTheme`)**
|
|
561
|
+
|
|
562
|
+
* `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. 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.
|
|
563
|
+
* `theme`: The merged theme configuration object.
|
|
564
|
+
* `themeMode`: The current mode ('light' or 'dark').
|
|
565
|
+
* `setThemeMode(mode)`: Function to change the theme mode.
|
|
566
|
+
|
|
567
|
+
## ResponsiveProvider
|
|
568
|
+
|
|
569
|
+
Provides context about the current screen size, orientation, and device type based on configured breakpoints.
|
|
570
|
+
|
|
571
|
+
**Props:**
|
|
572
|
+
|
|
573
|
+
| Prop | Type | Default | Description |
|
|
574
|
+
| :------------ | :----------------- | :---------------------------- | :----------------------------------------------------------------------------------- |
|
|
575
|
+
| `breakpoints` | `ResponsiveConfig` | `{ xs: 0, sm: 340, ... }` | An object mapping breakpoint names (e.g., `xs`, `sm`) to minimum width pixel values. |
|
|
576
|
+
| `devices` | `DeviceConfig` | `{ mobile: ['xs', 'sm'], ...}` | An object mapping device names (e.g., `mobile`) to arrays of breakpoint names. |
|
|
577
|
+
|
|
578
|
+
**Context Values (via `useResponsive`)**
|
|
579
|
+
|
|
580
|
+
* `breakpoints`: The configured breakpoints object.
|
|
581
|
+
* `devices`: The configured devices object.
|
|
582
|
+
* `mediaQueries`: Generated media query strings for each breakpoint.
|
|
583
|
+
* `currentWidth`: Current window width.
|
|
584
|
+
* `currentHeight`: Current window height.
|
|
585
|
+
* `currentBreakpoint`: The name of the currently active breakpoint (e.g., 'sm', 'lg').
|
|
586
|
+
* `currentDevice`: The name of the currently inferred device type (e.g., 'mobile', 'desktop').
|
|
587
|
+
* `orientation`: Current screen orientation ('landscape' or 'portrait').
|
|
588
|
+
* `on(name)` / `is(name)`: Function to check if the current screen matches a breakpoint or device name.
|
|
589
|
+
|
|
590
|
+
## AnalyticsProvider
|
|
591
|
+
|
|
592
|
+
Enables event tracking throughout the application. Components like `Element` automatically track `click` events if `onClick` is provided and this provider is used.
|
|
593
|
+
|
|
594
|
+
**Props:**
|
|
595
|
+
|
|
596
|
+
| Prop | Type | Description |
|
|
597
|
+
| :----------- | :--------- | :---------------------------------------------------------------- |
|
|
598
|
+
| `trackEvent` | `function` | A callback function `(event: { type, target?, text?, ... }) => void` that receives event data to be sent to your analytics service. |
|
|
599
|
+
|
|
600
|
+
**Example Usage (Provider Setup):**
|
|
601
|
+
|
|
602
|
+
See the [Installation](#installation) section.
|
|
603
|
+
|
|
604
|
+
## WindowSizeProvider
|
|
605
|
+
|
|
606
|
+
Provides the current dimensions of the browser window via the `useWindowSize` hook.
|
|
607
|
+
|
|
608
|
+
**Props:** None.
|
|
609
|
+
|
|
610
|
+
**Context Values (via `useWindowSize`)**
|
|
611
|
+
|
|
612
|
+
* `width`: Current window width in pixels.
|
|
613
|
+
* `height`: Current window height in pixels.
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
# Utilities
|
|
618
|
+
|
|
619
|
+
App-Studio exports utility objects and functions.
|
|
620
|
+
|
|
621
|
+
## Colors (`utils/colors.ts`)
|
|
622
|
+
|
|
623
|
+
Defines the default color palettes (`defaultLightPalette`, `defaultDarkPalette`) and singleton colors (`defaultLightColors`, `defaultDarkColors`) used by `ThemeProvider`. You can import these if needed for custom theme configurations. Colors are accessed within components primarily via the `getColor` function from `useTheme`.
|
|
624
|
+
|
|
625
|
+
**Accessing Colors:**
|
|
626
|
+
|
|
627
|
+
```jsx
|
|
628
|
+
import { useTheme } from 'app-studio';
|
|
629
|
+
import { View, Text } from './components/Components';
|
|
630
|
+
|
|
631
|
+
function ThemedComponent() {
|
|
632
|
+
const { getColor } = useTheme();
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<View
|
|
636
|
+
backgroundColor={getColor('theme.primary')} // Get theme color
|
|
637
|
+
color={getColor('color.white')} // Get singleton color
|
|
638
|
+
borderRadius={8}
|
|
639
|
+
padding={10}
|
|
640
|
+
>
|
|
641
|
+
<Text>My Themed Content</Text>
|
|
642
|
+
|
|
643
|
+
{/* Direct access to specific theme mode colors */}
|
|
644
|
+
<View
|
|
645
|
+
marginTop={10}
|
|
646
|
+
padding={8}
|
|
647
|
+
backgroundColor={getColor('light.blue.200')} // Always light mode blue
|
|
648
|
+
borderColor={getColor('dark.red.500')} // Always dark mode red
|
|
649
|
+
borderWidth={2}
|
|
650
|
+
borderStyle="solid"
|
|
651
|
+
borderRadius={4}
|
|
652
|
+
>
|
|
653
|
+
<Text>Mixed theme mode colors</Text>
|
|
654
|
+
</View>
|
|
655
|
+
|
|
656
|
+
{/* Direct usage in component props without getColor */}
|
|
657
|
+
<View marginTop={10} padding={8}>
|
|
658
|
+
<Text color="light.white">Always light mode white text</Text>
|
|
659
|
+
<Text color="dark.blue.700" marginTop={4}>Always dark mode blue text</Text>
|
|
660
|
+
</View>
|
|
661
|
+
</View>
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
## Typography (`utils/typography.ts`)
|
|
667
|
+
|
|
668
|
+
Exports the `Typography` object containing pre-defined scales for `letterSpacings`, `lineHeights`, `fontWeights`, and `fontSizes`. These are typically used internally or can be referenced when customizing themes.
|
|
669
|
+
|
|
670
|
+
## Shadows (`utils/shadow.ts`)
|
|
671
|
+
|
|
672
|
+
Exports the `Shadows` object, which maps numbers (0-9) to `box-shadow` configurations used by the `shadow` prop on `Element`.
|
|
673
|
+
|
|
674
|
+
## Constants (`utils/constants.ts`)
|
|
675
|
+
|
|
676
|
+
May export various constants used within the library (e.g., internal configuration keys). Check the file for specifics if needed.
|
|
677
|
+
|
|
678
|
+
---
|
|
679
|
+
|
|
680
|
+
# Examples
|
|
681
|
+
|
|
682
|
+
## Responsive Layout
|
|
683
|
+
|
|
684
|
+
```jsx
|
|
685
|
+
import { View, Text, useResponsive } from 'app-studio';
|
|
686
|
+
|
|
687
|
+
function ResponsiveCard() {
|
|
688
|
+
const { on } = useResponsive();
|
|
689
|
+
|
|
690
|
+
return (
|
|
691
|
+
<View
|
|
692
|
+
flexDirection={on('mobile') ? 'column' : 'row'} // Stack on mobile, row otherwise
|
|
693
|
+
padding={16}
|
|
694
|
+
backgroundColor="color.white"
|
|
695
|
+
borderRadius={8}
|
|
696
|
+
shadow={2} // Apply shadow level 2
|
|
697
|
+
gap={on('mobile') ? 12 : 20}
|
|
698
|
+
>
|
|
699
|
+
<View flex={1}> {/* Use flex for layout control */}
|
|
700
|
+
<Text fontWeight="bold" fontSize="lg">Card Title</Text>
|
|
701
|
+
<Text color="color.gray.600">Some descriptive content here.</Text>
|
|
702
|
+
</View>
|
|
703
|
+
<View width={on('mobile') ? '100%' : 100} height={100} backgroundColor="color.blue.100" borderRadius={4}>
|
|
704
|
+
{/* Image or placeholder */}
|
|
705
|
+
</View>
|
|
706
|
+
</View>
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
## Animated Button
|
|
712
|
+
|
|
713
|
+
```jsx
|
|
714
|
+
import { Button, Animation } from 'app-studio';
|
|
715
|
+
|
|
716
|
+
function AnimatedButton() {
|
|
717
|
+
return (
|
|
718
|
+
<Button
|
|
719
|
+
paddingHorizontal={20}
|
|
720
|
+
paddingVertical={10}
|
|
721
|
+
backgroundColor="color.green.500"
|
|
722
|
+
color="color.white"
|
|
723
|
+
borderRadius={5}
|
|
724
|
+
fontWeight="bold"
|
|
725
|
+
animate={Animation.fadeIn({ duration: '0.5s' })}
|
|
726
|
+
on={{
|
|
727
|
+
hover: {
|
|
728
|
+
backgroundColor: 'color.green.600',
|
|
729
|
+
animate: Animation.pulse({ duration: '0.8s', iterationCount: 2 })
|
|
730
|
+
},
|
|
731
|
+
active: {
|
|
732
|
+
transform: 'scale(0.95)' // Simple transform on active
|
|
733
|
+
}
|
|
734
|
+
}}
|
|
735
|
+
>
|
|
736
|
+
Click Me
|
|
737
|
+
</Button>
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
# API Reference Summary
|
|
745
|
+
|
|
746
|
+
* **Core:** `Element`
|
|
747
|
+
* **Components:** `View`, `Horizontal`, `Vertical`, `HorizontalResponsive`, `VerticalResponsive`, `Scroll`, `SafeArea`, `Div`, `Span`, `Text`, `Image`, `ImageBackground`, `Form`, `Input`, `Button`, `Skeleton`.
|
|
748
|
+
* **Animation:** `Animation` object with functions like `fadeIn`, `slideInLeft`, `pulse`, etc.
|
|
749
|
+
* **Hooks:** `useActive`, `useClickOutside`, `useElementPosition`, `useFocus`, `useHover`, `useInView`, `useKeyPress`, `useMount`, `useOnScreen`, `useResponsive`, `useScroll`, `useWindowSize`.
|
|
750
|
+
* **Providers:** `ThemeProvider`, `ResponsiveProvider`, `AnalyticsProvider`, `WindowSizeProvider`.
|
|
751
|
+
* **Context Hooks:** `useTheme`, `useResponsiveContext`, `useAnalytics`, `useWindowSize`.
|
|
752
|
+
* **Utilities:** `colors`, `Typography`, `Shadows`.
|
|
753
|
+
|
|
754
|
+
---
|
|
755
|
+
|
|
756
|
+
# Contributing
|
|
757
|
+
|
|
758
|
+
Contributions are welcome! Please follow standard procedures:
|
|
759
|
+
|
|
760
|
+
1. Fork the repository.
|
|
761
|
+
2. Create a feature branch (`git checkout -b feature/your-feature-name`).
|
|
762
|
+
3. Make your changes.
|
|
763
|
+
4. Add tests for your changes.
|
|
764
|
+
5. Commit your changes (`git commit -m 'Add some feature'`).
|
|
765
|
+
6. Push to the branch (`git push origin feature/your-feature-name`).
|
|
766
|
+
7. Open a Pull Request.
|
|
767
|
+
|
|
768
|
+
---
|
|
769
|
+
|
|
770
|
+
# Changelog
|
|
771
|
+
|
|
772
|
+
*(Maintain a log of versions and changes here)*
|
|
773
|
+
|
|
774
|
+
* **vX.Y.Z** (Date):
|
|
775
|
+
* Description of changes.
|
|
776
|
+
* **v1.0.0** (Initial Release):
|
|
777
|
+
* Core `Element` component.
|
|
778
|
+
* Basic components: `View`, `Text`, `Image`, `Form`, `Skeleton`.
|
|
779
|
+
* Hooks for interactions, viewport, and responsiveness.
|
|
780
|
+
* Providers for Theme, Responsiveness, Analytics, WindowSize.
|
|
781
|
+
* Animation system via `Animation` object.
|