@app-studio/web 0.9.57 → 0.9.60
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 +18 -1
- package/dist/components/ColorPicker/ColorPicker/ColorPicker.props.d.ts +1 -1
- package/dist/components/DragAndDrop/DragAndDrop/DragAndDrop.props.d.ts +1 -1
- package/dist/components/EmojiPicker/EmojiPicker/EmojiPicker.props.d.ts +1 -1
- 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/Slider/Slider/Slider.props.d.ts +1 -1
- package/dist/components/Title/Title/SlideEffect.d.ts +1 -0
- package/dist/components/Title/Title/Title.props.d.ts +0 -5
- package/dist/pages/title.page.d.ts +0 -3
- package/dist/web.cjs.development.js +238 -223
- 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 +238 -223
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +242 -226
- 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,135 @@
|
|
|
1
|
+
# Responsive Design with App-Studio
|
|
2
|
+
|
|
3
|
+
Creating a responsive design is an essential part of modern web development. In App-Studio, two primary features help you achieve this: `useResponsive` hook and the `media` prop. This document provides an overview and examples for both approaches.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Media Prop for Responsive Design
|
|
8
|
+
|
|
9
|
+
The `media` prop is particularly useful for managing responsive design without causing your components to re-render. You can specify different styles for various devices or screen sizes.
|
|
10
|
+
|
|
11
|
+
### Example
|
|
12
|
+
|
|
13
|
+
Here's a quick example to demonstrate its usage:
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { ResponsiveProvider, View } from 'app-studio';
|
|
18
|
+
|
|
19
|
+
const Example = () => {
|
|
20
|
+
return (
|
|
21
|
+
<View widthHeight={100}
|
|
22
|
+
media={{
|
|
23
|
+
mobile: {
|
|
24
|
+
backgroundColor: 'color.green',
|
|
25
|
+
},
|
|
26
|
+
tablet: {
|
|
27
|
+
backgroundColor: 'color.yellow',
|
|
28
|
+
},
|
|
29
|
+
xl: {
|
|
30
|
+
backgroundColor: 'color.blue',
|
|
31
|
+
},
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const App = () => (
|
|
38
|
+
<ResponsiveProvider
|
|
39
|
+
breakpoints={{
|
|
40
|
+
xs: 0,
|
|
41
|
+
sm: 340,
|
|
42
|
+
md: 560,
|
|
43
|
+
lg: 1080,
|
|
44
|
+
xl: 1300,
|
|
45
|
+
}}
|
|
46
|
+
devices={{
|
|
47
|
+
mobile: ['xs', 'sm'],
|
|
48
|
+
tablet: ['md', 'lg'],
|
|
49
|
+
desktop: ['lg', 'xl']
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<Example />
|
|
53
|
+
</ResponsiveProvider>
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `media` prop receives an object, where each key corresponds to a device type or screen size, and its value is another object describing the CSS to apply for that specific device.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 2. Using `useResponsive` Hook
|
|
62
|
+
|
|
63
|
+
The `useResponsive` hook provides you with screen size and device type information based on your defined breakpoints and devices.
|
|
64
|
+
|
|
65
|
+
### Example
|
|
66
|
+
|
|
67
|
+
Here's how you can use `useResponsive`:
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
import React from 'react';
|
|
71
|
+
import { ResponsiveProvider, View, useResponsive } from 'app-studio';
|
|
72
|
+
|
|
73
|
+
const Example = () => {
|
|
74
|
+
const { screen, on } = useResponsive();
|
|
75
|
+
|
|
76
|
+
const responsive = {
|
|
77
|
+
xs: {
|
|
78
|
+
backgroundColor: 'red',
|
|
79
|
+
},
|
|
80
|
+
sm: {
|
|
81
|
+
backgroundColor: 'green',
|
|
82
|
+
},
|
|
83
|
+
md: {
|
|
84
|
+
backgroundColor: 'blue',
|
|
85
|
+
},
|
|
86
|
+
lg: {
|
|
87
|
+
backgroundColor: 'yellow',
|
|
88
|
+
},
|
|
89
|
+
xl: {
|
|
90
|
+
backgroundColor: 'red',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<View widthHeight={100}
|
|
96
|
+
{...responsive[screen]}
|
|
97
|
+
>
|
|
98
|
+
{screen} - mobile : {on('mobile') ? 'yes' : 'no'}
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const App = () => (
|
|
104
|
+
<ResponsiveProvider
|
|
105
|
+
breakpoints={{
|
|
106
|
+
xs: 0,
|
|
107
|
+
sm: 340,
|
|
108
|
+
md: 560,
|
|
109
|
+
lg: 1080,
|
|
110
|
+
xl: 1300,
|
|
111
|
+
}}
|
|
112
|
+
devices={{
|
|
113
|
+
mobile: ['xs', 'sm'],
|
|
114
|
+
tablet: ['md', 'lg'],
|
|
115
|
+
desktop: ['lg', 'xl']
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<Example />
|
|
119
|
+
</ResponsiveProvider>
|
|
120
|
+
);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
In this example, `useResponsive` provides `screen` and `on`:
|
|
124
|
+
- `screen`: Gives you the current screen size based on your breakpoints.
|
|
125
|
+
- `on`: A function that returns `true` or `false` depending on whether the current screen size is included in the given device type.
|
|
126
|
+
|
|
127
|
+
It's important to note that `useResponsive` causes re-renders when the screen size changes, as it relies on React state updates. In contrast, the `media` prop avoids re-renders because it applies styles directly through CSS media queries. Choose the method that best suits your performance needs and design requirements.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
These can then be used to dynamically apply styles to your components, as demonstrated with the `responsive` object.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
By combining the `media` prop and `useResponsive`, you can create robust, efficient, and responsive designs with App-Studio.
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
# Theming with App-Studio
|
|
2
|
+
|
|
3
|
+
Theming is an essential part of any application. It allows you to maintain a consistent look and feel across your app. With App-Studio, theming becomes effortless through its `ThemeProvider` component. This document shows you how to set up theming in App-Studio.
|
|
4
|
+
|
|
5
|
+
## Available Colors Reference
|
|
6
|
+
|
|
7
|
+
App-Studio provides an extensive color system with three types of colors:
|
|
8
|
+
|
|
9
|
+
### 1. Singleton Colors (Basic Colors)
|
|
10
|
+
These are simple named colors accessible via `color.{name}`:
|
|
11
|
+
|
|
12
|
+
- **Basic Colors**: `white`, `black`, `red`, `green`, `blue`, `yellow`, `cyan`, `magenta`, `grey`, `orange`, `brown`, `purple`, `pink`, `lime`, `teal`, `navy`, `olive`, `maroon`, `gold`, `silver`, `indigo`, `violet`, `beige`, `turquoise`, `coral`, `chocolate`, `skyBlue`, `plum`, `darkGreen`, `salmon`
|
|
13
|
+
|
|
14
|
+
**Usage**: `color.white`, `color.gold`, `color.turquoise`
|
|
15
|
+
|
|
16
|
+
### 2. Color Palettes (Shaded Colors)
|
|
17
|
+
Each palette has 9 shades (50, 100, 200, 300, 400, 500, 600, 700, 800, 900) accessible via `color.{palette}.{shade}`:
|
|
18
|
+
|
|
19
|
+
**Available Palettes**:
|
|
20
|
+
- **Alpha Channels**: `whiteAlpha`, `blackAlpha` - RGBA colors with varying opacity
|
|
21
|
+
- **Neutrals**: `white`, `black`, `gray`, `dark`, `light`, `warmGray`, `trueGray`, `coolGray`, `blueGray`
|
|
22
|
+
- **Reds & Pinks**: `rose`, `pink`, `red`
|
|
23
|
+
- **Purples**: `fuchsia`, `purple`, `violet`
|
|
24
|
+
- **Blues**: `indigo`, `blue`, `lightBlue`, `cyan`
|
|
25
|
+
- **Greens**: `teal`, `emerald`, `green`, `lime`
|
|
26
|
+
- **Yellows & Oranges**: `yellow`, `amber`, `orange`
|
|
27
|
+
|
|
28
|
+
**Usage**: `color.blue.500`, `color.rose.200`, `color.gray.800`
|
|
29
|
+
|
|
30
|
+
### 3. Theme Colors
|
|
31
|
+
Custom theme colors defined in your theme configuration, accessible via `theme.{path}`:
|
|
32
|
+
|
|
33
|
+
**Default Theme Colors**:
|
|
34
|
+
- `theme.primary` - Main brand color (default: black)
|
|
35
|
+
- `theme.secondary` - Secondary brand color (default: blue)
|
|
36
|
+
- `theme.success` - Success state color (default: green.500)
|
|
37
|
+
- `theme.error` - Error state color (default: red.500)
|
|
38
|
+
- `theme.warning` - Warning state color (default: orange.500)
|
|
39
|
+
- `theme.disabled` - Disabled state color (default: gray.500)
|
|
40
|
+
- `theme.loading` - Loading state color (default: dark.500)
|
|
41
|
+
|
|
42
|
+
You can extend these with custom theme paths like `theme.button.background` or `theme.header.text`.
|
|
43
|
+
|
|
44
|
+
### 4. Mode-Specific Colors
|
|
45
|
+
Access light or dark mode colors directly, regardless of current theme:
|
|
46
|
+
|
|
47
|
+
- **Light Mode**: `light.{colorName}` or `light.{palette}.{shade}`
|
|
48
|
+
- **Dark Mode**: `dark.{colorName}` or `dark.{palette}.{shade}`
|
|
49
|
+
|
|
50
|
+
**Usage**: `light.white`, `dark.blue.500`, `light.gray.100`
|
|
51
|
+
|
|
52
|
+
### Color System Hierarchy
|
|
53
|
+
```
|
|
54
|
+
color.* → Direct color access (current theme mode)
|
|
55
|
+
├─ color.white → Singleton colors
|
|
56
|
+
└─ color.blue.500 → Palette colors with shades
|
|
57
|
+
|
|
58
|
+
theme.* → Custom theme configuration
|
|
59
|
+
├─ theme.primary
|
|
60
|
+
└─ theme.button.background
|
|
61
|
+
|
|
62
|
+
light.* → Always use light mode colors
|
|
63
|
+
├─ light.white
|
|
64
|
+
└─ light.blue.500
|
|
65
|
+
|
|
66
|
+
dark.* → Always use dark mode colors
|
|
67
|
+
├─ dark.white
|
|
68
|
+
└─ dark.red.200
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Setting up the Theme Object
|
|
72
|
+
|
|
73
|
+
First, define a theme object that contains the properties you'd like to customize, such as colors and palettes. This object can be as simple or as complex as your needs require.
|
|
74
|
+
|
|
75
|
+
Here's an example:
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const theme = {
|
|
79
|
+
main:{
|
|
80
|
+
primary: '#fff7ed'
|
|
81
|
+
},
|
|
82
|
+
components: {
|
|
83
|
+
button:{
|
|
84
|
+
background: '#fff7ed'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const colors = {
|
|
90
|
+
main:{
|
|
91
|
+
blue: '#94a3b8'
|
|
92
|
+
},
|
|
93
|
+
palette: {
|
|
94
|
+
blueGray: {
|
|
95
|
+
50: '#f8fafc',
|
|
96
|
+
100: '#f1f5f9',
|
|
97
|
+
200: '#e2e8f0',
|
|
98
|
+
300: '#cbd5e1',
|
|
99
|
+
400: '#94a3b8',
|
|
100
|
+
500: '#64748b',
|
|
101
|
+
600: '#475569',
|
|
102
|
+
700: '#334155',
|
|
103
|
+
800: '#1e293b',
|
|
104
|
+
900: '#0f172a'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Using `ThemeProvider`
|
|
111
|
+
|
|
112
|
+
Wrap your application's root component with `ThemeProvider` and pass the theme object as a prop. This will make the theme available to all child components.
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { ThemeProvider, View } from 'app-studio';
|
|
116
|
+
|
|
117
|
+
// ...
|
|
118
|
+
|
|
119
|
+
function App() {
|
|
120
|
+
return (
|
|
121
|
+
<ThemeProvider theme={theme} colors={colors}>
|
|
122
|
+
{/* The rest of your app */}
|
|
123
|
+
</ThemeProvider>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Using the Theme in Components
|
|
129
|
+
|
|
130
|
+
Now that the theme is available, you can use it in your components. All color references are resolved automatically based on the current theme mode.
|
|
131
|
+
|
|
132
|
+
### Color Reference Formats
|
|
133
|
+
|
|
134
|
+
App-Studio supports multiple ways to reference colors:
|
|
135
|
+
|
|
136
|
+
1. **Direct Color Values**: `"#fff"`, `"rgb(255,0,0)"`, `"transparent"`
|
|
137
|
+
2. **Singleton Colors**: `"color.white"`, `"color.gold"`, `"color.turquoise"`
|
|
138
|
+
3. **Palette Colors**: `"color.blue.500"`, `"color.rose.200"`, `"color.gray.800"`
|
|
139
|
+
4. **Theme Colors**: `"theme.primary"`, `"theme.button.background"`
|
|
140
|
+
5. **Mode-Specific Colors**: `"light.white"`, `"dark.blue.500"`
|
|
141
|
+
|
|
142
|
+
### Examples
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
import { View, Text } from 'app-studio';
|
|
146
|
+
import { Button } from '@app-studio/web';
|
|
147
|
+
|
|
148
|
+
function Example() {
|
|
149
|
+
return (
|
|
150
|
+
<View backgroundColor="color.blue">
|
|
151
|
+
{/* Using palette colors with shades */}
|
|
152
|
+
<View backgroundColor="color.blueGray.500">
|
|
153
|
+
<Text color="theme.primary">Hello</Text>
|
|
154
|
+
</View>
|
|
155
|
+
|
|
156
|
+
{/* Using theme colors */}
|
|
157
|
+
<Button backgroundColor="theme.button.background">Hello</Button>
|
|
158
|
+
|
|
159
|
+
{/* Using singleton colors */}
|
|
160
|
+
<View backgroundColor="color.turquoise" padding={10}>
|
|
161
|
+
<Text color="color.white">Turquoise Background</Text>
|
|
162
|
+
</View>
|
|
163
|
+
|
|
164
|
+
{/* Using alpha colors for transparency */}
|
|
165
|
+
<View backgroundColor="color.blackAlpha.500">
|
|
166
|
+
<Text color="color.whiteAlpha.900">Semi-transparent</Text>
|
|
167
|
+
</View>
|
|
168
|
+
</View>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### All Available Color Palettes
|
|
174
|
+
|
|
175
|
+
Each palette below has shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900
|
|
176
|
+
|
|
177
|
+
**Alpha Transparency**:
|
|
178
|
+
- `color.whiteAlpha.{shade}` - White with alpha (rgba)
|
|
179
|
+
- `color.blackAlpha.{shade}` - Black with alpha (rgba)
|
|
180
|
+
|
|
181
|
+
**Neutral Colors**:
|
|
182
|
+
- `color.white.{shade}` - White to light gray scale
|
|
183
|
+
- `color.black.{shade}` - Black to dark gray scale
|
|
184
|
+
- `color.gray.{shade}` - True gray scale
|
|
185
|
+
- `color.dark.{shade}` - Dark neutral scale
|
|
186
|
+
- `color.light.{shade}` - Light neutral scale
|
|
187
|
+
- `color.warmGray.{shade}` - Warm gray tones
|
|
188
|
+
- `color.trueGray.{shade}` - True neutral gray
|
|
189
|
+
- `color.coolGray.{shade}` - Cool gray tones
|
|
190
|
+
- `color.blueGray.{shade}` - Blue-tinted gray
|
|
191
|
+
|
|
192
|
+
**Red & Pink Family**:
|
|
193
|
+
- `color.rose.{shade}` - Rose pink tones
|
|
194
|
+
- `color.pink.{shade}` - Pink tones
|
|
195
|
+
- `color.red.{shade}` - Red tones
|
|
196
|
+
|
|
197
|
+
**Purple Family**:
|
|
198
|
+
- `color.fuchsia.{shade}` - Bright purple-pink
|
|
199
|
+
- `color.purple.{shade}` - Purple tones
|
|
200
|
+
- `color.violet.{shade}` - Violet tones
|
|
201
|
+
|
|
202
|
+
**Blue Family**:
|
|
203
|
+
- `color.indigo.{shade}` - Deep blue-purple
|
|
204
|
+
- `color.blue.{shade}` - Blue tones
|
|
205
|
+
- `color.lightBlue.{shade}` - Light blue tones
|
|
206
|
+
- `color.cyan.{shade}` - Cyan tones
|
|
207
|
+
|
|
208
|
+
**Green Family**:
|
|
209
|
+
- `color.teal.{shade}` - Teal (blue-green)
|
|
210
|
+
- `color.emerald.{shade}` - Emerald green
|
|
211
|
+
- `color.green.{shade}` - Green tones
|
|
212
|
+
- `color.lime.{shade}` - Lime green
|
|
213
|
+
|
|
214
|
+
**Yellow & Orange Family**:
|
|
215
|
+
- `color.yellow.{shade}` - Yellow tones
|
|
216
|
+
- `color.amber.{shade}` - Amber (orange-yellow)
|
|
217
|
+
- `color.orange.{shade}` - Orange tones
|
|
218
|
+
|
|
219
|
+
### Accessing Specific Theme Mode Colors
|
|
220
|
+
|
|
221
|
+
You can directly access colors from a specific theme mode regardless of the current theme mode using the `light.` or `dark.` prefix:
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
import { View, Text } from 'app-studio';
|
|
225
|
+
|
|
226
|
+
function Example() {
|
|
227
|
+
return (
|
|
228
|
+
<View>
|
|
229
|
+
{/* Always use light mode white color regardless of current theme mode */}
|
|
230
|
+
<Text color="light.white">Always light mode white</Text>
|
|
231
|
+
|
|
232
|
+
{/* Always use dark mode red.200 color regardless of current theme mode */}
|
|
233
|
+
<View backgroundColor="dark.red.200">
|
|
234
|
+
<Text>Always dark mode red.200 background</Text>
|
|
235
|
+
</View>
|
|
236
|
+
</View>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This is useful when you need to access a specific theme mode's color regardless of the current theme setting.
|
|
242
|
+
|
|
243
|
+
### Direct Theme Color Access
|
|
244
|
+
|
|
245
|
+
App-Studio allows you to directly call theme colors using a simple dot notation format. This makes your code more readable and maintainable:
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
import { View, Text } from 'app-studio';
|
|
249
|
+
|
|
250
|
+
function Example() {
|
|
251
|
+
return (
|
|
252
|
+
<View>
|
|
253
|
+
{/* Access light theme colors directly */}
|
|
254
|
+
<Text color="light.white">White text in light mode</Text>
|
|
255
|
+
<View backgroundColor="light.blue.500">
|
|
256
|
+
<Text>Light blue background</Text>
|
|
257
|
+
</View>
|
|
258
|
+
|
|
259
|
+
{/* Access dark theme colors directly */}
|
|
260
|
+
<Text color="dark.white">White text in dark mode</Text>
|
|
261
|
+
<View backgroundColor="dark.red.200">
|
|
262
|
+
<Text>Dark red background</Text>
|
|
263
|
+
</View>
|
|
264
|
+
|
|
265
|
+
{/* Mix and match in the same component */}
|
|
266
|
+
<View
|
|
267
|
+
backgroundColor="light.gray.100"
|
|
268
|
+
borderColor="dark.gray.800"
|
|
269
|
+
borderWidth={1}
|
|
270
|
+
>
|
|
271
|
+
<Text>Mixed theme colors</Text>
|
|
272
|
+
</View>
|
|
273
|
+
</View>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
This direct access syntax works with all color-related properties and can be used with both singleton colors (like `white`, `black`) and palette colors (like `red.200`, `blue.500`). It provides a convenient way to reference specific theme colors without having to use the `getColor` function from the `useTheme` hook.
|
|
279
|
+
|
|
280
|
+
### Smart Text Contrast
|
|
281
|
+
|
|
282
|
+
For text that needs to be visible on any background color (light, dark, or dynamic gradients), App-Studio provides a smart contrast feature.
|
|
283
|
+
|
|
284
|
+
**Default Behavior:** If you do **not** specify a `color` prop on a `Text` or `Element` component, it automatically applies `mix-blend-mode: difference` and sets the color to `white`. This intelligently inverts the text color based on the background behind it, ensuring visibility.
|
|
285
|
+
|
|
286
|
+
**Explicit Control:** You can also force this behavior by explicitly setting the `blend` prop to `true`, even if a color is specified (though the color will be overridden to white for the blend calculation).
|
|
287
|
+
|
|
288
|
+
This is particularly useful for:
|
|
289
|
+
- Text over images or videos
|
|
290
|
+
- Components that need to work in both light and dark modes without specific color overrides
|
|
291
|
+
- Text over gradients where the background lightness varies
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
import { View, Text } from 'app-studio';
|
|
295
|
+
|
|
296
|
+
function SmartTextExample() {
|
|
297
|
+
return (
|
|
298
|
+
<View>
|
|
299
|
+
{/* Automatically becomes white on black background (no color specified) */}
|
|
300
|
+
<View backgroundColor="black" padding={20}>
|
|
301
|
+
<Text>Visible on Black</Text>
|
|
302
|
+
</View>
|
|
303
|
+
|
|
304
|
+
{/* Automatically becomes black on white background (no color specified) */}
|
|
305
|
+
<View backgroundColor="white" padding={20}>
|
|
306
|
+
<Text>Visible on White</Text>
|
|
307
|
+
</View>
|
|
308
|
+
|
|
309
|
+
{/* Works on colored backgrounds too */}
|
|
310
|
+
<View backgroundColor="red" padding={20}>
|
|
311
|
+
<Text>Visible on Red</Text>
|
|
312
|
+
</View>
|
|
313
|
+
|
|
314
|
+
{/* And gradients! */}
|
|
315
|
+
<View
|
|
316
|
+
style={{ background: 'linear-gradient(90deg, #ffffff 0%, #000000 100%)' }}
|
|
317
|
+
padding={20}
|
|
318
|
+
>
|
|
319
|
+
<Text fontWeight="bold">
|
|
320
|
+
Smart Text Across Gradient
|
|
321
|
+
</Text>
|
|
322
|
+
</View>
|
|
323
|
+
|
|
324
|
+
{/* Explicitly disabling it by setting a color */}
|
|
325
|
+
<View backgroundColor="white" padding={20}>
|
|
326
|
+
<Text color="black">Standard Black Text (No Blend)</Text>
|
|
327
|
+
</View>
|
|
328
|
+
</View>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Complete Example
|
|
334
|
+
|
|
335
|
+
Here's a complete example demonstrating all color reference methods:
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
import React from 'react';
|
|
339
|
+
import { ThemeProvider, View, Text, Button } from 'app-studio';
|
|
340
|
+
|
|
341
|
+
// Custom theme configuration
|
|
342
|
+
const theme = {
|
|
343
|
+
main: {
|
|
344
|
+
primary: 'color.blue.600', // References a palette color
|
|
345
|
+
secondary: 'color.purple.500',
|
|
346
|
+
accent: 'color.orange.400'
|
|
347
|
+
},
|
|
348
|
+
components: {
|
|
349
|
+
button: {
|
|
350
|
+
background: 'color.emerald.500',
|
|
351
|
+
text: 'color.white',
|
|
352
|
+
disabled: 'color.gray.400'
|
|
353
|
+
},
|
|
354
|
+
card: {
|
|
355
|
+
background: 'color.white',
|
|
356
|
+
border: 'color.gray.200'
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// Custom color overrides (optional)
|
|
362
|
+
const customColors = {
|
|
363
|
+
main: {
|
|
364
|
+
brand: '#0066cc', // Custom singleton color
|
|
365
|
+
blue: '#1e40af' // Override default blue
|
|
366
|
+
},
|
|
367
|
+
palette: {
|
|
368
|
+
// Override or add custom palettes
|
|
369
|
+
custom: {
|
|
370
|
+
50: '#f0f9ff',
|
|
371
|
+
100: '#e0f2fe',
|
|
372
|
+
200: '#bae6fd',
|
|
373
|
+
300: '#7dd3fc',
|
|
374
|
+
400: '#38bdf8',
|
|
375
|
+
500: '#0ea5e9',
|
|
376
|
+
600: '#0284c7',
|
|
377
|
+
700: '#0369a1',
|
|
378
|
+
800: '#075985',
|
|
379
|
+
900: '#0c4a6e'
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
function Example() {
|
|
385
|
+
return (
|
|
386
|
+
<ThemeProvider theme={theme} colors={customColors} mode="light">
|
|
387
|
+
{/* Using theme colors */}
|
|
388
|
+
<View backgroundColor="theme.components.card.background" padding={20}>
|
|
389
|
+
<Text color="theme.main.primary" fontSize={24}>
|
|
390
|
+
Primary Theme Color
|
|
391
|
+
</Text>
|
|
392
|
+
|
|
393
|
+
{/* Using palette colors directly */}
|
|
394
|
+
<View backgroundColor="color.rose.100" padding={10} marginTop={10}>
|
|
395
|
+
<Text color="color.rose.900">Rose palette color</Text>
|
|
396
|
+
</View>
|
|
397
|
+
|
|
398
|
+
{/* Using singleton colors */}
|
|
399
|
+
<View backgroundColor="color.turquoise" padding={10} marginTop={10}>
|
|
400
|
+
<Text color="color.white">Turquoise singleton</Text>
|
|
401
|
+
</View>
|
|
402
|
+
|
|
403
|
+
{/* Using custom colors */}
|
|
404
|
+
<View backgroundColor="color.brand" padding={10} marginTop={10}>
|
|
405
|
+
<Text color="color.white">Custom brand color</Text>
|
|
406
|
+
</View>
|
|
407
|
+
|
|
408
|
+
{/* Using mode-specific colors */}
|
|
409
|
+
<View backgroundColor="light.gray.100" padding={10} marginTop={10}>
|
|
410
|
+
<Text color="dark.gray.900">Always light background, dark text</Text>
|
|
411
|
+
</View>
|
|
412
|
+
|
|
413
|
+
{/* Using alpha transparency */}
|
|
414
|
+
<View backgroundColor="color.blackAlpha.500" padding={10} marginTop={10}>
|
|
415
|
+
<Text color="color.whiteAlpha.900">Semi-transparent overlay</Text>
|
|
416
|
+
</View>
|
|
417
|
+
|
|
418
|
+
{/* Button using theme */}
|
|
419
|
+
<Button
|
|
420
|
+
backgroundColor="theme.components.button.background"
|
|
421
|
+
color="theme.components.button.text"
|
|
422
|
+
>
|
|
423
|
+
Themed Button
|
|
424
|
+
</Button>
|
|
425
|
+
</View>
|
|
426
|
+
</ThemeProvider>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Quick Reference for AI Agents
|
|
432
|
+
|
|
433
|
+
When working with colors in App-Studio, use these patterns:
|
|
434
|
+
|
|
435
|
+
### Color Access Patterns
|
|
436
|
+
```javascript
|
|
437
|
+
// Pattern: color.{name}
|
|
438
|
+
"color.white" // → "#FFFFFF" (in light mode) or "#000000" (in dark mode)
|
|
439
|
+
"color.gold" // → "#FFD700"
|
|
440
|
+
"color.turquoise" // → "#40E0D0"
|
|
441
|
+
|
|
442
|
+
// Pattern: color.{palette}.{shade}
|
|
443
|
+
"color.blue.500" // → "#3b82f6" (light) or "#60a5fa" (dark)
|
|
444
|
+
"color.rose.200" // → "#fecdd3" (light) or "#6b112f" (dark)
|
|
445
|
+
"color.gray.800" // → "#27272a" (light) or "#f4f4f5" (dark)
|
|
446
|
+
|
|
447
|
+
// Pattern: theme.{path}
|
|
448
|
+
"theme.primary" // → Resolves to your theme's primary color
|
|
449
|
+
"theme.button.background" // → Resolves to nested theme path
|
|
450
|
+
|
|
451
|
+
// Pattern: light.{name} or light.{palette}.{shade}
|
|
452
|
+
"light.white" // → Always "#FFFFFF" (light mode)
|
|
453
|
+
"light.blue.500" // → Always "#3b82f6" (light mode value)
|
|
454
|
+
|
|
455
|
+
// Pattern: dark.{name} or dark.{palette}.{shade}
|
|
456
|
+
"dark.white" // → Always "#000000" (dark mode white)
|
|
457
|
+
"dark.red.200" // → Always "#6b112f" (dark mode value)
|
|
458
|
+
|
|
459
|
+
// Direct values (unchanged)
|
|
460
|
+
"#ff0000" // → "#ff0000"
|
|
461
|
+
"rgb(255, 0, 0)" // → "rgb(255, 0, 0)"
|
|
462
|
+
"transparent" // → "transparent"
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Available Singleton Colors (30 total)
|
|
466
|
+
```
|
|
467
|
+
white, black, red, green, blue, yellow, cyan, magenta, grey, orange,
|
|
468
|
+
brown, purple, pink, lime, teal, navy, olive, maroon, gold, silver,
|
|
469
|
+
indigo, violet, beige, turquoise, coral, chocolate, skyBlue, plum,
|
|
470
|
+
darkGreen, salmon
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Available Color Palettes (30 total)
|
|
474
|
+
```
|
|
475
|
+
whiteAlpha, blackAlpha, white, black, rose, pink, fuchsia, purple,
|
|
476
|
+
violet, indigo, blue, lightBlue, cyan, teal, emerald, green, lime,
|
|
477
|
+
yellow, amber, orange, red, warmGray, trueGray, gray, dark, light,
|
|
478
|
+
coolGray, blueGray
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### Shades Available
|
|
482
|
+
Each palette has these shades: `50, 100, 200, 300, 400, 500, 600, 700, 800, 900`
|
|
483
|
+
|
|
484
|
+
### Theme Mode Behavior
|
|
485
|
+
- **Light Mode**: Uses `defaultLightPalette` and `defaultLightColors`
|
|
486
|
+
- **Dark Mode**: Uses `defaultDarkPalette` and `defaultDarkColors`
|
|
487
|
+
- Colors automatically switch based on `themeMode` unless using `light.*` or `dark.*` prefix
|
|
488
|
+
- Color values are inverted for dark mode (e.g., `color.white` becomes black in dark mode)
|
|
@@ -78,7 +78,7 @@ export const DefaultDemo = () => (
|
|
|
78
78
|
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=400&fit=crop"
|
|
79
79
|
height="200px"
|
|
80
80
|
backgroundSize="cover"
|
|
81
|
-
|
|
81
|
+
overlay={<Background.Overlay />}
|
|
82
82
|
blendMode="multiply"
|
|
83
83
|
>
|
|
84
84
|
<Text color="white" fontSize={18} fontWeight="500">
|
|
@@ -111,7 +111,7 @@ export const DefaultDemo = () => (
|
|
|
111
111
|
<Background.Video
|
|
112
112
|
src="https://www.w3schools.com/html/mov_bbb.mp4"
|
|
113
113
|
height="200px"
|
|
114
|
-
|
|
114
|
+
overlay={<Background.Overlay />}
|
|
115
115
|
>
|
|
116
116
|
<Text color="white" fontSize={18} fontWeight="500">
|
|
117
117
|
Video Background
|