@app-studio/web 0.9.17 → 0.9.19
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/AuthGuard/index.d.ts +1 -1
- package/dist/utils/request.d.ts +2 -2
- package/dist/web.cjs.development.js +41 -46
- 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 +43 -48
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +45 -45
- 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/README.md +52 -0
- package/docs/adk-components.md +316 -0
- package/docs/adk-quick-start.md +294 -0
- package/docs/api-integration.md +801 -0
- package/docs/api-reference/README.md +103 -0
- package/docs/api-reference/data-display/flow.md +220 -0
- package/docs/api-reference/data-display/tree.md +210 -0
- package/docs/api-reference/form/chat-input.md +210 -0
- package/docs/api-reference/utility/button.md +145 -0
- package/docs/api-reference/utility/title.md +301 -0
- package/docs/app-studio.md +302 -0
- package/docs/component-development/guide.md +546 -0
- package/docs/contributing/documentation.md +153 -0
- package/docs/conventions.md +536 -0
- package/docs/design-system/theming.md +299 -0
- package/docs/documentation-system.md +143 -0
- package/docs/getting-started/component-usage.md +211 -0
- package/docs/getting-started/introduction.md +114 -0
- package/docs/guide.md +550 -0
- package/docs/integration-guide.md +449 -0
- package/docs/tutorials/README.md +51 -0
- package/docs/tutorials/basic/creating-a-simple-form.md +566 -0
- package/package.json +3 -2
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Theming Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to use and customize the theming system in the App Studio Web Component Library.
|
|
4
|
+
|
|
5
|
+
## Theme System Overview
|
|
6
|
+
|
|
7
|
+
The App Studio Web Component Library uses a theme system that provides consistent styling across all components. The theme includes:
|
|
8
|
+
|
|
9
|
+
- Color palette
|
|
10
|
+
- Typography
|
|
11
|
+
- Spacing
|
|
12
|
+
- Shapes
|
|
13
|
+
- Shadows
|
|
14
|
+
- Transitions
|
|
15
|
+
|
|
16
|
+
## Theme Provider
|
|
17
|
+
|
|
18
|
+
The `ThemeProvider` component is used to provide theme context to all components:
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import { ThemeProvider } from 'app-studio';
|
|
23
|
+
import { Button, Text } from '@app-studio/web';
|
|
24
|
+
|
|
25
|
+
function App() {
|
|
26
|
+
return (
|
|
27
|
+
<ThemeProvider theme={{ mode: 'light' }}>
|
|
28
|
+
<Text>Themed content</Text>
|
|
29
|
+
<Button>Themed button</Button>
|
|
30
|
+
</ThemeProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Theme Modes
|
|
36
|
+
|
|
37
|
+
The library supports light and dark theme modes:
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
import React from 'react';
|
|
41
|
+
import { ThemeProvider } from 'app-studio';
|
|
42
|
+
import { Button } from '@app-studio/web';
|
|
43
|
+
|
|
44
|
+
function App() {
|
|
45
|
+
return (
|
|
46
|
+
<ThemeProvider theme={{ mode: 'dark' }}>
|
|
47
|
+
<Button>Dark theme button</Button>
|
|
48
|
+
</ThemeProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can also override the theme mode for specific components:
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
import React from 'react';
|
|
57
|
+
import { ThemeProvider } from 'app-studio';
|
|
58
|
+
import { Button } from '@app-studio/web';
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<ThemeProvider theme={{ mode: 'light' }}>
|
|
63
|
+
<Button>Light theme button</Button>
|
|
64
|
+
<Button themeMode="dark">Dark theme button</Button>
|
|
65
|
+
</ThemeProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Using Theme Values
|
|
71
|
+
|
|
72
|
+
Within components, you can access theme values using the `useTheme` hook:
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import React from 'react';
|
|
76
|
+
import { View, useTheme } from 'app-studio';
|
|
77
|
+
|
|
78
|
+
function ThemedComponent() {
|
|
79
|
+
const { getColor, themeMode } = useTheme();
|
|
80
|
+
|
|
81
|
+
const primaryColor = getColor('theme.primary', { themeMode });
|
|
82
|
+
const textColor = getColor('theme.text', { themeMode });
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<View backgroundColor={primaryColor} color={textColor}>
|
|
86
|
+
Themed content
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Theme Color Reference
|
|
93
|
+
|
|
94
|
+
The theme includes the following color categories:
|
|
95
|
+
|
|
96
|
+
### Semantic Colors
|
|
97
|
+
|
|
98
|
+
- `theme.primary`: Primary brand color
|
|
99
|
+
- `theme.secondary`: Secondary brand color
|
|
100
|
+
- `theme.success`: Success state color
|
|
101
|
+
- `theme.warning`: Warning state color
|
|
102
|
+
- `theme.error`: Error state color
|
|
103
|
+
- `theme.info`: Information state color
|
|
104
|
+
- `theme.disabled`: Disabled state color
|
|
105
|
+
|
|
106
|
+
### Neutral Colors
|
|
107
|
+
|
|
108
|
+
- `color.white`: White
|
|
109
|
+
- `color.black`: Black
|
|
110
|
+
- `color.gray.50` to `color.gray.900`: Gray scale
|
|
111
|
+
|
|
112
|
+
### Color Scales
|
|
113
|
+
|
|
114
|
+
Each color has a scale from 50 (lightest) to 900 (darkest):
|
|
115
|
+
|
|
116
|
+
- `color.blue.50` to `color.blue.900`
|
|
117
|
+
- `color.green.50` to `color.green.900`
|
|
118
|
+
- `color.red.50` to `color.red.900`
|
|
119
|
+
- `color.yellow.50` to `color.yellow.900`
|
|
120
|
+
- `color.purple.50` to `color.purple.900`
|
|
121
|
+
|
|
122
|
+
## Typography
|
|
123
|
+
|
|
124
|
+
The theme includes typography settings:
|
|
125
|
+
|
|
126
|
+
- Font family: Inter/Geist
|
|
127
|
+
- Font sizes: From 12px to 48px
|
|
128
|
+
- Font weights: From 400 (regular) to 700 (bold)
|
|
129
|
+
- Line heights: From 1.2 to 1.8
|
|
130
|
+
|
|
131
|
+
Example usage:
|
|
132
|
+
|
|
133
|
+
```jsx
|
|
134
|
+
import React from 'react';
|
|
135
|
+
import { Text } from '@app-studio/web';
|
|
136
|
+
|
|
137
|
+
function TypographyExample() {
|
|
138
|
+
return (
|
|
139
|
+
<>
|
|
140
|
+
<Text fontSize={12} fontWeight="normal">Small text</Text>
|
|
141
|
+
<Text fontSize={16} fontWeight="normal">Normal text</Text>
|
|
142
|
+
<Text fontSize={24} fontWeight="bold">Large bold text</Text>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Spacing
|
|
149
|
+
|
|
150
|
+
The theme uses a 4px grid system for spacing:
|
|
151
|
+
|
|
152
|
+
- 4px (extra small)
|
|
153
|
+
- 8px (small)
|
|
154
|
+
- 16px (medium)
|
|
155
|
+
- 24px (large)
|
|
156
|
+
- 32px (extra large)
|
|
157
|
+
|
|
158
|
+
Example usage:
|
|
159
|
+
|
|
160
|
+
```jsx
|
|
161
|
+
import React from 'react';
|
|
162
|
+
import { View, Horizontal } from 'app-studio';
|
|
163
|
+
|
|
164
|
+
function SpacingExample() {
|
|
165
|
+
return (
|
|
166
|
+
<View padding={16}>
|
|
167
|
+
<Horizontal gap={8}>
|
|
168
|
+
<View width={50} height={50} backgroundColor="theme.primary" />
|
|
169
|
+
<View width={50} height={50} backgroundColor="theme.secondary" />
|
|
170
|
+
</Horizontal>
|
|
171
|
+
</View>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Shapes
|
|
177
|
+
|
|
178
|
+
The theme includes shape definitions:
|
|
179
|
+
|
|
180
|
+
- `sharp`: No border radius (0px)
|
|
181
|
+
- `rounded`: Small border radius (4px)
|
|
182
|
+
- `pillShaped`: Pill shape (9999px)
|
|
183
|
+
|
|
184
|
+
Example usage:
|
|
185
|
+
|
|
186
|
+
```jsx
|
|
187
|
+
import React from 'react';
|
|
188
|
+
import { Button } from '@app-studio/web';
|
|
189
|
+
|
|
190
|
+
function ShapeExample() {
|
|
191
|
+
return (
|
|
192
|
+
<>
|
|
193
|
+
<Button shape="sharp">Sharp Button</Button>
|
|
194
|
+
<Button shape="rounded">Rounded Button</Button>
|
|
195
|
+
<Button shape="pillShaped">Pill Button</Button>
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Shadows
|
|
202
|
+
|
|
203
|
+
The theme includes shadow definitions:
|
|
204
|
+
|
|
205
|
+
- `shadow.sm`: Small shadow
|
|
206
|
+
- `shadow.md`: Medium shadow
|
|
207
|
+
- `shadow.lg`: Large shadow
|
|
208
|
+
- `shadow.xl`: Extra large shadow
|
|
209
|
+
|
|
210
|
+
Example usage:
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
import React from 'react';
|
|
214
|
+
import { Card } from '@app-studio/web';
|
|
215
|
+
|
|
216
|
+
function ShadowExample() {
|
|
217
|
+
return (
|
|
218
|
+
<>
|
|
219
|
+
<Card shadow="shadow.sm">Small Shadow Card</Card>
|
|
220
|
+
<Card shadow="shadow.md">Medium Shadow Card</Card>
|
|
221
|
+
<Card shadow="shadow.lg">Large Shadow Card</Card>
|
|
222
|
+
</>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Custom Theming
|
|
228
|
+
|
|
229
|
+
You can customize the theme by providing a custom theme object to the `ThemeProvider`:
|
|
230
|
+
|
|
231
|
+
```jsx
|
|
232
|
+
import React from 'react';
|
|
233
|
+
import { ThemeProvider } from 'app-studio';
|
|
234
|
+
|
|
235
|
+
const customTheme = {
|
|
236
|
+
mode: 'light',
|
|
237
|
+
colors: {
|
|
238
|
+
primary: '#6200ee',
|
|
239
|
+
secondary: '#03dac6',
|
|
240
|
+
success: '#00c853',
|
|
241
|
+
warning: '#ffab00',
|
|
242
|
+
error: '#b00020',
|
|
243
|
+
info: '#2196f3',
|
|
244
|
+
},
|
|
245
|
+
typography: {
|
|
246
|
+
fontFamily: 'Roboto, sans-serif',
|
|
247
|
+
fontSize: {
|
|
248
|
+
xs: 12,
|
|
249
|
+
sm: 14,
|
|
250
|
+
md: 16,
|
|
251
|
+
lg: 20,
|
|
252
|
+
xl: 24,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
// Add other theme customizations
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
function App() {
|
|
259
|
+
return (
|
|
260
|
+
<ThemeProvider theme={customTheme}>
|
|
261
|
+
{/* Your app content */}
|
|
262
|
+
</ThemeProvider>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Component-Specific Styling
|
|
268
|
+
|
|
269
|
+
You can override the theme for specific components using the `views` prop:
|
|
270
|
+
|
|
271
|
+
```jsx
|
|
272
|
+
import React from 'react';
|
|
273
|
+
import { Button } from '@app-studio/web';
|
|
274
|
+
|
|
275
|
+
function CustomStyledButton() {
|
|
276
|
+
return (
|
|
277
|
+
<Button
|
|
278
|
+
views={{
|
|
279
|
+
container: {
|
|
280
|
+
backgroundColor: '#6200ee',
|
|
281
|
+
borderRadius: 8,
|
|
282
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
283
|
+
},
|
|
284
|
+
}}
|
|
285
|
+
>
|
|
286
|
+
Custom Styled Button
|
|
287
|
+
</Button>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Best Practices
|
|
293
|
+
|
|
294
|
+
- Use theme variables instead of hardcoded values
|
|
295
|
+
- Use the `useTheme` hook to access theme values
|
|
296
|
+
- Use the `views` prop for component-specific styling
|
|
297
|
+
- Use the `themeMode` prop for component-specific theme mode
|
|
298
|
+
- Follow the spacing grid system (multiples of 4px)
|
|
299
|
+
- Use semantic colors for consistent meaning across the application
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Documentation System
|
|
2
|
+
|
|
3
|
+
This guide explains the documentation system used in the App Studio Web Component Library.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The documentation system consists of:
|
|
8
|
+
|
|
9
|
+
1. **Markdown Documentation**: General guides and tutorials in Markdown format
|
|
10
|
+
2. **MDX Component Documentation**: Interactive component documentation in MDX format
|
|
11
|
+
3. **Automated Documentation Generation**: Tools to generate and update documentation
|
|
12
|
+
|
|
13
|
+
## Documentation Structure
|
|
14
|
+
|
|
15
|
+
The documentation is organized into the following directories:
|
|
16
|
+
|
|
17
|
+
- `docs/`: General documentation and guides
|
|
18
|
+
- `public/files/media/`: MDX component documentation
|
|
19
|
+
- `src/data/props/`: Generated component props data
|
|
20
|
+
|
|
21
|
+
## MDX Component Documentation
|
|
22
|
+
|
|
23
|
+
Component documentation is written in MDX format, which allows for interactive examples. Each component has an MDX file in the `public/files/media/` directory.
|
|
24
|
+
|
|
25
|
+
Example MDX file structure:
|
|
26
|
+
|
|
27
|
+
```mdx
|
|
28
|
+
# Button
|
|
29
|
+
|
|
30
|
+
Customizable button for user interaction
|
|
31
|
+
|
|
32
|
+
### **Import**
|
|
33
|
+
```tsx
|
|
34
|
+
import { Button } from '@app-studio/web';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### **Default**
|
|
38
|
+
```tsx
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { Button } from '../Button';
|
|
41
|
+
|
|
42
|
+
export const DefaultButton = () => (
|
|
43
|
+
<Button onClick={() => alert('Hello, World!')}>Default</Button>
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### **Props**
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
| ---- | ---- | ------- | ----------- |
|
|
51
|
+
| variant | 'filled' \| 'outline' \| 'ghost' \| 'link' | 'filled' | The visual style of the button |
|
|
52
|
+
| size | 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' | 'md' | The size of the button |
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation Generation
|
|
56
|
+
|
|
57
|
+
The documentation system includes tools to automatically generate and update documentation:
|
|
58
|
+
|
|
59
|
+
### bot-doc
|
|
60
|
+
|
|
61
|
+
The `bot-doc` tool generates component documentation by analyzing the component code. It:
|
|
62
|
+
|
|
63
|
+
1. Processes component files to add comments
|
|
64
|
+
2. Generates props data
|
|
65
|
+
3. Creates MDX documentation
|
|
66
|
+
|
|
67
|
+
To run `bot-doc` for a specific component:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm run bot-doc -- ComponentName src/components/ComponentName
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### create-docs
|
|
74
|
+
|
|
75
|
+
The `create-docs` script checks for components without documentation and generates documentation for them. It also updates documentation for components that have changed.
|
|
76
|
+
|
|
77
|
+
To run `create-docs`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run create-docs
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Documentation Viewing
|
|
84
|
+
|
|
85
|
+
The documentation can be viewed in the application using the documentation viewer at `/docs`. The documentation viewer:
|
|
86
|
+
|
|
87
|
+
1. Loads MDX files
|
|
88
|
+
2. Renders them with the MDX provider
|
|
89
|
+
3. Provides a side menu for navigation
|
|
90
|
+
|
|
91
|
+
## Adding New Documentation
|
|
92
|
+
|
|
93
|
+
To add new documentation:
|
|
94
|
+
|
|
95
|
+
1. Create a new Markdown file in the appropriate directory
|
|
96
|
+
2. Add the file to the documentation structure
|
|
97
|
+
3. Link to the file from related documentation
|
|
98
|
+
|
|
99
|
+
## Updating Component Documentation
|
|
100
|
+
|
|
101
|
+
To update component documentation:
|
|
102
|
+
|
|
103
|
+
1. Run `bot-doc` for the component
|
|
104
|
+
2. Review the generated documentation
|
|
105
|
+
3. Make any necessary manual adjustments
|
|
106
|
+
|
|
107
|
+
## Documentation Best Practices
|
|
108
|
+
|
|
109
|
+
- Keep documentation up-to-date with code changes
|
|
110
|
+
- Include examples for all components and features
|
|
111
|
+
- Use consistent formatting and terminology
|
|
112
|
+
- Link related documentation
|
|
113
|
+
- Test all code examples
|
|
114
|
+
- Include accessibility information
|
|
115
|
+
- Document best practices and common pitfalls
|
|
116
|
+
|
|
117
|
+
## Troubleshooting
|
|
118
|
+
|
|
119
|
+
If you encounter issues with the documentation system:
|
|
120
|
+
|
|
121
|
+
### Missing Component Documentation
|
|
122
|
+
|
|
123
|
+
If a component is missing documentation:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run bot-doc -- ComponentName src/components/ComponentName
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Documentation Not Updating
|
|
130
|
+
|
|
131
|
+
If documentation is not updating after code changes:
|
|
132
|
+
|
|
133
|
+
1. Check if the component has changed significantly
|
|
134
|
+
2. Run `bot-doc` manually for the component
|
|
135
|
+
3. Check for errors in the console
|
|
136
|
+
|
|
137
|
+
### MDX Rendering Issues
|
|
138
|
+
|
|
139
|
+
If MDX files are not rendering correctly:
|
|
140
|
+
|
|
141
|
+
1. Check the MDX syntax
|
|
142
|
+
2. Ensure the MDX file is in the correct location
|
|
143
|
+
3. Check for errors in the console
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Component Usage Guide
|
|
2
|
+
|
|
3
|
+
This guide provides an overview of how to use components from the App Studio Web Component Library in your application.
|
|
4
|
+
|
|
5
|
+
## Basic Component Usage
|
|
6
|
+
|
|
7
|
+
Most components can be imported directly from the library and used with their default props:
|
|
8
|
+
|
|
9
|
+
```jsx
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { Button, Text } from '@app-studio/web';
|
|
12
|
+
|
|
13
|
+
function MyComponent() {
|
|
14
|
+
return (
|
|
15
|
+
<div>
|
|
16
|
+
<Text>Click the button below</Text>
|
|
17
|
+
<Button onClick={() => alert('Button clicked!')}>Click Me</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Component Props
|
|
24
|
+
|
|
25
|
+
Each component accepts a set of props that control its appearance and behavior. Common props include:
|
|
26
|
+
|
|
27
|
+
- `variant`: Controls the visual style (e.g., 'default', 'primary', 'secondary')
|
|
28
|
+
- `size`: Controls the size (e.g., 'xs', 'sm', 'md', 'lg', 'xl')
|
|
29
|
+
- `shape`: Controls the shape (e.g., 'sharp', 'rounded', 'pillShaped')
|
|
30
|
+
- `isDisabled`: Controls whether the component is disabled
|
|
31
|
+
- `views`: Allows for custom styling of specific parts of the component
|
|
32
|
+
|
|
33
|
+
Example with props:
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import React from 'react';
|
|
37
|
+
import { Button } from '@app-studio/web';
|
|
38
|
+
|
|
39
|
+
function MyComponent() {
|
|
40
|
+
return (
|
|
41
|
+
<Button
|
|
42
|
+
variant="primary"
|
|
43
|
+
size="lg"
|
|
44
|
+
shape="pillShaped"
|
|
45
|
+
isDisabled={false}
|
|
46
|
+
views={{ container: { backgroundColor: 'blue' } }}
|
|
47
|
+
onClick={() => alert('Button clicked!')}
|
|
48
|
+
>
|
|
49
|
+
Click Me
|
|
50
|
+
</Button>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Layout Components
|
|
56
|
+
|
|
57
|
+
Layout components help structure your UI. The main layout components are:
|
|
58
|
+
|
|
59
|
+
- `View`: Base container component
|
|
60
|
+
- `Horizontal`: Horizontal flex container
|
|
61
|
+
- `Vertical`: Vertical flex container
|
|
62
|
+
- `Center`: Centered flex container
|
|
63
|
+
|
|
64
|
+
Example:
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
import React from 'react';
|
|
68
|
+
import { View, Horizontal, Vertical, Center, Text, Button } from '@app-studio/web';
|
|
69
|
+
|
|
70
|
+
function MyLayout() {
|
|
71
|
+
return (
|
|
72
|
+
<View padding={20}>
|
|
73
|
+
<Vertical gap={16}>
|
|
74
|
+
<Text>Header</Text>
|
|
75
|
+
<Horizontal gap={8} justifyContent="space-between">
|
|
76
|
+
<Button>Left Button</Button>
|
|
77
|
+
<Button>Right Button</Button>
|
|
78
|
+
</Horizontal>
|
|
79
|
+
<Center>
|
|
80
|
+
<Text>Centered Content</Text>
|
|
81
|
+
</Center>
|
|
82
|
+
</Vertical>
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Form Components
|
|
89
|
+
|
|
90
|
+
Form components can be used standalone or integrated with Formik:
|
|
91
|
+
|
|
92
|
+
### Standalone Usage
|
|
93
|
+
|
|
94
|
+
```jsx
|
|
95
|
+
import React, { useState } from 'react';
|
|
96
|
+
import { TextField, Button } from '@app-studio/web';
|
|
97
|
+
|
|
98
|
+
function MyForm() {
|
|
99
|
+
const [value, setValue] = useState('');
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<form onSubmit={(e) => { e.preventDefault(); alert(`Submitted: ${value}`); }}>
|
|
103
|
+
<TextField
|
|
104
|
+
label="Name"
|
|
105
|
+
value={value}
|
|
106
|
+
onChange={(e) => setValue(e.target.value)}
|
|
107
|
+
/>
|
|
108
|
+
<Button type="submit">Submit</Button>
|
|
109
|
+
</form>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Formik Integration
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
import React from 'react';
|
|
118
|
+
import { Formik, Form } from 'formik';
|
|
119
|
+
import { FormikTextField, Button } from '@app-studio/web';
|
|
120
|
+
|
|
121
|
+
function MyFormikForm() {
|
|
122
|
+
return (
|
|
123
|
+
<Formik
|
|
124
|
+
initialValues={{ name: '' }}
|
|
125
|
+
onSubmit={(values) => alert(`Submitted: ${values.name}`)}
|
|
126
|
+
>
|
|
127
|
+
<Form>
|
|
128
|
+
<FormikTextField name="name" label="Name" />
|
|
129
|
+
<Button type="submit">Submit</Button>
|
|
130
|
+
</Form>
|
|
131
|
+
</Formik>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Compound Components
|
|
137
|
+
|
|
138
|
+
Some components use the compound component pattern, where a main component has sub-components for different parts:
|
|
139
|
+
|
|
140
|
+
```jsx
|
|
141
|
+
import React from 'react';
|
|
142
|
+
import { Card, Text, Button, Horizontal } from '@app-studio/web';
|
|
143
|
+
|
|
144
|
+
function MyCard() {
|
|
145
|
+
return (
|
|
146
|
+
<Card>
|
|
147
|
+
<Card.Header>
|
|
148
|
+
<Text fontWeight="bold" fontSize={18}>Card Title</Text>
|
|
149
|
+
</Card.Header>
|
|
150
|
+
<Card.Content>
|
|
151
|
+
<Text>This is the card content.</Text>
|
|
152
|
+
</Card.Content>
|
|
153
|
+
<Card.Footer>
|
|
154
|
+
<Horizontal justifyContent="flex-end" gap={10}>
|
|
155
|
+
<Button variant="outline">Cancel</Button>
|
|
156
|
+
<Button>Submit</Button>
|
|
157
|
+
</Horizontal>
|
|
158
|
+
</Card.Footer>
|
|
159
|
+
</Card>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Theming
|
|
165
|
+
|
|
166
|
+
Components automatically use the theme from the ThemeProvider context. You can override the theme mode for specific components:
|
|
167
|
+
|
|
168
|
+
```jsx
|
|
169
|
+
import React from 'react';
|
|
170
|
+
import { ThemeProvider, Button } from '@app-studio/web';
|
|
171
|
+
|
|
172
|
+
function MyThemedApp() {
|
|
173
|
+
return (
|
|
174
|
+
<ThemeProvider theme={{ mode: 'light' }}>
|
|
175
|
+
<Button>Light Theme Button</Button>
|
|
176
|
+
<Button themeMode="dark">Dark Theme Button</Button>
|
|
177
|
+
</ThemeProvider>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Custom Styling
|
|
183
|
+
|
|
184
|
+
You can customize component styling using the `views` prop:
|
|
185
|
+
|
|
186
|
+
```jsx
|
|
187
|
+
import React from 'react';
|
|
188
|
+
import { Button } from '@app-studio/web';
|
|
189
|
+
|
|
190
|
+
function MyCustomButton() {
|
|
191
|
+
return (
|
|
192
|
+
<Button
|
|
193
|
+
views={{
|
|
194
|
+
container: {
|
|
195
|
+
backgroundColor: '#6200ee',
|
|
196
|
+
borderRadius: 8,
|
|
197
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
198
|
+
},
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
Custom Styled Button
|
|
202
|
+
</Button>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Next Steps
|
|
208
|
+
|
|
209
|
+
- [Theming Guide](../design-system/theming.md)
|
|
210
|
+
- [Form Components Guide](../component-usage/form-components.md)
|
|
211
|
+
- [Layout Components Guide](../component-usage/layout-components.md)
|