app-studio 0.6.21 → 0.6.22
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/docs/Animation.md +197 -0
- package/docs/Components.md +192 -0
- package/docs/Design.md +121 -0
- package/docs/Events.md +296 -0
- package/docs/Hooks.md +469 -0
- package/docs/Providers.md +186 -0
- package/docs/README.md +780 -0
- package/docs/Responsive.md +135 -0
- package/docs/Theming.md +200 -0
- package/package.json +3 -2
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Animation
|
|
2
|
+
|
|
3
|
+
## 1. Introduction
|
|
4
|
+
|
|
5
|
+
App-Studio provides a powerful animation system through the `Animation` object. This system allows you to easily add dynamic and engaging animations to any component that extends from `Element`. The animations are based on CSS animations and can be customized with various properties.
|
|
6
|
+
|
|
7
|
+
## 2. Usage
|
|
8
|
+
|
|
9
|
+
### Basic Usage
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
import { View, Animation } from 'app-studio';
|
|
13
|
+
|
|
14
|
+
// Simple animation
|
|
15
|
+
<View
|
|
16
|
+
animate={Animation.fadeIn({
|
|
17
|
+
duration: '1s',
|
|
18
|
+
timingFunction: 'ease',
|
|
19
|
+
iterationCount: '1'
|
|
20
|
+
})}
|
|
21
|
+
/>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Animation Properties
|
|
25
|
+
|
|
26
|
+
Each animation function accepts an options object with these properties:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
type AnimationOptions = {
|
|
30
|
+
duration?: string; // e.g., '1s', '500ms'
|
|
31
|
+
timingFunction?: string; // e.g., 'ease', 'linear', 'ease-in-out'
|
|
32
|
+
iterationCount?: string | number; // e.g., '1', 'infinite'
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 3. Animation Types
|
|
37
|
+
|
|
38
|
+
### Transition Animations
|
|
39
|
+
|
|
40
|
+
Animations that involve changes in opacity or position:
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
// Fade animations (change opacity)
|
|
44
|
+
Animation.fadeIn()
|
|
45
|
+
Animation.fadeOut()
|
|
46
|
+
|
|
47
|
+
// Slide animations (move elements)
|
|
48
|
+
Animation.slideInLeft()
|
|
49
|
+
Animation.slideInRight()
|
|
50
|
+
Animation.slideOutLeft()
|
|
51
|
+
Animation.slideOutRight()
|
|
52
|
+
Animation.slideInUp()
|
|
53
|
+
Animation.slideOutDown()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Transform Animations
|
|
57
|
+
|
|
58
|
+
Animations that modify the element's transformation:
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
// Rotate
|
|
62
|
+
Animation.rotate()
|
|
63
|
+
|
|
64
|
+
// Scale
|
|
65
|
+
Animation.scale()
|
|
66
|
+
|
|
67
|
+
// Translate
|
|
68
|
+
Animation.translate()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Effect Animations
|
|
72
|
+
|
|
73
|
+
Animations that create special effects:
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
// Attention seekers
|
|
77
|
+
Animation.bounce()
|
|
78
|
+
Animation.pulse()
|
|
79
|
+
Animation.shake()
|
|
80
|
+
Animation.flash()
|
|
81
|
+
|
|
82
|
+
// Special effects
|
|
83
|
+
Animation.flip()
|
|
84
|
+
Animation.rubberBand()
|
|
85
|
+
Animation.heartBeat()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 4. Event-Based Animations
|
|
89
|
+
|
|
90
|
+
Animations can be triggered by various events using the `on` prop:
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
<View
|
|
94
|
+
on={{
|
|
95
|
+
// Animation on hover
|
|
96
|
+
hover: {
|
|
97
|
+
backgroundColor: 'lightblue', // Example: change background color on hover
|
|
98
|
+
animate: Animation.pulse({
|
|
99
|
+
duration: "1s",
|
|
100
|
+
iterationCount: "infinite",
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// Animation on click
|
|
105
|
+
click: {
|
|
106
|
+
animate: Animation.flash({ duration: '0.5s' })
|
|
107
|
+
}
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 5. Responsive Animations
|
|
113
|
+
|
|
114
|
+
You can define different animations for different screen sizes using the `media` prop:
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
<View
|
|
118
|
+
media={{
|
|
119
|
+
mobile: {
|
|
120
|
+
animate: Animation.fadeIn({ duration: '1s' })
|
|
121
|
+
},
|
|
122
|
+
tablet: {
|
|
123
|
+
animate: Animation.slideInLeft({ duration: '0.5s' })
|
|
124
|
+
},
|
|
125
|
+
desktop: {
|
|
126
|
+
animate: Animation.bounce({ duration: '2s' })
|
|
127
|
+
}
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 6. Custom Animation Sequences
|
|
133
|
+
|
|
134
|
+
You can create complex animation sequences by defining an array of animation states. Each state in the sequence is an object with `from` and `to` properties that define the CSS styles at the start and end of that animation segment.
|
|
135
|
+
|
|
136
|
+
Here's a simple example:
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
const simpleSequence = [
|
|
140
|
+
{
|
|
141
|
+
from: { opacity: 0 }, // Start fully transparent
|
|
142
|
+
to: { opacity: 1 }, // End fully opaque
|
|
143
|
+
duration: "1s",
|
|
144
|
+
timingFunction: "ease-in",
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
<View animate={simpleSequence} />
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
And here's a more complex example:
|
|
152
|
+
|
|
153
|
+
```jsx
|
|
154
|
+
const complexSequence = [
|
|
155
|
+
{
|
|
156
|
+
from: { opacity: 0, transform: "translateY(-100px)" },
|
|
157
|
+
to: { opacity: 1, transform: "translateY(0)" },
|
|
158
|
+
duration: "2s",
|
|
159
|
+
timingFunction: "ease-in",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
from: { opacity: 1, transform: "translateY(100px)" },
|
|
163
|
+
to: { opacity: 0, transform: "translateY(0)" },
|
|
164
|
+
duration: "2s",
|
|
165
|
+
timingFunction: "ease-out",
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
<View animate={complexSequence} />
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 7. Best Practices
|
|
173
|
+
|
|
174
|
+
1. **Performance**
|
|
175
|
+
- Use animations sparingly and purposefully
|
|
176
|
+
- Prefer transform and opacity animations for better performance
|
|
177
|
+
- Avoid animating too many properties simultaneously
|
|
178
|
+
|
|
179
|
+
2. **User Experience**
|
|
180
|
+
- Keep animations short and subtle
|
|
181
|
+
- Use appropriate timing functions for natural movement
|
|
182
|
+
- Consider reducing motion for accessibility
|
|
183
|
+
|
|
184
|
+
3. **Code Organization**
|
|
185
|
+
- Define reusable animation configurations
|
|
186
|
+
- Use meaningful names for custom sequences
|
|
187
|
+
- Keep animation logic separate from component logic. For example, you can create separate configuration objects for your animations:
|
|
188
|
+
```jsx
|
|
189
|
+
const myAnimation = Animation.fadeIn({ duration: '1s' });
|
|
190
|
+
|
|
191
|
+
<View animate={myAnimation} />
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
4. **Responsive Design**
|
|
195
|
+
- Adjust animation duration for different screen sizes
|
|
196
|
+
- Consider disabling complex animations on mobile devices
|
|
197
|
+
- Test animations on *real devices* in addition to browser developer tools, as performance can vary.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
App-Studio provides a comprehensive set of components built on the `Element` base component. This guide covers all the available components and their usage.
|
|
4
|
+
|
|
5
|
+
## Element
|
|
6
|
+
|
|
7
|
+
The `Element` component is the foundation of App-Studio. It is responsible for handling a large part of the styles of the other components. It takes care of responsiveness, shadow, margins, and padding among other properties.
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<Element backgroundColor="color.blue" padding={10}>This is an element</Element>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
It is the base component for all other components in the library. It adds additional properties to help manage design:
|
|
16
|
+
|
|
17
|
+
- `widthHeight`: Sets both `width` and `height` to the same value. Accepts a number (in pixels) or a string (e.g., '50%', 'auto').
|
|
18
|
+
- `on`: An object to define styles that apply on different CSS pseudo-class events (like `hover`, `focus`, `active`). Refer to the Events documentation for details.
|
|
19
|
+
- `media`: An object to define responsive styles for different media queries (breakpoints) or devices. Refer to the Responsive Design documentation for details.
|
|
20
|
+
- `shadow`: Applies a shadow effect to the element. Can be a boolean (default shadow), a number (referencing predefined shadow levels), or a `Shadow` object for custom shadow properties.
|
|
21
|
+
|
|
22
|
+
## Layout Components
|
|
23
|
+
|
|
24
|
+
### View
|
|
25
|
+
The basic building block for layouts. Extends the basic `div` HTML element.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { View } from 'app-studio';
|
|
29
|
+
|
|
30
|
+
<View
|
|
31
|
+
widthHeight={100}
|
|
32
|
+
backgroundColor="color.white"
|
|
33
|
+
marginTop={20}
|
|
34
|
+
>
|
|
35
|
+
{/* Content */}
|
|
36
|
+
</View>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Vertical & Horizontal
|
|
40
|
+
For stack and row layouts.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Vertical, Horizontal } from 'app-studio';
|
|
44
|
+
|
|
45
|
+
// Vertical stack
|
|
46
|
+
<Vertical spacing={20}>
|
|
47
|
+
<View />
|
|
48
|
+
<View />
|
|
49
|
+
</Vertical>
|
|
50
|
+
|
|
51
|
+
// Horizontal row
|
|
52
|
+
<Horizontal spacing={10}>
|
|
53
|
+
<View />
|
|
54
|
+
<View />
|
|
55
|
+
</Horizontal>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Text Components
|
|
59
|
+
|
|
60
|
+
### Text
|
|
61
|
+
For displaying text content with theme support. Extends the basic `span` HTML element.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Text } from 'app-studio';
|
|
65
|
+
|
|
66
|
+
<Text
|
|
67
|
+
color="color.black"
|
|
68
|
+
marginRight={10}
|
|
69
|
+
>
|
|
70
|
+
Content
|
|
71
|
+
</Text>
|
|
72
|
+
|
|
73
|
+
// With theme mode
|
|
74
|
+
<Text
|
|
75
|
+
color="color.red"
|
|
76
|
+
themeMode="dark"
|
|
77
|
+
>
|
|
78
|
+
Dark mode text
|
|
79
|
+
</Text>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Media Components
|
|
83
|
+
|
|
84
|
+
### Image
|
|
85
|
+
Extends the basic `img` HTML element with additional properties like `shadow`, `media`, and `on`.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { Image } from 'app-studio';
|
|
89
|
+
|
|
90
|
+
// Basic usage
|
|
91
|
+
<Image
|
|
92
|
+
widthHeight={100}
|
|
93
|
+
shadow={9}
|
|
94
|
+
src="https://picsum.photos/200"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
// Responsive image (mobile only)
|
|
98
|
+
<Image
|
|
99
|
+
widthHeight={100}
|
|
100
|
+
src="https://picsum.photos/200"
|
|
101
|
+
only={['mobile']}
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Form Components
|
|
106
|
+
|
|
107
|
+
### Form
|
|
108
|
+
Extends the basic `form` HTML element. It's used for creating forms and provides nested `Form.Button` and `Form.Input` components for form elements.
|
|
109
|
+
|
|
110
|
+
```jsx
|
|
111
|
+
<Form>
|
|
112
|
+
<Input placeholder="Enter your name" />
|
|
113
|
+
<Button>Submit</Button>
|
|
114
|
+
</Form>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Input
|
|
118
|
+
Extends the basic `input` HTML element with additional styling properties.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { Input } from 'app-studio';
|
|
122
|
+
|
|
123
|
+
// Basic usage
|
|
124
|
+
<Input width={100} />
|
|
125
|
+
|
|
126
|
+
// With hover state
|
|
127
|
+
<Input
|
|
128
|
+
width={100}
|
|
129
|
+
shadow={9}
|
|
130
|
+
on={{
|
|
131
|
+
hover: {
|
|
132
|
+
backgroundColor: 'color.red'
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Button
|
|
139
|
+
Interactive button component with built-in states and animations.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { Button } from 'app-studio';
|
|
143
|
+
|
|
144
|
+
<Button
|
|
145
|
+
paddingHorizontal={20}
|
|
146
|
+
paddingVertical={10}
|
|
147
|
+
backgroundColor="color.green.500"
|
|
148
|
+
color="color.white"
|
|
149
|
+
borderRadius={5}
|
|
150
|
+
fontWeight="bold"
|
|
151
|
+
on={{
|
|
152
|
+
hover: { backgroundColor: 'color.green.600' },
|
|
153
|
+
active: { transform: 'scale(0.95)' }
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
Click Me
|
|
157
|
+
</Button>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Feedback Components
|
|
161
|
+
|
|
162
|
+
### Skeleton
|
|
163
|
+
Used for loading states and content placeholders. Extends `View`.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { Skeleton, View } from 'app-studio';
|
|
167
|
+
|
|
168
|
+
// Basic usage
|
|
169
|
+
<View>
|
|
170
|
+
<Skeleton widthHeight={100} />
|
|
171
|
+
</View>
|
|
172
|
+
|
|
173
|
+
// With background comparison
|
|
174
|
+
<View>
|
|
175
|
+
<View widthHeight={100} backgroundColor="red" />
|
|
176
|
+
<Skeleton widthHeight={100} />
|
|
177
|
+
</View>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Component Props
|
|
181
|
+
|
|
182
|
+
All components extend the base `Element` props:
|
|
183
|
+
|
|
184
|
+
- `as`: HTML element to render as
|
|
185
|
+
- `media`: Responsive styles object
|
|
186
|
+
- `on`: Interactive state styles
|
|
187
|
+
- `animate`: Animation configuration
|
|
188
|
+
- `themeMode`: Override theme mode
|
|
189
|
+
- `colors`: Custom color palette
|
|
190
|
+
- `theme`: Custom theme tokens
|
|
191
|
+
|
|
192
|
+
Additional component-specific props are documented in their respective sections above.
|
package/docs/Design.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
# Design Props and Styling
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
The `app-studio` library provides a set of design props that simplify styling and enhance design integration. These props offer a more streamlined and efficient way to manage styling compared to using inline styles or CSS classes directly. They are particularly beneficial for implementing responsive and theme-aware styling, allowing you to easily adapt your components to different screen sizes and themes.
|
|
6
|
+
|
|
7
|
+
Here is an example:
|
|
8
|
+
|
|
9
|
+
```jsx
|
|
10
|
+
<View
|
|
11
|
+
backgroundColor="theme.primary"
|
|
12
|
+
padding={20}
|
|
13
|
+
margin={10}
|
|
14
|
+
width={200}
|
|
15
|
+
height={100}
|
|
16
|
+
>
|
|
17
|
+
I am a View component with custom styling
|
|
18
|
+
</View>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In this example, the View component is styled with custom background color, padding, margin, width, and height.
|
|
22
|
+
|
|
23
|
+
The `shadow` prop allows you to apply shadow effects to components. It can accept a boolean, a number, or a `Shadow` object. A boolean value applies a default shadow, while a number references predefined shadow levels (e.g., `shadow={6}` might correspond to a specific shadow intensity defined in your theme). For more granular control, you can use a `Shadow` object to customize the shadow's properties.
|
|
24
|
+
|
|
25
|
+
Here is an example:
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
<View backgroundColor="theme.primary" padding={20} shadow={6}>
|
|
29
|
+
I have a shadow
|
|
30
|
+
</View>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
In this example, the `shadow={6}` applies the 6th predefined shadow level from your theme to the `View` component.
|
|
34
|
+
|
|
35
|
+
## CSS Custom Properties (Variables)
|
|
36
|
+
|
|
37
|
+
App-Studio supports CSS custom properties (CSS variables) that start with `--`. You can define and use these variables in your components for more flexible styling:
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
<View
|
|
41
|
+
style={{
|
|
42
|
+
'--primary-color': 'blue',
|
|
43
|
+
'--primary-bg': 'lightblue',
|
|
44
|
+
'--spacing': '15px',
|
|
45
|
+
}}
|
|
46
|
+
backgroundColor="var(--primary-bg)"
|
|
47
|
+
color="var(--primary-color)"
|
|
48
|
+
padding="var(--spacing)"
|
|
49
|
+
>
|
|
50
|
+
This component uses CSS variables
|
|
51
|
+
</View>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can also define CSS variables using the `css` prop:
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
<View
|
|
58
|
+
css={{
|
|
59
|
+
'--secondary-color': 'green',
|
|
60
|
+
'--secondary-bg': 'lightgreen',
|
|
61
|
+
'--border-radius': '8px',
|
|
62
|
+
}}
|
|
63
|
+
backgroundColor="var(--secondary-bg)"
|
|
64
|
+
borderRadius="var(--border-radius)"
|
|
65
|
+
>
|
|
66
|
+
<Text color="var(--secondary-color)">
|
|
67
|
+
This text uses a CSS variable for its color
|
|
68
|
+
</Text>
|
|
69
|
+
</View>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
CSS variables are particularly useful for:
|
|
73
|
+
- Creating theme variations within components
|
|
74
|
+
- Sharing values between different CSS properties
|
|
75
|
+
- Enabling dynamic styling through JavaScript
|
|
76
|
+
|
|
77
|
+
## Vendor-Prefixed Properties
|
|
78
|
+
|
|
79
|
+
App-Studio handles vendor-prefixed CSS properties to ensure cross-browser compatibility. You can use both camelCase and lowercase formats for vendor prefixes:
|
|
80
|
+
|
|
81
|
+
### Camel Case Format (Recommended)
|
|
82
|
+
|
|
83
|
+
```jsx
|
|
84
|
+
<View
|
|
85
|
+
WebkitUserSelect="none"
|
|
86
|
+
MozUserSelect="none"
|
|
87
|
+
msFlexAlign="center"
|
|
88
|
+
>
|
|
89
|
+
This element has vendor-prefixed properties
|
|
90
|
+
</View>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Lowercase Format
|
|
94
|
+
|
|
95
|
+
```jsx
|
|
96
|
+
<View
|
|
97
|
+
webkitBackgroundClip="text"
|
|
98
|
+
webkitTextFillColor="transparent"
|
|
99
|
+
background="linear-gradient(45deg, #ff0000, #0000ff)"
|
|
100
|
+
>
|
|
101
|
+
This text should have a gradient effect
|
|
102
|
+
</View>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
You can also use the `css` prop for more complex vendor-prefixed styles:
|
|
106
|
+
|
|
107
|
+
```jsx
|
|
108
|
+
<View
|
|
109
|
+
css={{
|
|
110
|
+
background: "linear-gradient(45deg, #ff0000, #00ff00, #0000ff)",
|
|
111
|
+
webkitBackgroundClip: "text",
|
|
112
|
+
color: "transparent",
|
|
113
|
+
fontSize: "24px",
|
|
114
|
+
fontWeight: "bold"
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
This text should have a gradient background
|
|
118
|
+
</View>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
App-Studio automatically converts JavaScript-style vendor-prefixed properties (like `webkitBackgroundClip`) to their CSS equivalents with hyphens (e.g., `-webkit-background-clip`), ensuring proper rendering across different browsers.
|