@app-studio/web 0.9.57 → 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 +149 -99
- 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 +149 -99
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +153 -102
- 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/ChatInput.mdx +133 -0
- package/package.json +3 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Animation
|
|
2
|
+
|
|
3
|
+
## 1. Introduction
|
|
4
|
+
|
|
5
|
+
App-Studio provides a powerful animation system through the `Animation` object and the `Element` component. This system allows you to easily add dynamic and engaging animations, including:
|
|
6
|
+
|
|
7
|
+
- **Standard CSS Animations**: Immediate animations on mount or loop.
|
|
8
|
+
- **Scroll-Triggered Animations** (`view()`): Animations that play when elements enter the viewport.
|
|
9
|
+
- **Scroll-Linked Animations** (`scroll()`): Animations driven by the scroll progress (e.g., parallax, reading progress).
|
|
10
|
+
- **Interactive Animations**: Triggered by events like hover, click, or focus.
|
|
11
|
+
|
|
12
|
+
## 2. Basic Usage
|
|
13
|
+
|
|
14
|
+
### Standard Animations
|
|
15
|
+
|
|
16
|
+
Use the `Animation` object to access standard animation presets.
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { View, Animation } from 'app-studio';
|
|
20
|
+
|
|
21
|
+
// Simple animation running immediately on mount
|
|
22
|
+
<View
|
|
23
|
+
animate={Animation.fadeIn({
|
|
24
|
+
duration: '1s',
|
|
25
|
+
timingFunction: 'ease',
|
|
26
|
+
iterationCount: '1'
|
|
27
|
+
})}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Animation Properties
|
|
32
|
+
|
|
33
|
+
Each animation function accepts an options object with these properties:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
type AnimationOptions = {
|
|
37
|
+
duration?: string; // e.g., '1s', '500ms'
|
|
38
|
+
timingFunction?: string; // e.g., 'ease', 'linear', 'cubic-bezier(...)'
|
|
39
|
+
iterationCount?: string | number; // e.g., '1', 'infinite'
|
|
40
|
+
delay?: string; // e.g., '0.5s'
|
|
41
|
+
direction?: string; // e.g., 'normal', 'reverse', 'alternate'
|
|
42
|
+
fillMode?: string; // e.g., 'forwards', 'both'
|
|
43
|
+
playState?: string; // e.g., 'running', 'paused'
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 3. Element Props for Animation
|
|
48
|
+
|
|
49
|
+
The `Element` component (and components extending it like `View`, `Text`, `Image`) supports several props to control animations:
|
|
50
|
+
|
|
51
|
+
### `animate`
|
|
52
|
+
The main property to apply animations. Accepts a single animation object or an array of animations.
|
|
53
|
+
|
|
54
|
+
```jsx
|
|
55
|
+
<View animate={Animation.bounce()} />
|
|
56
|
+
<View animate={[Animation.fadeIn(), Animation.slideInUp()]} />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `animateIn` & `animateOut`
|
|
60
|
+
Useful for mounting and unmounting transitions, or conditional rendering effects.
|
|
61
|
+
- `animateIn`: Applied when the component mounts or becomes visible (if `IntersectionObserver` is used internally).
|
|
62
|
+
- `animateOut`: Applied during unmount cleanup (requires immediate re-render or external handling to be visible).
|
|
63
|
+
|
|
64
|
+
### `animateOn`
|
|
65
|
+
Controls *when* the animation defined in `animate` starts.
|
|
66
|
+
|
|
67
|
+
- `'Mount'` (default): Animation starts immediately when the component is added to the DOM.
|
|
68
|
+
- `'View'`: Animation is converted to a CSS `view()` timeline animation. It plays as the element enters the viewport. **No JavaScript required.**
|
|
69
|
+
- `'Both'`: Technically same as Mount for most cases, ensuring visibility.
|
|
70
|
+
|
|
71
|
+
```jsx
|
|
72
|
+
// Trigger animation only when user scrolls it into view
|
|
73
|
+
<View animate={Animation.slideInUp()} animateOn="View" />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 4. Animation Presets
|
|
77
|
+
|
|
78
|
+
App-Studio comes with a comprehensive library of ready-to-use animations available under the `Animation` namespace.
|
|
79
|
+
|
|
80
|
+
### Fades
|
|
81
|
+
- `Animation.fadeIn()`
|
|
82
|
+
- `Animation.fadeOut()`
|
|
83
|
+
- `Animation.fadeInDown()`
|
|
84
|
+
- `Animation.fadeInUp()`
|
|
85
|
+
- `Animation.fadeInScroll()` - Scroll-progress driven fade
|
|
86
|
+
|
|
87
|
+
### Slides
|
|
88
|
+
- `Animation.slideInLeft()`
|
|
89
|
+
- `Animation.slideInRight()`
|
|
90
|
+
- `Animation.slideInDown()`
|
|
91
|
+
- `Animation.slideInUp()`
|
|
92
|
+
- `Animation.slideOutLeft()`
|
|
93
|
+
- `Animation.slideOutRight()`
|
|
94
|
+
- `Animation.slideInLeftScroll()` - Scroll-progress driven slide
|
|
95
|
+
|
|
96
|
+
### Zooms & Scales
|
|
97
|
+
- `Animation.zoomIn()`
|
|
98
|
+
- `Animation.zoomOut()`
|
|
99
|
+
- `Animation.zoomInDown()`
|
|
100
|
+
- `Animation.zoomOutUp()`
|
|
101
|
+
- `Animation.scale()` - Pulse scale effect
|
|
102
|
+
- `Animation.scaleDownScroll()`
|
|
103
|
+
- `Animation.listItemScaleScroll()`
|
|
104
|
+
|
|
105
|
+
### Bounces
|
|
106
|
+
- `Animation.bounce()`
|
|
107
|
+
- `Animation.bounceIn()`
|
|
108
|
+
- `Animation.bounceOut()`
|
|
109
|
+
|
|
110
|
+
### Flips & Rotations
|
|
111
|
+
- `Animation.rotate()`
|
|
112
|
+
- `Animation.flip()`
|
|
113
|
+
- `Animation.flipInX()`
|
|
114
|
+
- `Animation.flipInY()`
|
|
115
|
+
- `Animation.rollIn()`
|
|
116
|
+
- `Animation.rollOut()`
|
|
117
|
+
- `Animation.swing()`
|
|
118
|
+
|
|
119
|
+
### Attention Seekers & Effects
|
|
120
|
+
- `Animation.pulse()`
|
|
121
|
+
- `Animation.flash()`
|
|
122
|
+
- `Animation.shake()`
|
|
123
|
+
- `Animation.headShake()`
|
|
124
|
+
- `Animation.rubberBand()`
|
|
125
|
+
- `Animation.wobble()`
|
|
126
|
+
- `Animation.heartBeat()`
|
|
127
|
+
- `Animation.tada()`
|
|
128
|
+
- `Animation.jello()`
|
|
129
|
+
|
|
130
|
+
### Extrances & Exits
|
|
131
|
+
- `Animation.lightSpeedIn()`
|
|
132
|
+
- `Animation.lightSpeedOut()`
|
|
133
|
+
- `Animation.jackInTheBox()`
|
|
134
|
+
- `Animation.hinge()`
|
|
135
|
+
- `Animation.backInDown()`
|
|
136
|
+
- `Animation.backOutUp()`
|
|
137
|
+
|
|
138
|
+
### Special / Scroll-Driven
|
|
139
|
+
- `Animation.shimmer()` - Loading shimmer effect
|
|
140
|
+
- `Animation.typewriter()` - Typing effect
|
|
141
|
+
- `Animation.blinkCursor()`
|
|
142
|
+
- `Animation.handWaveScroll()`
|
|
143
|
+
- `Animation.ctaCollapseScroll()`
|
|
144
|
+
- `Animation.fillTextScroll()`
|
|
145
|
+
|
|
146
|
+
## 5. View Timeline Animations (Scroll-Driven)
|
|
147
|
+
|
|
148
|
+
There are two ways to create animations that trigger on scroll into view:
|
|
149
|
+
|
|
150
|
+
### 1. Using `animateOn="View"`
|
|
151
|
+
This works with any standard animation.
|
|
152
|
+
|
|
153
|
+
```jsx
|
|
154
|
+
<View animate={Animation.fadeIn()} animateOn="View" />
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Using `*OnView` Helper Functions
|
|
158
|
+
These are performant, pure CSS animations explicitly designed for entry/exit effects. Imported directly from `app-studio`.
|
|
159
|
+
|
|
160
|
+
```jsx
|
|
161
|
+
import {
|
|
162
|
+
fadeInOnView,
|
|
163
|
+
slideUpOnView,
|
|
164
|
+
scaleUpOnView,
|
|
165
|
+
blurInOnView,
|
|
166
|
+
rotateInOnView,
|
|
167
|
+
revealOnView,
|
|
168
|
+
flipXOnView,
|
|
169
|
+
flipYOnView
|
|
170
|
+
} from 'app-studio';
|
|
171
|
+
|
|
172
|
+
<View animate={fadeInOnView()} />
|
|
173
|
+
<View animate={slideUpOnView({ distance: '50px' })} />
|
|
174
|
+
<View animate={revealOnView()} /> // Clip-path reveal
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 6. Scroll Progress Animations
|
|
178
|
+
|
|
179
|
+
These animations are linked to the scroll position associated with a timeline (usually the nearest scroller). As you scroll active range, the animation progresses.
|
|
180
|
+
|
|
181
|
+
```jsx
|
|
182
|
+
// Text that fills efficiently as you scroll (requires CSS variable support)
|
|
183
|
+
<View animate={Animation.fillTextScroll()} />
|
|
184
|
+
|
|
185
|
+
// Image that unclips/expands as you scroll
|
|
186
|
+
<View animate={Animation.unclipScroll()} />
|
|
187
|
+
|
|
188
|
+
// Item that fades in based on scroll progress
|
|
189
|
+
<View animate={Animation.fadeInScroll()} />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 7. Event-Based Animations
|
|
193
|
+
|
|
194
|
+
You can trigger animations on interactions like hover, click, or focus using the `on` prop or underscore props (`_hover`, `_active`).
|
|
195
|
+
|
|
196
|
+
```jsx
|
|
197
|
+
<View
|
|
198
|
+
_hover={{
|
|
199
|
+
// Pulse animation while hovering
|
|
200
|
+
animate: Animation.pulse({ duration: '0.5s' }),
|
|
201
|
+
scale: 1.05
|
|
202
|
+
}}
|
|
203
|
+
|
|
204
|
+
on={{
|
|
205
|
+
click: {
|
|
206
|
+
animate: Animation.flash()
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
<Text>Hover or Click Me</Text>
|
|
211
|
+
</View>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## 8. Custom Animation Sequences
|
|
215
|
+
|
|
216
|
+
You can create complex animation sequences by configuring keyframes directly.
|
|
217
|
+
|
|
218
|
+
```jsx
|
|
219
|
+
const customTwist = {
|
|
220
|
+
from: { transform: 'rotate(0deg) scale(1)' },
|
|
221
|
+
'50%': { transform: 'rotate(180deg) scale(1.5)' },
|
|
222
|
+
to: { transform: 'rotate(360deg) scale(1)' },
|
|
223
|
+
duration: '2s',
|
|
224
|
+
iterationCount: 'infinite'
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
<View animate={customTwist} />
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 9. Best Practices
|
|
231
|
+
|
|
232
|
+
1. **Performance**: Prefer standard transforms (`translate`, `scale`, `rotate`) and `opacity`. Avoid animating layout properties like `width` or `margin`.
|
|
233
|
+
2. **Scroll Animations**: Use `animateOn="View"` or `*OnView` helpers for "reveal" effects, as they run on the compositor thread and don't require JavaScript listeners.
|
|
234
|
+
3. **Accessibility**: Respect user motion preferences.
|
|
235
|
+
4. **Composability**: You can mix standard styles with animations.
|
|
236
|
+
```jsx
|
|
237
|
+
<View
|
|
238
|
+
style={{ opacity: 0 }} // Initial state
|
|
239
|
+
animate={Animation.fadeIn({ delay: '0.5s', fillMode: 'forwards' })}
|
|
240
|
+
/>
|
|
241
|
+
```
|
|
@@ -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.
|
|
@@ -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.
|