@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,411 @@
|
|
|
1
|
+
# Carousel
|
|
2
|
+
|
|
3
|
+
A component for displaying a series of content items that can be navigated through. The Carousel can be used in two ways:
|
|
4
|
+
|
|
5
|
+
1. **Traditional approach**: Direct children as slides
|
|
6
|
+
2. **Compound component pattern**: Using `Carousel.Content`, `Carousel.Item`, `Carousel.Previous`, and `Carousel.Next`
|
|
7
|
+
|
|
8
|
+
### **Import**
|
|
9
|
+
```tsx
|
|
10
|
+
import { Carousel } from '@app-studio/web';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### **Default**
|
|
14
|
+
```tsx
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { Carousel } from '../Carousel';
|
|
17
|
+
import { View } from 'app-studio';
|
|
18
|
+
import { Text } from '../../Text/Text';
|
|
19
|
+
|
|
20
|
+
export const DefaultDemo = () => {
|
|
21
|
+
// Create an array of slides with different background colors
|
|
22
|
+
const slides = [
|
|
23
|
+
{ color: 'color.blue.500', text: 'Slide 1' },
|
|
24
|
+
{ color: 'color.green.500', text: 'Slide 2' },
|
|
25
|
+
{ color: 'color.purple.500', text: 'Slide 3' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View height="300px" width="100%">
|
|
30
|
+
<Carousel>
|
|
31
|
+
{slides.map((slide, index) => (
|
|
32
|
+
<View
|
|
33
|
+
key={index}
|
|
34
|
+
backgroundColor={slide.color}
|
|
35
|
+
width="100%"
|
|
36
|
+
height="100%"
|
|
37
|
+
display="flex"
|
|
38
|
+
alignItems="center"
|
|
39
|
+
justifyContent="center"
|
|
40
|
+
>
|
|
41
|
+
<Text color="white" fontSize="24px" fontWeight="bold">
|
|
42
|
+
{slide.text}
|
|
43
|
+
</Text>
|
|
44
|
+
</View>
|
|
45
|
+
))}
|
|
46
|
+
</Carousel>
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### **Compound Component Pattern**
|
|
53
|
+
Use the compound component pattern for more flexibility and control over the carousel structure.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import React from 'react';
|
|
57
|
+
import { Carousel } from '../Carousel';
|
|
58
|
+
import { View } from 'app-studio';
|
|
59
|
+
import { Text } from '../../Text/Text';
|
|
60
|
+
|
|
61
|
+
export const CompoundDemo = () => {
|
|
62
|
+
const slides = [
|
|
63
|
+
{ color: 'color.blue.500', text: 'Slide 1' },
|
|
64
|
+
{ color: 'color.green.500', text: 'Slide 2' },
|
|
65
|
+
{ color: 'color.purple.500', text: 'Slide 3' },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View height="300px" width="100%">
|
|
70
|
+
<Carousel
|
|
71
|
+
aria-label="Compound Carousel Example"
|
|
72
|
+
views={{
|
|
73
|
+
container: {
|
|
74
|
+
borderRadius: '8px',
|
|
75
|
+
overflow: 'hidden',
|
|
76
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
77
|
+
},
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<Carousel.Content>
|
|
81
|
+
{slides.map((slide, index) => (
|
|
82
|
+
<Carousel.Item key={index}>
|
|
83
|
+
<View
|
|
84
|
+
backgroundColor={slide.color}
|
|
85
|
+
width="100%"
|
|
86
|
+
height="100%"
|
|
87
|
+
display="flex"
|
|
88
|
+
alignItems="center"
|
|
89
|
+
justifyContent="center"
|
|
90
|
+
>
|
|
91
|
+
<Text color="white" fontSize="24px" fontWeight="bold">
|
|
92
|
+
{slide.text}
|
|
93
|
+
</Text>
|
|
94
|
+
</View>
|
|
95
|
+
</Carousel.Item>
|
|
96
|
+
))}
|
|
97
|
+
</Carousel.Content>
|
|
98
|
+
|
|
99
|
+
<Carousel.Previous />
|
|
100
|
+
<Carousel.Next />
|
|
101
|
+
</Carousel>
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### **Custom Navigation**
|
|
108
|
+
Customize the navigation buttons with your own content.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<Carousel>
|
|
112
|
+
<Carousel.Content>
|
|
113
|
+
{/* Slides here */}
|
|
114
|
+
</Carousel.Content>
|
|
115
|
+
|
|
116
|
+
<Carousel.Previous>
|
|
117
|
+
Previous
|
|
118
|
+
</Carousel.Previous>
|
|
119
|
+
|
|
120
|
+
<Carousel.Next>
|
|
121
|
+
Next
|
|
122
|
+
</Carousel.Next>
|
|
123
|
+
</Carousel>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### **Step Navigation**
|
|
127
|
+
Restrict navigation to specific slide indices using the `stepIndices` prop.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import React, { useState } from 'react';
|
|
131
|
+
import { Carousel } from '../Carousel';
|
|
132
|
+
import { View } from 'app-studio';
|
|
133
|
+
import { Button } from '../../Button/Button';
|
|
134
|
+
|
|
135
|
+
export const StepIndicesDemo = () => {
|
|
136
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
137
|
+
|
|
138
|
+
// Create an array of slides
|
|
139
|
+
const slides = [
|
|
140
|
+
{ text: 'Introduction', id: 0 },
|
|
141
|
+
{ text: 'Step 1', id: 1 },
|
|
142
|
+
{ text: 'Step 2', id: 2 },
|
|
143
|
+
{ text: 'Step 3', id: 3 },
|
|
144
|
+
{ text: 'Step 4', id: 4 },
|
|
145
|
+
{ text: 'Summary', id: 5 },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
// Only allow navigation to specific slides
|
|
149
|
+
const stepIndices = [0, 2, 4, 5];
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<View height="300px" width="100%">
|
|
153
|
+
<Carousel
|
|
154
|
+
activeIndex={activeIndex}
|
|
155
|
+
onChange={setActiveIndex}
|
|
156
|
+
stepIndices={stepIndices}
|
|
157
|
+
>
|
|
158
|
+
{/* Slides here */}
|
|
159
|
+
</Carousel>
|
|
160
|
+
|
|
161
|
+
{/* External navigation */}
|
|
162
|
+
<Horizontal justifyContent="center" gap={4} marginTop={4}>
|
|
163
|
+
{stepIndices.map((index) => (
|
|
164
|
+
<Button
|
|
165
|
+
key={index}
|
|
166
|
+
onClick={() => setActiveIndex(index)}
|
|
167
|
+
variant={activeIndex === index ? 'filled' : 'outline'}
|
|
168
|
+
>
|
|
169
|
+
{slides[index].text}
|
|
170
|
+
</Button>
|
|
171
|
+
))}
|
|
172
|
+
</Horizontal>
|
|
173
|
+
</View>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### **Auto-Play**
|
|
179
|
+
Automatically advance through slides with customizable interval.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import React from 'react';
|
|
183
|
+
import { Carousel } from '../Carousel';
|
|
184
|
+
import { View } from 'app-studio';
|
|
185
|
+
import { Text } from '../../Text/Text';
|
|
186
|
+
|
|
187
|
+
export const AutoPlayDemo = () => {
|
|
188
|
+
const slides = [
|
|
189
|
+
{ color: 'color.red.500', text: 'Auto-play Slide 1' },
|
|
190
|
+
{ color: 'color.yellow.500', text: 'Auto-play Slide 2' },
|
|
191
|
+
{ color: 'color.teal.500', text: 'Auto-play Slide 3' },
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<View height="300px" width="100%">
|
|
196
|
+
<Carousel
|
|
197
|
+
autoPlay
|
|
198
|
+
autoPlayInterval={2000}
|
|
199
|
+
pauseOnHover
|
|
200
|
+
>
|
|
201
|
+
{slides.map((slide, index) => (
|
|
202
|
+
<View
|
|
203
|
+
key={index}
|
|
204
|
+
backgroundColor={slide.color}
|
|
205
|
+
width="100%"
|
|
206
|
+
height="100%"
|
|
207
|
+
display="flex"
|
|
208
|
+
alignItems="center"
|
|
209
|
+
justifyContent="center"
|
|
210
|
+
>
|
|
211
|
+
<Text color="white" fontSize="24px" fontWeight="bold">
|
|
212
|
+
{slide.text}
|
|
213
|
+
</Text>
|
|
214
|
+
</View>
|
|
215
|
+
))}
|
|
216
|
+
</Carousel>
|
|
217
|
+
</View>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### **Indicators**
|
|
223
|
+
Different styles of indicators to show the current slide position.
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
import React from 'react';
|
|
227
|
+
import { Carousel } from '../Carousel';
|
|
228
|
+
import { View } from 'app-studio';
|
|
229
|
+
import { Text } from '../../Text/Text';
|
|
230
|
+
|
|
231
|
+
export const IndicatorsDemo = () => {
|
|
232
|
+
const slides = [
|
|
233
|
+
{ color: 'color.indigo.500', text: 'Slide 1' },
|
|
234
|
+
{ color: 'color.cyan.500', text: 'Slide 2' },
|
|
235
|
+
{ color: 'color.amber.500', text: 'Slide 3' },
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<View height="300px" width="100%">
|
|
240
|
+
<Carousel
|
|
241
|
+
indicatorVariant="dot" // Options: 'dot', 'line', 'number'
|
|
242
|
+
indicatorPosition="bottom" // Options: 'top', 'bottom'
|
|
243
|
+
>
|
|
244
|
+
{slides.map((slide, index) => (
|
|
245
|
+
<View
|
|
246
|
+
key={index}
|
|
247
|
+
backgroundColor={slide.color}
|
|
248
|
+
width="100%"
|
|
249
|
+
height="100%"
|
|
250
|
+
display="flex"
|
|
251
|
+
alignItems="center"
|
|
252
|
+
justifyContent="center"
|
|
253
|
+
>
|
|
254
|
+
<Text color="white" fontSize="24px" fontWeight="bold">
|
|
255
|
+
{slide.text}
|
|
256
|
+
</Text>
|
|
257
|
+
</View>
|
|
258
|
+
))}
|
|
259
|
+
</Carousel>
|
|
260
|
+
</View>
|
|
261
|
+
);
|
|
262
|
+
};
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### **Navigation**
|
|
266
|
+
Customize the navigation controls.
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import React from 'react';
|
|
270
|
+
import { Carousel } from '../Carousel';
|
|
271
|
+
import { View } from 'app-studio';
|
|
272
|
+
import { Text } from '../../Text/Text';
|
|
273
|
+
import { Button } from '../../Button/Button';
|
|
274
|
+
|
|
275
|
+
export const NavigationDemo = () => {
|
|
276
|
+
const slides = [
|
|
277
|
+
{ color: 'color.blue.500', text: 'Slide 1' },
|
|
278
|
+
{ color: 'color.green.500', text: 'Slide 2' },
|
|
279
|
+
{ color: 'color.purple.500', text: 'Slide 3' },
|
|
280
|
+
];
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<View height="300px" width="100%">
|
|
284
|
+
<Carousel
|
|
285
|
+
navigationPosition="inside" // Options: 'inside', 'outside'
|
|
286
|
+
prevButton={
|
|
287
|
+
<Button size="sm" variant="outline">
|
|
288
|
+
Previous
|
|
289
|
+
</Button>
|
|
290
|
+
}
|
|
291
|
+
nextButton={
|
|
292
|
+
<Button size="sm" variant="outline">
|
|
293
|
+
Next
|
|
294
|
+
</Button>
|
|
295
|
+
}
|
|
296
|
+
>
|
|
297
|
+
{slides.map((slide, index) => (
|
|
298
|
+
<View
|
|
299
|
+
key={index}
|
|
300
|
+
backgroundColor={slide.color}
|
|
301
|
+
width="100%"
|
|
302
|
+
height="100%"
|
|
303
|
+
display="flex"
|
|
304
|
+
alignItems="center"
|
|
305
|
+
justifyContent="center"
|
|
306
|
+
>
|
|
307
|
+
<Text color="white" fontSize="24px" fontWeight="bold">
|
|
308
|
+
{slide.text}
|
|
309
|
+
</Text>
|
|
310
|
+
</View>
|
|
311
|
+
))}
|
|
312
|
+
</Carousel>
|
|
313
|
+
</View>
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### **Custom Styling**
|
|
319
|
+
Customize the appearance of the carousel.
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
import React from 'react';
|
|
323
|
+
import { Carousel } from '../Carousel';
|
|
324
|
+
import { View } from 'app-studio';
|
|
325
|
+
import { Text } from '../../Text/Text';
|
|
326
|
+
import { Card } from '../../Card/Card';
|
|
327
|
+
|
|
328
|
+
export const CustomDemo = () => {
|
|
329
|
+
const cards = [
|
|
330
|
+
{
|
|
331
|
+
title: 'Mountain Retreat',
|
|
332
|
+
description: 'Peaceful mountain cabin with stunning views.',
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
title: 'Beach Paradise',
|
|
336
|
+
description: 'Relax on white sandy beaches with crystal clear water.',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
title: 'City Adventure',
|
|
340
|
+
description: 'Explore the vibrant streets and culture of the city.',
|
|
341
|
+
},
|
|
342
|
+
];
|
|
343
|
+
|
|
344
|
+
return (
|
|
345
|
+
<View height="300px" width="100%">
|
|
346
|
+
<Carousel
|
|
347
|
+
views={{
|
|
348
|
+
container: {
|
|
349
|
+
borderRadius: '16px',
|
|
350
|
+
overflow: 'hidden',
|
|
351
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
352
|
+
},
|
|
353
|
+
indicators: {
|
|
354
|
+
bottom: '20px',
|
|
355
|
+
},
|
|
356
|
+
indicator: {
|
|
357
|
+
width: '30px',
|
|
358
|
+
height: '4px',
|
|
359
|
+
borderRadius: '2px',
|
|
360
|
+
backgroundColor: 'color.gray.200',
|
|
361
|
+
},
|
|
362
|
+
activeIndicator: {
|
|
363
|
+
backgroundColor: 'color.blue.500',
|
|
364
|
+
width: '40px',
|
|
365
|
+
},
|
|
366
|
+
prevButton: {
|
|
367
|
+
backgroundColor: 'color.blue.500',
|
|
368
|
+
color: 'color.white',
|
|
369
|
+
},
|
|
370
|
+
nextButton: {
|
|
371
|
+
backgroundColor: 'color.blue.500',
|
|
372
|
+
color: 'color.white',
|
|
373
|
+
},
|
|
374
|
+
}}
|
|
375
|
+
indicatorVariant="line"
|
|
376
|
+
>
|
|
377
|
+
{cards.map((card, index) => (
|
|
378
|
+
<View
|
|
379
|
+
key={index}
|
|
380
|
+
width="100%"
|
|
381
|
+
height="100%"
|
|
382
|
+
padding="20px"
|
|
383
|
+
backgroundColor="color.blue.50"
|
|
384
|
+
display="flex"
|
|
385
|
+
alignItems="center"
|
|
386
|
+
justifyContent="center"
|
|
387
|
+
>
|
|
388
|
+
<Card
|
|
389
|
+
variant="elevated"
|
|
390
|
+
width="80%"
|
|
391
|
+
maxWidth="500px"
|
|
392
|
+
padding="20px"
|
|
393
|
+
>
|
|
394
|
+
<Card.Header>
|
|
395
|
+
<Text fontSize="24px" fontWeight="bold">
|
|
396
|
+
{card.title}
|
|
397
|
+
</Text>
|
|
398
|
+
</Card.Header>
|
|
399
|
+
<Card.Content>
|
|
400
|
+
<Text fontSize="16px">
|
|
401
|
+
{card.description}
|
|
402
|
+
</Text>
|
|
403
|
+
</Card.Content>
|
|
404
|
+
</Card>
|
|
405
|
+
</View>
|
|
406
|
+
))}
|
|
407
|
+
</Carousel>
|
|
408
|
+
</View>
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
```
|