app-studio 0.6.21 → 0.6.24
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/app-studio.cjs.development.js +31 -2
- 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 +31 -3
- package/dist/app-studio.esm.js.map +1 -1
- package/dist/app-studio.umd.development.js +31 -2
- 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 +2 -2
- package/dist/components/Image.d.ts +1 -1
- package/dist/element/Element.d.ts +2 -0
- package/dist/element/css.d.ts +19 -0
- 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,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.
|
package/docs/Theming.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
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
|
+
## Setting up the Theme Object
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
Here's an example:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const theme = {
|
|
13
|
+
main:{
|
|
14
|
+
primary: '#fff7ed'
|
|
15
|
+
},
|
|
16
|
+
components: {
|
|
17
|
+
button:{
|
|
18
|
+
background: '#fff7ed'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const colors = {
|
|
24
|
+
main:{
|
|
25
|
+
blue: '#94a3b8'
|
|
26
|
+
},
|
|
27
|
+
palette: {
|
|
28
|
+
blueGray: {
|
|
29
|
+
50: '#f8fafc',
|
|
30
|
+
100: '#f1f5f9',
|
|
31
|
+
200: '#e2e8f0',
|
|
32
|
+
300: '#cbd5e1',
|
|
33
|
+
400: '#94a3b8',
|
|
34
|
+
500: '#64748b',
|
|
35
|
+
600: '#475569',
|
|
36
|
+
700: '#334155',
|
|
37
|
+
800: '#1e293b',
|
|
38
|
+
900: '#0f172a'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Using `ThemeProvider`
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import { ThemeProvider, View } from 'app-studio';
|
|
50
|
+
|
|
51
|
+
// ...
|
|
52
|
+
|
|
53
|
+
function App() {
|
|
54
|
+
return (
|
|
55
|
+
<ThemeProvider theme={theme} colors={colors}>
|
|
56
|
+
{/* The rest of your app */}
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Using the Theme in Components
|
|
63
|
+
|
|
64
|
+
Now that the theme is available, you can use it in your components. For example, any component that accepts `color` or `backgroundColor` props will use the values from the theme.
|
|
65
|
+
|
|
66
|
+
Here's an example of how you might set the background color for a `View` and text color for a `Text` component:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { View, Text } from 'app-studio';
|
|
70
|
+
import { Button } from '@app-studio/web';
|
|
71
|
+
|
|
72
|
+
function Example() {
|
|
73
|
+
return (
|
|
74
|
+
<View backgroundColor="color.blue">
|
|
75
|
+
<View backgroundColor="color.blueGray.500">
|
|
76
|
+
<Text color="theme.primary">Hello</Text>
|
|
77
|
+
</View>
|
|
78
|
+
<Button backgroundColor="theme.button.background">Hello</Button>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Notice how the `backgroundColor` and `color` props use values defined in the theme object.
|
|
85
|
+
|
|
86
|
+
### Accessing Specific Theme Mode Colors
|
|
87
|
+
|
|
88
|
+
You can directly access colors from a specific theme mode regardless of the current theme mode using the `light.` or `dark.` prefix:
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
import { View, Text } from 'app-studio';
|
|
92
|
+
|
|
93
|
+
function Example() {
|
|
94
|
+
return (
|
|
95
|
+
<View>
|
|
96
|
+
{/* Always use light mode white color regardless of current theme mode */}
|
|
97
|
+
<Text color="light.white">Always light mode white</Text>
|
|
98
|
+
|
|
99
|
+
{/* Always use dark mode red.200 color regardless of current theme mode */}
|
|
100
|
+
<View backgroundColor="dark.red.200">
|
|
101
|
+
<Text>Always dark mode red.200 background</Text>
|
|
102
|
+
</View>
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This is useful when you need to access a specific theme mode's color regardless of the current theme setting.
|
|
109
|
+
|
|
110
|
+
### Direct Theme Color Access
|
|
111
|
+
|
|
112
|
+
App-Studio allows you to directly call theme colors using a simple dot notation format. This makes your code more readable and maintainable:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { View, Text } from 'app-studio';
|
|
116
|
+
|
|
117
|
+
function Example() {
|
|
118
|
+
return (
|
|
119
|
+
<View>
|
|
120
|
+
{/* Access light theme colors directly */}
|
|
121
|
+
<Text color="light.white">White text in light mode</Text>
|
|
122
|
+
<View backgroundColor="light.blue.500">
|
|
123
|
+
<Text>Light blue background</Text>
|
|
124
|
+
</View>
|
|
125
|
+
|
|
126
|
+
{/* Access dark theme colors directly */}
|
|
127
|
+
<Text color="dark.white">White text in dark mode</Text>
|
|
128
|
+
<View backgroundColor="dark.red.200">
|
|
129
|
+
<Text>Dark red background</Text>
|
|
130
|
+
</View>
|
|
131
|
+
|
|
132
|
+
{/* Mix and match in the same component */}
|
|
133
|
+
<View
|
|
134
|
+
backgroundColor="light.gray.100"
|
|
135
|
+
borderColor="dark.gray.800"
|
|
136
|
+
borderWidth={1}
|
|
137
|
+
>
|
|
138
|
+
<Text>Mixed theme colors</Text>
|
|
139
|
+
</View>
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
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.
|
|
146
|
+
|
|
147
|
+
## Complete Example
|
|
148
|
+
|
|
149
|
+
Here's a complete example that ties it all together:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
import React from 'react';
|
|
153
|
+
import { ThemeProvider, View, Text, Button } from 'app-studio';
|
|
154
|
+
|
|
155
|
+
const theme = {
|
|
156
|
+
main:{
|
|
157
|
+
primary: '#fff7ed'
|
|
158
|
+
},
|
|
159
|
+
components: {
|
|
160
|
+
button:{
|
|
161
|
+
background: '#fff7ed'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const colors = {
|
|
167
|
+
main:{
|
|
168
|
+
blue: '#94a3b8'
|
|
169
|
+
},
|
|
170
|
+
palette: {
|
|
171
|
+
blueGray: {
|
|
172
|
+
50: '#f8fafc',
|
|
173
|
+
100: '#f1f5f9',
|
|
174
|
+
200: '#e2e8f0',
|
|
175
|
+
300: '#cbd5e1',
|
|
176
|
+
400: '#94a3b8',
|
|
177
|
+
500: '#64748b',
|
|
178
|
+
600: '#475569',
|
|
179
|
+
700: '#334155',
|
|
180
|
+
800: '#1e293b',
|
|
181
|
+
900: '#0f172a'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function Example() {
|
|
187
|
+
return (
|
|
188
|
+
<ThemeProvider theme={theme} colors={colors}>
|
|
189
|
+
<View backgroundColor="color.blue">
|
|
190
|
+
<View backgroundColor="color.blueGray.500">
|
|
191
|
+
<Text color="theme.primary">Hello</Text>
|
|
192
|
+
</View>
|
|
193
|
+
<Button backgroundColor="theme.button.background">Hello</Button>
|
|
194
|
+
</View>
|
|
195
|
+
</ThemeProvider>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
By using the `ThemeProvider` and the theme object, you can now maintain a consistent and easily customizable UI across your application.
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.24",
|
|
3
3
|
"name": "app-studio",
|
|
4
4
|
"description": "App Studio is a responsive and themeable framework to build cross platform applications",
|
|
5
5
|
"repository": "git@github.com:rize-network/app-studio.git",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
-
"codemod"
|
|
24
|
+
"codemod",
|
|
25
|
+
"docs"
|
|
25
26
|
],
|
|
26
27
|
"engines": {
|
|
27
28
|
"node": ">=10"
|