@app-studio/web 0.9.31 → 0.9.32
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/components/Accordion.mdx +158 -0
- package/docs/components/Alert.mdx +123 -0
- package/docs/components/AspectRatio.mdx +55 -0
- package/docs/components/Avatar.mdx +85 -0
- package/docs/components/Background.mdx +522 -0
- package/docs/components/Badge.mdx +220 -0
- package/docs/components/Button.mdx +272 -0
- package/docs/components/Calendar.mdx +274 -0
- package/docs/components/Card.mdx +341 -0
- package/docs/components/Carousel.mdx +411 -0
- package/docs/components/Center.mdx +474 -0
- package/docs/components/Chart.mdx +232 -0
- package/docs/components/ChatInput.mdx +373 -0
- package/docs/components/Checkbox.mdx +66 -0
- package/docs/components/ColorInput.mdx +209 -0
- package/docs/components/ComboBox.mdx +364 -0
- package/docs/components/Command.mdx +252 -0
- package/docs/components/ContextMenu.mdx +219 -0
- package/docs/components/CountryPicker.mdx +123 -0
- package/docs/components/DatePicker.mdx +77 -0
- package/docs/components/DragAndDrop.mdx +539 -0
- package/docs/components/DropdownMenu.mdx +205 -0
- package/docs/components/File.mdx +8 -0
- package/docs/components/Flow.mdx +257 -0
- package/docs/components/Form.mdx +681 -0
- package/docs/components/Formik.mdx +621 -0
- package/docs/components/Gradient.mdx +271 -0
- package/docs/components/Horizontal.mdx +40 -0
- package/docs/components/HoverCard.mdx +140 -0
- package/docs/components/Icon.mdx +438 -0
- package/docs/components/Label.mdx +438 -0
- package/docs/components/Link.mdx +83 -0
- package/docs/components/Loader.mdx +527 -0
- package/docs/components/Menubar.mdx +124 -0
- package/docs/components/Message.mdx +571 -0
- package/docs/components/Modal.mdx +533 -0
- package/docs/components/NavigationMenu.mdx +165 -0
- package/docs/components/Pagination.mdx +150 -0
- package/docs/components/Password.mdx +121 -0
- package/docs/components/Resizable.mdx +148 -0
- package/docs/components/Select.mdx +126 -0
- package/docs/components/Separator.mdx +121 -0
- package/docs/components/Sidebar.mdx +147 -0
- package/docs/components/Slider.mdx +232 -0
- package/docs/components/Switch.mdx +62 -0
- package/docs/components/Table.mdx +409 -0
- package/docs/components/Tabs.mdx +215 -0
- package/docs/components/TagInput.mdx +528 -0
- package/docs/components/Text.mdx +163 -0
- package/docs/components/TextArea.mdx +136 -0
- package/docs/components/TextField.mdx +225 -0
- package/docs/components/Title.mdx +535 -0
- package/docs/components/Toast.mdx +165 -0
- package/docs/components/Toggle.mdx +141 -0
- package/docs/components/ToggleGroup.mdx +165 -0
- package/docs/components/Tooltip.mdx +191 -0
- package/docs/components/Tree.mdx +340 -0
- package/docs/components/Uploader.mdx +426 -0
- package/docs/components/Vertical.mdx +566 -0
- package/package.json +1 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
# Center
|
|
2
|
+
|
|
3
|
+
A layout component that centers its children both horizontally and vertically within its bounds using CSS Flexbox. Perfect for creating loading states, empty states, modal content, hero sections, and any content that needs perfect centering.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Center } from '@app-studio/web';
|
|
8
|
+
// or from app-studio
|
|
9
|
+
import { Center } from 'app-studio';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### **Basic Usage**
|
|
13
|
+
```tsx
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { Center } from 'app-studio';
|
|
16
|
+
import { Text } from 'app-studio';
|
|
17
|
+
|
|
18
|
+
export const BasicCenter = () => (
|
|
19
|
+
<Center height={200} backgroundColor="color.gray.100">
|
|
20
|
+
<Text fontSize={18} fontWeight="bold">
|
|
21
|
+
Centered Content
|
|
22
|
+
</Text>
|
|
23
|
+
</Center>
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### **Loading State Example**
|
|
28
|
+
```tsx
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { Center } from 'app-studio';
|
|
31
|
+
import { Loader } from '@app-studio/web';
|
|
32
|
+
import { Text, Vertical } from 'app-studio';
|
|
33
|
+
|
|
34
|
+
export const LoadingCenter = () => (
|
|
35
|
+
<Center height="100vh" backgroundColor="color.white">
|
|
36
|
+
<Vertical gap={16} alignItems="center">
|
|
37
|
+
<Loader size="lg" />
|
|
38
|
+
<Text color="color.gray.600">Loading...</Text>
|
|
39
|
+
</Vertical>
|
|
40
|
+
</Center>
|
|
41
|
+
);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### **Empty State Example**
|
|
45
|
+
```tsx
|
|
46
|
+
import React from 'react';
|
|
47
|
+
import { Center } from 'app-studio';
|
|
48
|
+
import { Button } from '@app-studio/web';
|
|
49
|
+
import { Text, Vertical } from 'app-studio';
|
|
50
|
+
import { EmptyIcon } from '@app-studio/web';
|
|
51
|
+
|
|
52
|
+
export const EmptyStateCenter = () => (
|
|
53
|
+
<Center height={400} backgroundColor="color.gray.50" borderRadius={12}>
|
|
54
|
+
<Vertical gap={20} alignItems="center" textAlign="center">
|
|
55
|
+
<EmptyIcon widthHeight={64} color="color.gray.400" />
|
|
56
|
+
<Vertical gap={8} alignItems="center">
|
|
57
|
+
<Text fontSize={20} fontWeight="bold" color="color.gray.700">
|
|
58
|
+
No items found
|
|
59
|
+
</Text>
|
|
60
|
+
<Text color="color.gray.500" maxWidth={300}>
|
|
61
|
+
There are no items to display. Create your first item to get started.
|
|
62
|
+
</Text>
|
|
63
|
+
</Vertical>
|
|
64
|
+
<Button variant="filled" colorScheme="theme.primary">
|
|
65
|
+
Create Item
|
|
66
|
+
</Button>
|
|
67
|
+
</Vertical>
|
|
68
|
+
</Center>
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### **Modal Content Example**
|
|
73
|
+
```tsx
|
|
74
|
+
import React from 'react';
|
|
75
|
+
import { Center } from 'app-studio';
|
|
76
|
+
import { Modal, Button } from '@app-studio/web';
|
|
77
|
+
import { Text, Vertical, Horizontal } from 'app-studio';
|
|
78
|
+
|
|
79
|
+
export const ModalCenter = () => {
|
|
80
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<>
|
|
84
|
+
<Button onClick={() => setIsOpen(true)}>
|
|
85
|
+
Open Modal
|
|
86
|
+
</Button>
|
|
87
|
+
|
|
88
|
+
<Modal isOpen={isOpen} onClose={() => setIsOpen(false)}>
|
|
89
|
+
<Center padding={40}>
|
|
90
|
+
<Vertical gap={24} alignItems="center" textAlign="center">
|
|
91
|
+
<Text fontSize={24} fontWeight="bold">
|
|
92
|
+
Confirm Action
|
|
93
|
+
</Text>
|
|
94
|
+
<Text color="color.gray.600" maxWidth={300}>
|
|
95
|
+
Are you sure you want to delete this item? This action cannot be undone.
|
|
96
|
+
</Text>
|
|
97
|
+
<Horizontal gap={12}>
|
|
98
|
+
<Button
|
|
99
|
+
variant="outline"
|
|
100
|
+
onClick={() => setIsOpen(false)}
|
|
101
|
+
>
|
|
102
|
+
Cancel
|
|
103
|
+
</Button>
|
|
104
|
+
<Button
|
|
105
|
+
variant="filled"
|
|
106
|
+
colorScheme="theme.error"
|
|
107
|
+
onClick={() => setIsOpen(false)}
|
|
108
|
+
>
|
|
109
|
+
Delete
|
|
110
|
+
</Button>
|
|
111
|
+
</Horizontal>
|
|
112
|
+
</Vertical>
|
|
113
|
+
</Center>
|
|
114
|
+
</Modal>
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### **Hero Section Example**
|
|
121
|
+
```tsx
|
|
122
|
+
import React from 'react';
|
|
123
|
+
import { Center } from 'app-studio';
|
|
124
|
+
import { Button } from '@app-studio/web';
|
|
125
|
+
import { Text, Vertical, Horizontal } from 'app-studio';
|
|
126
|
+
|
|
127
|
+
export const HeroCenter = () => (
|
|
128
|
+
<Center
|
|
129
|
+
height="100vh"
|
|
130
|
+
backgroundImage="linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
131
|
+
color="color.white"
|
|
132
|
+
>
|
|
133
|
+
<Vertical gap={32} alignItems="center" textAlign="center" maxWidth={600}>
|
|
134
|
+
<Vertical gap={16} alignItems="center">
|
|
135
|
+
<Text fontSize={48} fontWeight="bold" lineHeight={1.2}>
|
|
136
|
+
Build Amazing Apps
|
|
137
|
+
</Text>
|
|
138
|
+
<Text fontSize={20} opacity={0.9} lineHeight={1.6}>
|
|
139
|
+
Create beautiful, responsive applications with our comprehensive
|
|
140
|
+
component library and design system.
|
|
141
|
+
</Text>
|
|
142
|
+
</Vertical>
|
|
143
|
+
|
|
144
|
+
<Horizontal gap={16}>
|
|
145
|
+
<Button
|
|
146
|
+
variant="filled"
|
|
147
|
+
size="lg"
|
|
148
|
+
backgroundColor="color.white"
|
|
149
|
+
color="color.gray.900"
|
|
150
|
+
>
|
|
151
|
+
Get Started
|
|
152
|
+
</Button>
|
|
153
|
+
<Button
|
|
154
|
+
variant="outline"
|
|
155
|
+
size="lg"
|
|
156
|
+
borderColor="color.white"
|
|
157
|
+
color="color.white"
|
|
158
|
+
>
|
|
159
|
+
Learn More
|
|
160
|
+
</Button>
|
|
161
|
+
</Horizontal>
|
|
162
|
+
</Vertical>
|
|
163
|
+
</Center>
|
|
164
|
+
);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### **Card Center Example**
|
|
168
|
+
```tsx
|
|
169
|
+
import React from 'react';
|
|
170
|
+
import { Center } from 'app-studio';
|
|
171
|
+
import { View, Text, Vertical } from 'app-studio';
|
|
172
|
+
import { StarIcon } from '@app-studio/web';
|
|
173
|
+
|
|
174
|
+
export const CardCenter = () => (
|
|
175
|
+
<View
|
|
176
|
+
width={300}
|
|
177
|
+
height={200}
|
|
178
|
+
border="1px solid"
|
|
179
|
+
borderColor="color.gray.200"
|
|
180
|
+
borderRadius={12}
|
|
181
|
+
backgroundColor="color.white"
|
|
182
|
+
boxShadow="0 4px 12px rgba(0,0,0,0.1)"
|
|
183
|
+
>
|
|
184
|
+
<Center height="100%">
|
|
185
|
+
<Vertical gap={12} alignItems="center">
|
|
186
|
+
<StarIcon widthHeight={32} color="color.yellow.500" filled />
|
|
187
|
+
<Text fontSize={18} fontWeight="bold">
|
|
188
|
+
Premium Feature
|
|
189
|
+
</Text>
|
|
190
|
+
<Text color="color.gray.600" textAlign="center" fontSize={14}>
|
|
191
|
+
Unlock advanced features with our premium plan
|
|
192
|
+
</Text>
|
|
193
|
+
</Vertical>
|
|
194
|
+
</Center>
|
|
195
|
+
</View>
|
|
196
|
+
);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### **Props**
|
|
200
|
+
|
|
201
|
+
The Center component extends ViewProps from app-studio, inheriting all standard view properties:
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
| ---- | ---- | ------- | ----------- |
|
|
205
|
+
| children | React.ReactNode | undefined | Content to be centered |
|
|
206
|
+
| gap | number \| string | 0 | Space between child elements (if multiple) |
|
|
207
|
+
|
|
208
|
+
**Inherited ViewProps:**
|
|
209
|
+
- `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`
|
|
210
|
+
- `padding`, `margin`, `paddingTop`, `paddingBottom`, etc.
|
|
211
|
+
- `backgroundColor`, `border`, `borderRadius`, `boxShadow`
|
|
212
|
+
- `position`, `top`, `left`, `right`, `bottom`, `zIndex`
|
|
213
|
+
- `overflow`, `cursor`, `opacity`, `transform`
|
|
214
|
+
- All CSS properties and responsive breakpoint props
|
|
215
|
+
|
|
216
|
+
### **Responsive Centering**
|
|
217
|
+
```tsx
|
|
218
|
+
import React from 'react';
|
|
219
|
+
import { Center } from 'app-studio';
|
|
220
|
+
import { Text, Vertical } from 'app-studio';
|
|
221
|
+
|
|
222
|
+
export const ResponsiveCenter = () => (
|
|
223
|
+
<Center
|
|
224
|
+
height={{ mobile: '50vh', tablet: '60vh', desktop: '100vh' }}
|
|
225
|
+
padding={{ mobile: 16, tablet: 24, desktop: 32 }}
|
|
226
|
+
>
|
|
227
|
+
<Vertical
|
|
228
|
+
gap={16}
|
|
229
|
+
alignItems="center"
|
|
230
|
+
textAlign="center"
|
|
231
|
+
maxWidth={{ mobile: 300, tablet: 400, desktop: 500 }}
|
|
232
|
+
>
|
|
233
|
+
<Text
|
|
234
|
+
fontSize={{ mobile: 24, tablet: 32, desktop: 40 }}
|
|
235
|
+
fontWeight="bold"
|
|
236
|
+
>
|
|
237
|
+
Responsive Title
|
|
238
|
+
</Text>
|
|
239
|
+
<Text
|
|
240
|
+
fontSize={{ mobile: 14, tablet: 16, desktop: 18 }}
|
|
241
|
+
color="color.gray.600"
|
|
242
|
+
>
|
|
243
|
+
This content adapts to different screen sizes
|
|
244
|
+
</Text>
|
|
245
|
+
</Vertical>
|
|
246
|
+
</Center>
|
|
247
|
+
);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### **Multiple Children with Gap**
|
|
251
|
+
```tsx
|
|
252
|
+
import React from 'react';
|
|
253
|
+
import { Center } from 'app-studio';
|
|
254
|
+
import { View } from 'app-studio';
|
|
255
|
+
|
|
256
|
+
export const CenterWithGap = () => (
|
|
257
|
+
<Center height={300} gap={16}>
|
|
258
|
+
<View
|
|
259
|
+
width={60}
|
|
260
|
+
height={60}
|
|
261
|
+
backgroundColor="color.red.400"
|
|
262
|
+
borderRadius={8}
|
|
263
|
+
/>
|
|
264
|
+
<View
|
|
265
|
+
width={60}
|
|
266
|
+
height={60}
|
|
267
|
+
backgroundColor="color.blue.400"
|
|
268
|
+
borderRadius={8}
|
|
269
|
+
/>
|
|
270
|
+
<View
|
|
271
|
+
width={60}
|
|
272
|
+
height={60}
|
|
273
|
+
backgroundColor="color.green.400"
|
|
274
|
+
borderRadius={8}
|
|
275
|
+
/>
|
|
276
|
+
</Center>
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### **Error State Example**
|
|
281
|
+
```tsx
|
|
282
|
+
import React from 'react';
|
|
283
|
+
import { Center } from 'app-studio';
|
|
284
|
+
import { Button } from '@app-studio/web';
|
|
285
|
+
import { Text, Vertical } from 'app-studio';
|
|
286
|
+
import { ErrorIcon } from '@app-studio/web';
|
|
287
|
+
|
|
288
|
+
export const ErrorStateCenter = () => (
|
|
289
|
+
<Center
|
|
290
|
+
height={400}
|
|
291
|
+
backgroundColor="color.red.50"
|
|
292
|
+
borderRadius={12}
|
|
293
|
+
border="1px solid"
|
|
294
|
+
borderColor="color.red.200"
|
|
295
|
+
>
|
|
296
|
+
<Vertical gap={20} alignItems="center" textAlign="center">
|
|
297
|
+
<ErrorIcon widthHeight={48} color="color.red.500" />
|
|
298
|
+
<Vertical gap={8} alignItems="center">
|
|
299
|
+
<Text fontSize={18} fontWeight="bold" color="color.red.700">
|
|
300
|
+
Something went wrong
|
|
301
|
+
</Text>
|
|
302
|
+
<Text color="color.red.600" maxWidth={300}>
|
|
303
|
+
We encountered an error while processing your request.
|
|
304
|
+
Please try again or contact support.
|
|
305
|
+
</Text>
|
|
306
|
+
</Vertical>
|
|
307
|
+
<Button
|
|
308
|
+
variant="filled"
|
|
309
|
+
colorScheme="theme.error"
|
|
310
|
+
onClick={() => window.location.reload()}
|
|
311
|
+
>
|
|
312
|
+
Try Again
|
|
313
|
+
</Button>
|
|
314
|
+
</Vertical>
|
|
315
|
+
</Center>
|
|
316
|
+
);
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### **Image Placeholder Example**
|
|
320
|
+
```tsx
|
|
321
|
+
import React from 'react';
|
|
322
|
+
import { Center } from 'app-studio';
|
|
323
|
+
import { Text } from 'app-studio';
|
|
324
|
+
import { ImageIcon } from '@app-studio/web';
|
|
325
|
+
|
|
326
|
+
export const ImagePlaceholder = () => (
|
|
327
|
+
<Center
|
|
328
|
+
width={300}
|
|
329
|
+
height={200}
|
|
330
|
+
backgroundColor="color.gray.100"
|
|
331
|
+
border="2px dashed"
|
|
332
|
+
borderColor="color.gray.300"
|
|
333
|
+
borderRadius={8}
|
|
334
|
+
cursor="pointer"
|
|
335
|
+
_hover={{
|
|
336
|
+
backgroundColor: 'color.gray.200',
|
|
337
|
+
borderColor: 'color.gray.400',
|
|
338
|
+
}}
|
|
339
|
+
>
|
|
340
|
+
<Vertical gap={8} alignItems="center">
|
|
341
|
+
<ImageIcon widthHeight={32} color="color.gray.500" />
|
|
342
|
+
<Text color="color.gray.600" fontSize={14}>
|
|
343
|
+
Click to upload image
|
|
344
|
+
</Text>
|
|
345
|
+
</Vertical>
|
|
346
|
+
</Center>
|
|
347
|
+
);
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### **Best Practices**
|
|
351
|
+
|
|
352
|
+
**When to Use Center:**
|
|
353
|
+
- Loading states and spinners
|
|
354
|
+
- Empty states and placeholders
|
|
355
|
+
- Modal and dialog content
|
|
356
|
+
- Hero sections and landing pages
|
|
357
|
+
- Error states and messages
|
|
358
|
+
- Single-item displays (icons, logos, etc.)
|
|
359
|
+
|
|
360
|
+
**Layout Considerations:**
|
|
361
|
+
- Always specify a height for proper centering
|
|
362
|
+
- Use appropriate container sizes for content
|
|
363
|
+
- Consider responsive behavior across devices
|
|
364
|
+
- Ensure content doesn't overflow on small screens
|
|
365
|
+
|
|
366
|
+
**Accessibility:**
|
|
367
|
+
- Ensure centered content is keyboard accessible
|
|
368
|
+
- Use proper heading hierarchy
|
|
369
|
+
- Provide alternative text for images
|
|
370
|
+
- Consider screen reader navigation
|
|
371
|
+
|
|
372
|
+
**Performance:**
|
|
373
|
+
- Avoid unnecessary nesting of Center components
|
|
374
|
+
- Use CSS transforms for animations instead of changing layout
|
|
375
|
+
- Consider using CSS Grid for complex centered layouts
|
|
376
|
+
|
|
377
|
+
### **Common Patterns**
|
|
378
|
+
|
|
379
|
+
**Splash Screen:**
|
|
380
|
+
```tsx
|
|
381
|
+
<Center height="100vh" backgroundColor="theme.primary">
|
|
382
|
+
<Vertical gap={24} alignItems="center">
|
|
383
|
+
<Logo size="lg" />
|
|
384
|
+
<Loader color="color.white" />
|
|
385
|
+
</Vertical>
|
|
386
|
+
</Center>
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Feature Highlight:**
|
|
390
|
+
```tsx
|
|
391
|
+
<Center height={300} backgroundColor="color.blue.50">
|
|
392
|
+
<Vertical gap={16} alignItems="center" textAlign="center">
|
|
393
|
+
<FeatureIcon widthHeight={48} />
|
|
394
|
+
<Text fontSize={20} fontWeight="bold">Feature Name</Text>
|
|
395
|
+
<Text color="color.gray.600">Feature description</Text>
|
|
396
|
+
</Vertical>
|
|
397
|
+
</Center>
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Call to Action:**
|
|
401
|
+
```tsx
|
|
402
|
+
<Center padding={40} backgroundColor="color.gray.900" color="color.white">
|
|
403
|
+
<Vertical gap={20} alignItems="center" textAlign="center">
|
|
404
|
+
<Text fontSize={24} fontWeight="bold">Ready to get started?</Text>
|
|
405
|
+
<Button variant="filled" size="lg">Get Started Now</Button>
|
|
406
|
+
</Vertical>
|
|
407
|
+
</Center>
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### **Integration with Other Components**
|
|
411
|
+
|
|
412
|
+
The Center component works well with other layout components:
|
|
413
|
+
|
|
414
|
+
```tsx
|
|
415
|
+
import { Center, Vertical, Horizontal } from 'app-studio';
|
|
416
|
+
|
|
417
|
+
// Centered content within a larger layout
|
|
418
|
+
<Vertical height="100vh">
|
|
419
|
+
<Header />
|
|
420
|
+
<Center flex={1}>
|
|
421
|
+
<MainContent />
|
|
422
|
+
</Center>
|
|
423
|
+
<Footer />
|
|
424
|
+
</Vertical>
|
|
425
|
+
|
|
426
|
+
// Horizontally centered, vertically stacked
|
|
427
|
+
<Horizontal height="100vh">
|
|
428
|
+
<Sidebar />
|
|
429
|
+
<Center flex={1}>
|
|
430
|
+
<Vertical gap={20}>
|
|
431
|
+
<Title />
|
|
432
|
+
<Content />
|
|
433
|
+
<Actions />
|
|
434
|
+
</Vertical>
|
|
435
|
+
</Center>
|
|
436
|
+
</Horizontal>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### **Advanced Usage**
|
|
440
|
+
|
|
441
|
+
**Custom Centering Logic:**
|
|
442
|
+
```tsx
|
|
443
|
+
// For more complex centering needs, you can extend Center
|
|
444
|
+
const CustomCenter = ({ children, ...props }) => (
|
|
445
|
+
<Center
|
|
446
|
+
position="relative"
|
|
447
|
+
{...props}
|
|
448
|
+
>
|
|
449
|
+
<View
|
|
450
|
+
position="absolute"
|
|
451
|
+
top="50%"
|
|
452
|
+
left="50%"
|
|
453
|
+
transform="translate(-50%, -50%)"
|
|
454
|
+
>
|
|
455
|
+
{children}
|
|
456
|
+
</View>
|
|
457
|
+
</Center>
|
|
458
|
+
);
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Animated Center:**
|
|
462
|
+
```tsx
|
|
463
|
+
const AnimatedCenter = ({ children, ...props }) => (
|
|
464
|
+
<Center
|
|
465
|
+
transition="all 0.3s ease"
|
|
466
|
+
_hover={{
|
|
467
|
+
transform: 'scale(1.05)',
|
|
468
|
+
}}
|
|
469
|
+
{...props}
|
|
470
|
+
>
|
|
471
|
+
{children}
|
|
472
|
+
</Center>
|
|
473
|
+
);
|
|
474
|
+
```
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Chart
|
|
2
|
+
|
|
3
|
+
A component for visualizing data in various chart formats.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Chart } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Bar Chart**
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Chart } from '../Chart';
|
|
14
|
+
import { View } from 'app-studio';
|
|
15
|
+
|
|
16
|
+
export const BarChartDemo = () => {
|
|
17
|
+
const data = {
|
|
18
|
+
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
|
|
19
|
+
series: [
|
|
20
|
+
{
|
|
21
|
+
name: 'Revenue',
|
|
22
|
+
data: [30, 40, 35, 50, 49, 60],
|
|
23
|
+
color: 'color.blue.500',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Expenses',
|
|
27
|
+
data: [20, 25, 30, 35, 30, 40],
|
|
28
|
+
color: 'color.red.500',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View height="300px" width="100%">
|
|
35
|
+
<Chart
|
|
36
|
+
type="bar"
|
|
37
|
+
data={data}
|
|
38
|
+
title="Monthly Revenue vs Expenses"
|
|
39
|
+
showGrid
|
|
40
|
+
animated
|
|
41
|
+
/>
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### **Line Chart**
|
|
48
|
+
```tsx
|
|
49
|
+
import React from 'react';
|
|
50
|
+
import { Chart } from '../Chart';
|
|
51
|
+
import { View } from 'app-studio';
|
|
52
|
+
|
|
53
|
+
export const LineChartDemo = () => {
|
|
54
|
+
const data = {
|
|
55
|
+
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
|
|
56
|
+
series: [
|
|
57
|
+
{
|
|
58
|
+
name: 'Users',
|
|
59
|
+
data: [500, 800, 1200, 1800, 2500, 3000],
|
|
60
|
+
color: 'color.purple.500',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Sessions',
|
|
64
|
+
data: [1000, 1600, 2400, 3600, 5000, 6000],
|
|
65
|
+
color: 'color.teal.500',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<View height="300px" width="100%">
|
|
72
|
+
<Chart
|
|
73
|
+
type="line"
|
|
74
|
+
data={data}
|
|
75
|
+
title="Website Traffic"
|
|
76
|
+
showGrid
|
|
77
|
+
animated
|
|
78
|
+
legendPosition="top"
|
|
79
|
+
/>
|
|
80
|
+
</View>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### **Area Chart**
|
|
86
|
+
```tsx
|
|
87
|
+
import React from 'react';
|
|
88
|
+
import { Chart } from '../Chart';
|
|
89
|
+
import { View } from 'app-studio';
|
|
90
|
+
|
|
91
|
+
export const AreaChartDemo = () => {
|
|
92
|
+
const data = {
|
|
93
|
+
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
94
|
+
series: [
|
|
95
|
+
{
|
|
96
|
+
name: 'This Week',
|
|
97
|
+
data: [10, 15, 12, 20, 18, 25, 22],
|
|
98
|
+
color: 'color.green.500',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Last Week',
|
|
102
|
+
data: [8, 12, 10, 15, 14, 20, 17],
|
|
103
|
+
color: 'color.blue.500',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<View height="300px" width="100%">
|
|
110
|
+
<Chart
|
|
111
|
+
type="area"
|
|
112
|
+
data={data}
|
|
113
|
+
title="Weekly Performance"
|
|
114
|
+
showGrid
|
|
115
|
+
animated
|
|
116
|
+
/>
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### **Pie Chart**
|
|
123
|
+
```tsx
|
|
124
|
+
import React from 'react';
|
|
125
|
+
import { Chart } from '../Chart';
|
|
126
|
+
import { View } from 'app-studio';
|
|
127
|
+
|
|
128
|
+
export const PieChartDemo = () => {
|
|
129
|
+
const dataPoints = [
|
|
130
|
+
{ label: 'Mobile', value: 45, color: 'color.blue.500' },
|
|
131
|
+
{ label: 'Desktop', value: 30, color: 'color.green.500' },
|
|
132
|
+
{ label: 'Tablet', value: 15, color: 'color.purple.500' },
|
|
133
|
+
{ label: 'Other', value: 10, color: 'color.orange.500' },
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<View height="300px" width="100%">
|
|
138
|
+
<Chart
|
|
139
|
+
type="pie"
|
|
140
|
+
dataPoints={dataPoints}
|
|
141
|
+
title="Device Distribution"
|
|
142
|
+
animated
|
|
143
|
+
/>
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### **Donut Chart**
|
|
150
|
+
```tsx
|
|
151
|
+
import React from 'react';
|
|
152
|
+
import { Chart } from '../Chart';
|
|
153
|
+
import { View } from 'app-studio';
|
|
154
|
+
|
|
155
|
+
export const DonutChartDemo = () => {
|
|
156
|
+
const dataPoints = [
|
|
157
|
+
{ label: 'Completed', value: 65, color: 'color.green.500' },
|
|
158
|
+
{ label: 'In Progress', value: 25, color: 'color.blue.500' },
|
|
159
|
+
{ label: 'Pending', value: 10, color: 'color.orange.500' },
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<View height="300px" width="100%">
|
|
164
|
+
<Chart
|
|
165
|
+
type="donut"
|
|
166
|
+
dataPoints={dataPoints}
|
|
167
|
+
title="Task Status"
|
|
168
|
+
animated
|
|
169
|
+
/>
|
|
170
|
+
</View>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### **Custom Styling**
|
|
176
|
+
```tsx
|
|
177
|
+
import React from 'react';
|
|
178
|
+
import { Chart } from '../Chart';
|
|
179
|
+
import { View } from 'app-studio';
|
|
180
|
+
|
|
181
|
+
export const CustomChartDemo = () => {
|
|
182
|
+
const data = {
|
|
183
|
+
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
184
|
+
series: [
|
|
185
|
+
{
|
|
186
|
+
name: 'Sales',
|
|
187
|
+
data: [120, 180, 150, 210],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<View height="300px" width="100%">
|
|
194
|
+
<Chart
|
|
195
|
+
type="bar"
|
|
196
|
+
data={data}
|
|
197
|
+
title="Quarterly Sales"
|
|
198
|
+
animated
|
|
199
|
+
views={{
|
|
200
|
+
container: {
|
|
201
|
+
backgroundColor: 'color.gray.50',
|
|
202
|
+
padding: '16px',
|
|
203
|
+
borderRadius: '8px',
|
|
204
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
|
|
205
|
+
},
|
|
206
|
+
chart: {
|
|
207
|
+
margin: '16px 0',
|
|
208
|
+
},
|
|
209
|
+
bar: {
|
|
210
|
+
rx: '4px',
|
|
211
|
+
ry: '4px',
|
|
212
|
+
fill: 'color.blue',
|
|
213
|
+
},
|
|
214
|
+
grid: {
|
|
215
|
+
stroke: 'color.gray.300',
|
|
216
|
+
strokeDasharray: '4',
|
|
217
|
+
},
|
|
218
|
+
axis: {
|
|
219
|
+
stroke: 'color.gray.400',
|
|
220
|
+
strokeWidth: '2px',
|
|
221
|
+
},
|
|
222
|
+
legend: {
|
|
223
|
+
backgroundColor: 'color.white',
|
|
224
|
+
padding: '8px',
|
|
225
|
+
borderRadius: '4px',
|
|
226
|
+
},
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</View>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
```
|