app-studio 0.5.71 → 0.5.72
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 +562 -335
- package/dist/app-studio.cjs.development.js +72 -136
- 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 +74 -137
- package/dist/app-studio.esm.js.map +1 -1
- package/dist/app-studio.umd.development.js +72 -136
- package/dist/app-studio.umd.development.js.map +1 -1
- package/dist/app-studio.umd.production.min.js +1 -1
- package/dist/components/Form.d.ts +3 -3
- package/dist/components/Image.d.ts +2 -2
- package/dist/components/Text.d.ts +1 -1
- package/dist/components/View.d.ts +9 -9
- package/dist/components/Wrapper.d.ts +1 -1
- package/dist/element/Element.d.ts +2 -1
- package/dist/hooks/useResponsive.d.ts +8 -5
- package/dist/hooks/useWindowSize.d.ts +1 -1
- package/dist/providers/Responsive.d.ts +2 -2
- package/dist/providers/WindowSize.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,487 +1,714 @@
|
|
|
1
|
-
# App-Studio
|
|
2
|
-
|
|
3
|
-
App-Studio is a
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- [Design Props](#8-design-props)
|
|
29
|
-
- [Shadow Prop](#shadow-prop)
|
|
30
|
-
- [Animation](#9-animation)
|
|
31
|
-
- [Basic Usage](#basic-usage)
|
|
32
|
-
- [Available Animations](#available-animations)
|
|
33
|
-
- [Animation Properties](#animation-properties)
|
|
34
|
-
- [Advanced Usage](#10-advanced-usage)
|
|
35
|
-
- [Contributing](#11-contributing)
|
|
36
|
-
- [License](#12-license)
|
|
37
|
-
|
|
38
|
-
## 2. Installation
|
|
39
|
-
|
|
40
|
-
To install App-Studio, run the following command:
|
|
1
|
+
# App-Studio
|
|
2
|
+
|
|
3
|
+
App-Studio is a React library that simplifies the creation of modern web applications by providing reusable components, hooks, and utilities. It offers built-in support for theming, responsive design, and analytics, making it an ideal choice for developers aiming to build high-quality, efficient, and scalable projects. Key features include:
|
|
4
|
+
|
|
5
|
+
- A robust set of UI components for layouts, forms, and more.
|
|
6
|
+
- Hooks for managing state, events, and responsiveness.
|
|
7
|
+
- Providers for theming, responsiveness, and analytics.
|
|
8
|
+
- Utilities for styling, colors, and typography.
|
|
9
|
+
|
|
10
|
+
Whether you're building a small prototype or a large-scale application, App-Studio empowers you to work faster and smarter.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Installation
|
|
15
|
+
|
|
16
|
+
To get started with App-Studio, install it via npm and set up the necessary providers in your application.
|
|
17
|
+
|
|
18
|
+
Prerequisites
|
|
19
|
+
|
|
20
|
+
- Node.js (>= 14.x)
|
|
21
|
+
- React (>= 17.x)
|
|
22
|
+
|
|
23
|
+
# Installation Steps
|
|
24
|
+
|
|
25
|
+
Run the following command to install App-Studio:
|
|
26
|
+
|
|
27
|
+
bash
|
|
41
28
|
|
|
42
29
|
```bash
|
|
43
|
-
npm install app-studio
|
|
30
|
+
npm install --save app-studio
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
After installation, wrap your application with the core providers to enable theming, responsiveness, and analytics:
|
|
34
|
+
|
|
35
|
+
jsx
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import { ThemeProvider, ResponsiveProvider, AnalyticsProvider } from 'app-studio';
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return (
|
|
42
|
+
<ThemeProvider>
|
|
43
|
+
<ResponsiveProvider>
|
|
44
|
+
<AnalyticsProvider>
|
|
45
|
+
{/* Your application components */}
|
|
46
|
+
</AnalyticsProvider>
|
|
47
|
+
</ResponsiveProvider>
|
|
48
|
+
</ThemeProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default App;
|
|
44
53
|
```
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# Components
|
|
58
|
+
|
|
59
|
+
App-Studio provides a set of reusable components to handle common UI tasks. Below is detailed documentation for each component.
|
|
60
|
+
|
|
61
|
+
## View
|
|
47
62
|
|
|
48
|
-
|
|
63
|
+
The View component is a versatile container for creating layouts, supporting a wide range of styling options.
|
|
49
64
|
|
|
50
|
-
|
|
65
|
+
Props
|
|
51
66
|
|
|
52
|
-
|
|
67
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| as | string | 'div' | The HTML element to render as. |
|
|
70
|
+
| children | React.ReactNode | - | Content inside the view. |
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
- Defines styles for different CSS events with the `on` prop.
|
|
56
|
-
- Defines responsive styles for different media queries with the `media` prop.
|
|
57
|
-
- Applies shadow effects with the `shadow` prop.
|
|
72
|
+
Example
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
jsx
|
|
60
75
|
|
|
61
76
|
```jsx
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
import { View } from 'app-studio';
|
|
78
|
+
|
|
79
|
+
function MyComponent() {
|
|
80
|
+
return (
|
|
81
|
+
<View
|
|
82
|
+
backgroundColor="color.blue.500"
|
|
83
|
+
padding={16}
|
|
84
|
+
borderRadius={8}
|
|
85
|
+
onClick={() => console.log('Clicked!')}
|
|
86
|
+
>
|
|
87
|
+
Hello, World!
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
65
91
|
```
|
|
66
92
|
|
|
67
|
-
|
|
93
|
+
Best Practices
|
|
68
94
|
|
|
69
|
-
|
|
95
|
+
- Use as to render semantic HTML elements (e.g., section, article).
|
|
96
|
+
- Leverage theme colors for consistent styling.
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
## Image
|
|
72
99
|
|
|
73
|
-
|
|
74
|
-
- Supports all `Element` props.
|
|
100
|
+
The Image component optimizes image loading and rendering.
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
Props
|
|
103
|
+
|
|
104
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
105
|
+
| --- | --- | --- | --- |
|
|
106
|
+
| src | string | - | Image URL. |
|
|
107
|
+
| alt | string | - | Alternative text for the image. |
|
|
108
|
+
| lazy | boolean | true | Enables lazy loading. |
|
|
109
|
+
|
|
110
|
+
Example
|
|
111
|
+
|
|
112
|
+
jsx
|
|
77
113
|
|
|
78
114
|
```jsx
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
115
|
+
import { Image } from 'app-studio';
|
|
116
|
+
|
|
117
|
+
function MyComponent() {
|
|
118
|
+
return <Image src="example.jpg" alt="Example" lazy />;
|
|
119
|
+
}
|
|
82
120
|
```
|
|
83
121
|
|
|
84
|
-
|
|
122
|
+
## Text
|
|
123
|
+
|
|
124
|
+
The Text component provides styled text with typography support.
|
|
85
125
|
|
|
86
|
-
|
|
126
|
+
Props
|
|
87
127
|
|
|
88
|
-
|
|
128
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
129
|
+
| --- | --- | --- | --- |
|
|
130
|
+
| as | string | 'p' | HTML element to render as. |
|
|
131
|
+
| size | string | 'md' | Font size (e.g., 'sm', 'lg'). |
|
|
132
|
+
| weight | string | 'normal' | Font weight (e.g., 'bold'). |
|
|
89
133
|
|
|
90
|
-
|
|
91
|
-
- Supports all `Element` props.
|
|
134
|
+
Example
|
|
92
135
|
|
|
93
|
-
|
|
136
|
+
jsx
|
|
94
137
|
|
|
95
138
|
```jsx
|
|
96
|
-
|
|
139
|
+
import { Text } from 'app-studio';
|
|
140
|
+
|
|
141
|
+
function MyComponent() {
|
|
142
|
+
return <Text size="lg" weight="bold">Bold Large Text</Text>;
|
|
143
|
+
}
|
|
97
144
|
```
|
|
98
145
|
|
|
99
|
-
|
|
146
|
+
## Form
|
|
147
|
+
|
|
148
|
+
The Form component simplifies form creation and validation.
|
|
100
149
|
|
|
101
|
-
|
|
150
|
+
Props
|
|
102
151
|
|
|
103
|
-
|
|
152
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| onSubmit | function | - | Callback on form submission. |
|
|
155
|
+
| children | React.ReactNode | - | Form fields and elements. |
|
|
104
156
|
|
|
105
|
-
|
|
106
|
-
- Supports all `Element` props.
|
|
157
|
+
Example
|
|
107
158
|
|
|
108
|
-
|
|
159
|
+
jsx
|
|
109
160
|
|
|
110
161
|
```jsx
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
162
|
+
import { Form } from 'app-studio';
|
|
163
|
+
|
|
164
|
+
function MyComponent() {
|
|
165
|
+
return (
|
|
166
|
+
<Form onSubmit={(data) => console.log(data)}>
|
|
167
|
+
<input name="username" />
|
|
168
|
+
<button type="submit">Submit</button>
|
|
169
|
+
</Form>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
115
172
|
```
|
|
116
173
|
|
|
117
|
-
|
|
174
|
+
## Skeleton
|
|
175
|
+
|
|
176
|
+
The Skeleton component displays a placeholder while content loads.
|
|
118
177
|
|
|
119
|
-
|
|
178
|
+
Props
|
|
120
179
|
|
|
121
|
-
|
|
180
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
181
|
+
| --- | --- | --- | --- |
|
|
182
|
+
| width | string | '100%' | Width of the skeleton. |
|
|
183
|
+
| height | string | '20px' | Height of the skeleton. |
|
|
122
184
|
|
|
123
|
-
|
|
124
|
-
- Applies shadow effects with `shadow`.
|
|
125
|
-
- Handles events with `on`.
|
|
185
|
+
Example
|
|
126
186
|
|
|
127
|
-
|
|
187
|
+
jsx
|
|
128
188
|
|
|
129
189
|
```jsx
|
|
130
|
-
|
|
190
|
+
import { Skeleton } from 'app-studio';
|
|
191
|
+
|
|
192
|
+
function MyComponent() {
|
|
193
|
+
return <Skeleton width="200px" height="30px" />;
|
|
194
|
+
}
|
|
131
195
|
```
|
|
132
196
|
|
|
133
|
-
|
|
197
|
+
# Hooks
|
|
198
|
+
|
|
199
|
+
App-Studio includes a variety of hooks to manage state, events, and responsiveness.
|
|
200
|
+
|
|
201
|
+
## useActive
|
|
134
202
|
|
|
135
|
-
|
|
203
|
+
Detects if an element is active (e.g., pressed).
|
|
136
204
|
|
|
137
|
-
|
|
205
|
+
Parameters
|
|
138
206
|
|
|
139
|
-
|
|
207
|
+
None.
|
|
140
208
|
|
|
141
|
-
|
|
209
|
+
Return Values
|
|
210
|
+
|
|
211
|
+
| **Value** | **Type** | **Description** |
|
|
212
|
+
| --- | --- | --- |
|
|
213
|
+
| active | boolean | Whether the element is active. |
|
|
214
|
+
|
|
215
|
+
Example
|
|
216
|
+
|
|
217
|
+
jsx
|
|
142
218
|
|
|
143
219
|
```jsx
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/>
|
|
220
|
+
import { useActive } from 'app-studio';
|
|
221
|
+
|
|
222
|
+
function MyComponent() {
|
|
223
|
+
const { active } = useActive();
|
|
224
|
+
return <button style={{ opacity: active ? 0.7 : 1 }}>Click me</button>;
|
|
225
|
+
}
|
|
151
226
|
```
|
|
152
227
|
|
|
153
|
-
|
|
228
|
+
## useClickOutside
|
|
229
|
+
|
|
230
|
+
Triggers a callback when clicking outside an element.
|
|
154
231
|
|
|
155
|
-
|
|
232
|
+
Parameters
|
|
156
233
|
|
|
157
|
-
|
|
234
|
+
| **Param** | **Type** | **Description** |
|
|
235
|
+
| --- | --- | --- |
|
|
236
|
+
| callback | function | Called when clicking outside. |
|
|
237
|
+
|
|
238
|
+
Example
|
|
239
|
+
|
|
240
|
+
jsx
|
|
158
241
|
|
|
159
242
|
```jsx
|
|
160
|
-
|
|
243
|
+
import { useClickOutside } from 'app-studio';
|
|
244
|
+
import { useRef } from 'react';
|
|
161
245
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
</
|
|
166
|
-
|
|
246
|
+
function MyComponent() {
|
|
247
|
+
const ref = useRef();
|
|
248
|
+
useClickOutside(() => console.log('Clicked outside'), ref);
|
|
249
|
+
return <div ref={ref}>Click outside me</div>;
|
|
250
|
+
}
|
|
167
251
|
```
|
|
168
252
|
|
|
169
|
-
|
|
253
|
+
## useFocus
|
|
254
|
+
|
|
255
|
+
Tracks focus state of an element.
|
|
256
|
+
|
|
257
|
+
Return Values
|
|
258
|
+
|
|
259
|
+
| **Value** | **Type** | **Description** |
|
|
260
|
+
| --- | --- | --- |
|
|
261
|
+
| focused | boolean | Whether the element is focused. |
|
|
262
|
+
|
|
263
|
+
Example
|
|
264
|
+
|
|
265
|
+
jsx
|
|
170
266
|
|
|
171
267
|
```jsx
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
xl: 1300,
|
|
179
|
-
}}
|
|
180
|
-
devices={{
|
|
181
|
-
mobile: ['xs', 'sm'],
|
|
182
|
-
tablet: ['md', 'lg'],
|
|
183
|
-
desktop: ['lg', 'xl']
|
|
184
|
-
}}
|
|
185
|
-
>
|
|
186
|
-
<App />
|
|
187
|
-
</ResponsiveProvider>
|
|
268
|
+
import { useFocus } from 'app-studio';
|
|
269
|
+
|
|
270
|
+
function MyComponent() {
|
|
271
|
+
const { focused } = useFocus();
|
|
272
|
+
return <input style={{ borderColor: focused ? 'blue' : 'gray' }} />;
|
|
273
|
+
}
|
|
188
274
|
```
|
|
189
275
|
|
|
190
|
-
##
|
|
276
|
+
## useHover
|
|
277
|
+
|
|
278
|
+
Detects if an element is being hovered.
|
|
279
|
+
|
|
280
|
+
Return Values
|
|
191
281
|
|
|
192
|
-
|
|
282
|
+
| **Value** | **Type** | **Description** |
|
|
283
|
+
| --- | --- | --- |
|
|
284
|
+
| hovered | boolean | Whether the element is hovered. |
|
|
193
285
|
|
|
194
|
-
|
|
286
|
+
Example
|
|
287
|
+
|
|
288
|
+
jsx
|
|
195
289
|
|
|
196
290
|
```jsx
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
>
|
|
202
|
-
|
|
203
|
-
</View>
|
|
291
|
+
import { useHover } from 'app-studio';
|
|
292
|
+
|
|
293
|
+
function MyComponent() {
|
|
294
|
+
const { hovered } = useHover();
|
|
295
|
+
return <div style={{ background: hovered ? 'lightgray' : 'white' }}>Hover me</div>;
|
|
296
|
+
}
|
|
204
297
|
```
|
|
205
298
|
|
|
206
|
-
|
|
299
|
+
## useInView
|
|
207
300
|
|
|
208
|
-
|
|
301
|
+
Detects if an element is in the viewport.
|
|
209
302
|
|
|
210
|
-
|
|
303
|
+
Return Values
|
|
211
304
|
|
|
212
|
-
|
|
305
|
+
| **Value** | **Type** | **Description** |
|
|
306
|
+
| --- | --- | --- |
|
|
307
|
+
| inView | boolean | Whether the element is in view. |
|
|
213
308
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
309
|
+
Example
|
|
310
|
+
|
|
311
|
+
jsx
|
|
312
|
+
|
|
313
|
+
```jsx
|
|
314
|
+
import { useInView } from 'app-studio';
|
|
315
|
+
import { useRef } from 'react';
|
|
219
316
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// ... other shades
|
|
226
|
-
900: '#0f172a'
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
};
|
|
317
|
+
function MyComponent() {
|
|
318
|
+
const ref = useRef();
|
|
319
|
+
const { inView } = useInView(ref);
|
|
320
|
+
return <div ref={ref}>{inView ? 'Visible' : 'Hidden'}</div>;
|
|
321
|
+
}
|
|
230
322
|
```
|
|
231
323
|
|
|
232
|
-
|
|
324
|
+
## useKeyPress
|
|
325
|
+
|
|
326
|
+
Detects key presses.
|
|
327
|
+
|
|
328
|
+
Parameters
|
|
329
|
+
|
|
330
|
+
| **Param** | **Type** | **Description** |
|
|
331
|
+
| --- | --- | --- |
|
|
332
|
+
| key | string | The key to listen for (e.g., 'Enter'). |
|
|
333
|
+
|
|
334
|
+
Return Values
|
|
335
|
+
|
|
336
|
+
| **Value** | **Type** | **Description** |
|
|
337
|
+
| --- | --- | --- |
|
|
338
|
+
| pressed | boolean | Whether the key is pressed. |
|
|
339
|
+
|
|
340
|
+
Example
|
|
341
|
+
|
|
342
|
+
jsx
|
|
233
343
|
|
|
234
344
|
```jsx
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
345
|
+
import { useKeyPress } from 'app-studio';
|
|
346
|
+
|
|
347
|
+
function MyComponent() {
|
|
348
|
+
const pressed = useKeyPress('Enter');
|
|
349
|
+
return <div>{pressed ? 'Enter pressed' : 'Waiting...'}</div>;
|
|
350
|
+
}
|
|
238
351
|
```
|
|
239
352
|
|
|
240
|
-
|
|
353
|
+
## useMount
|
|
354
|
+
|
|
355
|
+
Runs a callback when the component mounts.
|
|
356
|
+
|
|
357
|
+
Parameters
|
|
358
|
+
|
|
359
|
+
| **Param** | **Type** | **Description** |
|
|
360
|
+
| --- | --- | --- |
|
|
361
|
+
| callback | function | Called on mount. |
|
|
362
|
+
|
|
363
|
+
Example
|
|
364
|
+
|
|
365
|
+
jsx
|
|
241
366
|
|
|
242
367
|
```jsx
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
368
|
+
import { useMount } from 'app-studio';
|
|
369
|
+
|
|
370
|
+
function MyComponent() {
|
|
371
|
+
useMount(() => console.log('Mounted'));
|
|
372
|
+
return <div>Hello</div>;
|
|
373
|
+
}
|
|
247
374
|
```
|
|
248
375
|
|
|
249
|
-
##
|
|
376
|
+
## useOnScreen
|
|
377
|
+
|
|
378
|
+
Similar to useInView, detects if an element is on screen.
|
|
379
|
+
|
|
380
|
+
Return Values
|
|
250
381
|
|
|
251
|
-
|
|
382
|
+
| **Value** | **Type** | **Description** |
|
|
383
|
+
| --- | --- | --- |
|
|
384
|
+
| onScreen | boolean | Whether the element is on screen. |
|
|
252
385
|
|
|
253
|
-
|
|
386
|
+
Example
|
|
254
387
|
|
|
255
|
-
|
|
388
|
+
jsx
|
|
256
389
|
|
|
257
390
|
```jsx
|
|
258
|
-
import {
|
|
391
|
+
import { useOnScreen } from 'app-studio';
|
|
392
|
+
import { useRef } from 'react';
|
|
393
|
+
|
|
394
|
+
function MyComponent() {
|
|
395
|
+
const ref = useRef();
|
|
396
|
+
const { onScreen } = useOnScreen(ref);
|
|
397
|
+
return <div ref={ref}>{onScreen ? 'On screen' : 'Off screen'}</div>;
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## useResponsive
|
|
402
|
+
|
|
403
|
+
Provides screen size and orientation data.
|
|
404
|
+
|
|
405
|
+
Return Values
|
|
259
406
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
407
|
+
| **Value** | **Type** | **Description** |
|
|
408
|
+
| --- | --- | --- |
|
|
409
|
+
| screen | string | Current screen size (e.g., 'xs', 'sm'). |
|
|
410
|
+
| orientation | `'landscape' | 'portrait'` |
|
|
411
|
+
| on | function | Checks if the screen matches a size. |
|
|
264
412
|
|
|
265
|
-
|
|
266
|
-
|
|
413
|
+
Example
|
|
414
|
+
|
|
415
|
+
jsx
|
|
416
|
+
|
|
417
|
+
```jsx
|
|
418
|
+
import { useResponsive } from 'app-studio';
|
|
419
|
+
|
|
420
|
+
function MyComponent() {
|
|
421
|
+
const { screen, orientation, on } = useResponsive();
|
|
422
|
+
return (
|
|
423
|
+
<div>
|
|
424
|
+
Screen: {screen}, Orientation: {orientation}
|
|
425
|
+
{on('mobile') && <div>Mobile view</div>}
|
|
426
|
+
</div>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
267
429
|
```
|
|
268
430
|
|
|
269
|
-
##
|
|
431
|
+
## useScroll
|
|
270
432
|
|
|
271
|
-
|
|
433
|
+
Tracks scroll position and direction.
|
|
272
434
|
|
|
273
|
-
|
|
435
|
+
Parameters
|
|
436
|
+
|
|
437
|
+
| **Param** | **Type** | **Default** | **Description** |
|
|
438
|
+
| --- | --- | --- | --- |
|
|
439
|
+
| throttleMs | number | 100 | Throttle updates (in ms). |
|
|
440
|
+
|
|
441
|
+
Return Values
|
|
442
|
+
|
|
443
|
+
| **Value** | **Type** | **Description** |
|
|
444
|
+
| --- | --- | --- |
|
|
445
|
+
| scrollY | number | Vertical scroll position. |
|
|
446
|
+
| scrollX | number | Horizontal scroll position. |
|
|
447
|
+
|
|
448
|
+
Example
|
|
449
|
+
|
|
450
|
+
jsx
|
|
274
451
|
|
|
275
452
|
```jsx
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
>
|
|
283
|
-
I am a View component with custom styling
|
|
284
|
-
</View>
|
|
453
|
+
import { useScroll } from 'app-studio';
|
|
454
|
+
|
|
455
|
+
function MyComponent() {
|
|
456
|
+
const { scrollY } = useScroll({ throttleMs: 200 });
|
|
457
|
+
return <div>Scroll Y: {scrollY}px</div>;
|
|
458
|
+
}
|
|
285
459
|
```
|
|
286
460
|
|
|
287
|
-
|
|
461
|
+
## useWindowSize
|
|
462
|
+
|
|
463
|
+
Tracks window dimensions.
|
|
464
|
+
|
|
465
|
+
Return Values
|
|
288
466
|
|
|
289
|
-
|
|
467
|
+
| **Value** | **Type** | **Description** |
|
|
468
|
+
| --- | --- | --- |
|
|
469
|
+
| width | number | Window width. |
|
|
470
|
+
| height | number | Window height. |
|
|
471
|
+
|
|
472
|
+
Example
|
|
473
|
+
|
|
474
|
+
jsx
|
|
290
475
|
|
|
291
476
|
```jsx
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
>
|
|
297
|
-
|
|
298
|
-
</View>
|
|
477
|
+
import { useWindowSize } from 'app-studio';
|
|
478
|
+
|
|
479
|
+
function MyComponent() {
|
|
480
|
+
const { width, height } = useWindowSize();
|
|
481
|
+
return <div>Window: {width}x{height}</div>;
|
|
482
|
+
}
|
|
299
483
|
```
|
|
300
484
|
|
|
301
|
-
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
# Providers
|
|
488
|
+
|
|
489
|
+
Providers manage global state and functionality across your application.
|
|
490
|
+
|
|
491
|
+
## AnalyticsProvider
|
|
492
|
+
|
|
493
|
+
Enables analytics tracking.
|
|
302
494
|
|
|
303
|
-
|
|
495
|
+
Props
|
|
304
496
|
|
|
305
|
-
|
|
497
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
498
|
+
| --- | --- | --- | --- |
|
|
499
|
+
| trackEvent | function | - | Callback for tracking events. |
|
|
500
|
+
|
|
501
|
+
Example
|
|
502
|
+
|
|
503
|
+
jsx
|
|
306
504
|
|
|
307
505
|
```jsx
|
|
308
|
-
|
|
309
|
-
<View
|
|
310
|
-
animate={Animation.fadeIn({
|
|
311
|
-
duration: '1s',
|
|
312
|
-
timingFunction: 'ease',
|
|
313
|
-
iterationCount: '1'
|
|
314
|
-
})}
|
|
315
|
-
/>
|
|
506
|
+
import { AnalyticsProvider } from 'app-studio';
|
|
316
507
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
to: { opacity: 0, transform: 'translateY(0)' },
|
|
328
|
-
duration: '2s',
|
|
329
|
-
timingFunction: 'ease-out'
|
|
330
|
-
}
|
|
331
|
-
];
|
|
332
|
-
|
|
333
|
-
<View animate={sequence} />
|
|
334
|
-
|
|
335
|
-
// Animation on hover
|
|
336
|
-
<View
|
|
337
|
-
on={{
|
|
338
|
-
hover: {
|
|
339
|
-
animate: Animation.rotate({ duration: '1s', timingFunction: 'ease' })
|
|
340
|
-
}
|
|
341
|
-
}}
|
|
342
|
-
/>
|
|
508
|
+
function App() {
|
|
509
|
+
return (
|
|
510
|
+
<AnalyticsProvider
|
|
511
|
+
trackEvent={({ type, target, ...event }) => {
|
|
512
|
+
AppAnalytics.track(`${type}_${target}`, event);
|
|
513
|
+
}}>
|
|
514
|
+
{/* App content */}
|
|
515
|
+
</AnalyticsProvider>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
343
518
|
```
|
|
344
519
|
|
|
345
|
-
|
|
520
|
+
## ResponsiveProvider
|
|
346
521
|
|
|
347
|
-
|
|
348
|
-
- `Animation.fadeIn()`
|
|
349
|
-
- `Animation.fadeOut()`
|
|
350
|
-
- `Animation.bounce()`
|
|
351
|
-
- `Animation.rotate()`
|
|
352
|
-
- `Animation.pulse()`
|
|
353
|
-
- And many more...
|
|
522
|
+
Manages responsive design context.
|
|
354
523
|
|
|
355
|
-
|
|
524
|
+
Props
|
|
356
525
|
|
|
357
|
-
|
|
526
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
527
|
+
| --- | --- | --- | --- |
|
|
528
|
+
| breakpoints | object | - | Custom breakpoints. |
|
|
529
|
+
|
|
530
|
+
Example
|
|
531
|
+
|
|
532
|
+
jsx
|
|
358
533
|
|
|
359
534
|
```jsx
|
|
360
|
-
import {
|
|
535
|
+
import { ResponsiveProvider } from 'app-studio';
|
|
361
536
|
|
|
362
|
-
function
|
|
537
|
+
function App() {
|
|
363
538
|
return (
|
|
364
|
-
<
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
539
|
+
<ResponsiveProvider breakpoints={{ xs: 0, sm: 600, md: 960 }}>
|
|
540
|
+
{/* App content */}
|
|
541
|
+
</ResponsiveProvider>
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
## ThemeProvider
|
|
547
|
+
|
|
548
|
+
Manages theming, including colors and typography.
|
|
549
|
+
|
|
550
|
+
Props
|
|
551
|
+
|
|
552
|
+
| **Prop** | **Type** | **Default** | **Description** |
|
|
553
|
+
| --- | --- | --- | --- |
|
|
554
|
+
| theme | Theme | - | Custom theme configuration. |
|
|
555
|
+
| mode | `'light' | 'dark'` | 'light' |
|
|
556
|
+
| dark | Colors | - | Dark mode colors. |
|
|
557
|
+
| light | Colors | - | Light mode colors. |
|
|
558
|
+
|
|
559
|
+
Context
|
|
560
|
+
|
|
561
|
+
- getColor: Resolves theme colors.
|
|
562
|
+
- theme: Current theme configuration.
|
|
563
|
+
- themeMode: Current mode.
|
|
564
|
+
- setThemeMode: Switches mode.
|
|
565
|
+
|
|
566
|
+
Example
|
|
567
|
+
|
|
568
|
+
jsx
|
|
569
|
+
|
|
570
|
+
```jsx
|
|
571
|
+
import { ThemeProvider, useTheme } from 'app-studio';
|
|
572
|
+
|
|
573
|
+
function App() {
|
|
574
|
+
return (
|
|
575
|
+
<ThemeProvider mode="dark">
|
|
576
|
+
<MyComponent />
|
|
577
|
+
</ThemeProvider>
|
|
371
578
|
);
|
|
372
579
|
}
|
|
580
|
+
|
|
581
|
+
function MyComponent() {
|
|
582
|
+
const { getColor, themeMode } = useTheme();
|
|
583
|
+
return <div style={{ color: getColor('primary') }}>{themeMode} mode</div>;
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
# Utilities
|
|
590
|
+
|
|
591
|
+
Utilities provide helper functions and constants.
|
|
592
|
+
|
|
593
|
+
Colors
|
|
594
|
+
|
|
595
|
+
Predefined color palettes for theming.
|
|
596
|
+
|
|
597
|
+
Usage
|
|
598
|
+
|
|
599
|
+
jsx
|
|
600
|
+
|
|
601
|
+
```jsx
|
|
602
|
+
import { useTheme } from 'app-studio';
|
|
603
|
+
|
|
604
|
+
function MyComponent() {
|
|
605
|
+
const { getColor } = useTheme();
|
|
606
|
+
return <div style={{ backgroundColor: getColor('color.blue.500') }} />;
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
# Constants
|
|
611
|
+
|
|
612
|
+
Common values like breakpoints and sizes.
|
|
613
|
+
|
|
614
|
+
Usage
|
|
615
|
+
|
|
616
|
+
jsx
|
|
617
|
+
|
|
618
|
+
```jsx
|
|
619
|
+
import { BREAKPOINTS } from 'app-studio/constants';
|
|
620
|
+
|
|
621
|
+
console.log(BREAKPOINTS.sm); // 600
|
|
373
622
|
```
|
|
374
623
|
|
|
375
|
-
|
|
624
|
+
## Theming
|
|
376
625
|
|
|
377
|
-
|
|
626
|
+
Customize themes with ThemeProvider. Define light and dark modes and use getColor to access colors.
|
|
378
627
|
|
|
379
|
-
|
|
628
|
+
Example
|
|
380
629
|
|
|
381
|
-
|
|
382
|
-
- `slideInLeft` / `slideInRight` / `slideInUp` / `slideInDown`
|
|
383
|
-
- `zoomIn` / `zoomOut`
|
|
630
|
+
jsx
|
|
384
631
|
|
|
385
|
-
|
|
632
|
+
```jsx
|
|
633
|
+
<ThemeProvider
|
|
634
|
+
theme={{ primary: '#007bff' }}
|
|
635
|
+
dark={{ background: '#333' }}
|
|
636
|
+
light={{ background: '#fff' }}
|
|
637
|
+
/>
|
|
638
|
+
```
|
|
386
639
|
|
|
387
|
-
|
|
388
|
-
- `scale`
|
|
389
|
-
- `translate`
|
|
640
|
+
---
|
|
390
641
|
|
|
391
|
-
|
|
642
|
+
# Responsive Design
|
|
392
643
|
|
|
393
|
-
|
|
394
|
-
- `pulse`
|
|
395
|
-
- `flash`
|
|
396
|
-
- `shake`
|
|
397
|
-
- `swing`
|
|
398
|
-
- `rubberBand`
|
|
399
|
-
- `wobble`
|
|
400
|
-
- `flip`
|
|
401
|
-
- `heartBeat`
|
|
402
|
-
- `rollIn` / `rollOut`
|
|
403
|
-
- `lightSpeedIn` / `lightSpeedOut`
|
|
404
|
-
- `hinge`
|
|
405
|
-
- `jackInTheBox`
|
|
644
|
+
Use ResponsiveProvider and useResponsive to adapt to screen sizes.
|
|
406
645
|
|
|
407
|
-
|
|
646
|
+
Example
|
|
408
647
|
|
|
409
|
-
|
|
648
|
+
jsx
|
|
410
649
|
|
|
411
|
-
|
|
650
|
+
```jsx
|
|
651
|
+
const { on } = useResponsive();
|
|
652
|
+
return on('sm') ? <SmallLayout /> : <LargeLayout />;
|
|
653
|
+
```
|
|
412
654
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## Analytics
|
|
658
|
+
|
|
659
|
+
Integrate analytics with AnalyticsProvider to track events.
|
|
416
660
|
|
|
417
|
-
|
|
661
|
+
Example
|
|
418
662
|
|
|
419
|
-
|
|
663
|
+
jsx
|
|
420
664
|
|
|
421
665
|
```jsx
|
|
422
|
-
|
|
666
|
+
<AnalyticsProvider config={{ provider: 'google', trackingId: 'UA-123' }} />
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
---
|
|
423
670
|
|
|
424
|
-
|
|
425
|
-
main: { primary: '#fff7ed' },
|
|
426
|
-
components: { button: { background: '#fff7ed' } }
|
|
427
|
-
};
|
|
671
|
+
API Reference
|
|
428
672
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
673
|
+
- Components: View, Image, Text, Form, Skeleton, Wrapper
|
|
674
|
+
- Hooks: useActive, useClickOutside, etc.
|
|
675
|
+
- Providers: AnalyticsProvider, ResponsiveProvider, ThemeProvider
|
|
676
|
+
- Utilities: colors, constants, etc.
|
|
433
677
|
|
|
434
|
-
|
|
678
|
+
---
|
|
679
|
+
|
|
680
|
+
Examples
|
|
681
|
+
|
|
682
|
+
## Responsive Layout
|
|
683
|
+
|
|
684
|
+
jsx
|
|
685
|
+
|
|
686
|
+
```jsx
|
|
687
|
+
import { View, useResponsive } from 'app-studio';
|
|
688
|
+
|
|
689
|
+
function Layout() {
|
|
690
|
+
const { on } = useResponsive();
|
|
435
691
|
return (
|
|
436
|
-
<
|
|
437
|
-
<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
backgroundColor="color.blue"
|
|
441
|
-
padding={10}
|
|
442
|
-
media={{
|
|
443
|
-
mobile: {
|
|
444
|
-
padding: 20
|
|
445
|
-
}
|
|
446
|
-
}}
|
|
447
|
-
>
|
|
448
|
-
Base element
|
|
449
|
-
</Span>
|
|
450
|
-
<View
|
|
451
|
-
animate={Animation.slideInRight()}
|
|
452
|
-
backgroundColor="theme.primary"
|
|
453
|
-
margin={10}
|
|
454
|
-
width={200}
|
|
455
|
-
on={{ hover: { backgroundColor: 'color.blueGray.500' } }}
|
|
456
|
-
>
|
|
457
|
-
Hover to change color
|
|
458
|
-
</View>
|
|
459
|
-
<Button
|
|
460
|
-
animate={Animation.pulse({timingFunction:'infinite'})}
|
|
461
|
-
backgroundColor="theme.button.background"
|
|
462
|
-
>
|
|
463
|
-
Click here
|
|
464
|
-
</Button>
|
|
465
|
-
<Text
|
|
466
|
-
animate={Animation.typewriter('Hello', 100)}
|
|
467
|
-
color="theme.primary"
|
|
468
|
-
/>
|
|
469
|
-
</ThemeProvider>
|
|
470
|
-
</ResponsiveProvider>
|
|
692
|
+
<View flexDirection={on('mobile') ? 'column' : 'row'}>
|
|
693
|
+
<View>Sidebar</View>
|
|
694
|
+
<View>Main Content</View>
|
|
695
|
+
</View>
|
|
471
696
|
);
|
|
472
697
|
}
|
|
473
698
|
```
|
|
474
699
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
We welcome all contributions to App-Studio. Please read our [contributing guide](https://ant.design/docs/react/contributing) and let's build a better App-Studio together.
|
|
700
|
+
---
|
|
478
701
|
|
|
479
|
-
|
|
702
|
+
Contributing
|
|
480
703
|
|
|
481
|
-
|
|
704
|
+
Contributions are welcome! Please follow these steps:
|
|
482
705
|
|
|
483
|
-
|
|
706
|
+
1. Fork the repository.
|
|
707
|
+
2. Create a feature branch.
|
|
708
|
+
3. Submit a pull request with tests.
|
|
484
709
|
|
|
485
710
|
---
|
|
486
711
|
|
|
487
|
-
|
|
712
|
+
Changelog
|
|
713
|
+
|
|
714
|
+
- v1.0.0: Initial release with components, hooks, and providers.
|