@app-studio/web 0.9.31 → 0.9.33
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/docs/components.md +285 -0
- package/package.json +1 -1
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
# Title
|
|
2
|
+
|
|
3
|
+
A component for rendering animated and highlighted titles in hero sections.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Title } from "@app-studio/web";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Default
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
<Title>Simple Hero Title</Title>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Sizes
|
|
18
|
+
|
|
19
|
+
The `size` prop changes the title size. It has a type `TitleSize` with default value `"xl"`.
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<Vertical gap={32}>
|
|
23
|
+
<Title size="xs">Extra Small Title</Title>
|
|
24
|
+
<Title size="sm">Small Title</Title>
|
|
25
|
+
<Title size="md">Medium Title</Title>
|
|
26
|
+
<Title size="lg">Large Title</Title>
|
|
27
|
+
<Title size="xl">Extra Large Title</Title>
|
|
28
|
+
</Vertical>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Highlight Text
|
|
32
|
+
|
|
33
|
+
The `highlightText` prop specifies which part of the text should be highlighted. You can provide a string or an array of strings.
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
<Title highlightText="highlighted" highlightStyle="background" highlightColor="theme.primary">
|
|
37
|
+
Text with highlighted words
|
|
38
|
+
</Title>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Highlight Styles
|
|
42
|
+
|
|
43
|
+
The `highlightStyle` prop determines how the highlighted text is styled. Options include `'background'`, `'underline'`, `'gradient'`, `'outline'`, and `'glow'`.
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
<Vertical gap={32}>
|
|
47
|
+
<Title highlightText="background" highlightStyle="background" highlightColor="theme.primary">
|
|
48
|
+
Text with background highlight
|
|
49
|
+
</Title>
|
|
50
|
+
|
|
51
|
+
<Title highlightText="underlined" highlightStyle="underline" highlightColor="theme.secondary">
|
|
52
|
+
Text with underlined highlight
|
|
53
|
+
</Title>
|
|
54
|
+
|
|
55
|
+
<Title
|
|
56
|
+
highlightText="gradient"
|
|
57
|
+
highlightStyle="gradient"
|
|
58
|
+
highlightColor="theme.primary"
|
|
59
|
+
highlightSecondaryColor="theme.secondary"
|
|
60
|
+
>
|
|
61
|
+
Text with gradient highlight
|
|
62
|
+
</Title>
|
|
63
|
+
|
|
64
|
+
<Title highlightText="outline" highlightStyle="outline" highlightColor="theme.primary">
|
|
65
|
+
Text with outline highlight
|
|
66
|
+
</Title>
|
|
67
|
+
|
|
68
|
+
<Title highlightText="glow" highlightStyle="glow" highlightColor="theme.primary">
|
|
69
|
+
Text with glow highlight
|
|
70
|
+
</Title>
|
|
71
|
+
</Vertical>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Multiple Highlights
|
|
75
|
+
|
|
76
|
+
You can highlight multiple parts of the text by providing an array of strings.
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
<Title
|
|
80
|
+
highlightText={["multiple", "highlights"]}
|
|
81
|
+
highlightStyle="background"
|
|
82
|
+
highlightColor="theme.primary"
|
|
83
|
+
>
|
|
84
|
+
Text with multiple highlights in the same sentence
|
|
85
|
+
</Title>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Animations
|
|
89
|
+
|
|
90
|
+
The Title component supports animations through the `animate` prop, which accepts an animation object with properties like `from`, `to`, `duration`, etc.
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
<Vertical gap={48}>
|
|
94
|
+
<Title
|
|
95
|
+
animate={{
|
|
96
|
+
from: { opacity: 0 },
|
|
97
|
+
to: { opacity: 1 },
|
|
98
|
+
duration: '1.5s',
|
|
99
|
+
}}
|
|
100
|
+
animationLoop={1}
|
|
101
|
+
>
|
|
102
|
+
Fade In Animation (Once)
|
|
103
|
+
</Title>
|
|
104
|
+
|
|
105
|
+
<Title
|
|
106
|
+
animate={{
|
|
107
|
+
from: { transform: 'translateX(-100%)' },
|
|
108
|
+
to: { transform: 'translateX(0)' },
|
|
109
|
+
duration: '1s',
|
|
110
|
+
}}
|
|
111
|
+
animationLoop={3}
|
|
112
|
+
>
|
|
113
|
+
Slide In From Left (3 Times)
|
|
114
|
+
</Title>
|
|
115
|
+
|
|
116
|
+
<Title
|
|
117
|
+
animate={{
|
|
118
|
+
from: { transform: 'translateX(-10px)' },
|
|
119
|
+
to: { transform: 'translateX(10px)' },
|
|
120
|
+
duration: '2s',
|
|
121
|
+
direction: 'alternate',
|
|
122
|
+
}}
|
|
123
|
+
animationLoop="infinite"
|
|
124
|
+
>
|
|
125
|
+
Infinite Wiggle Animation
|
|
126
|
+
</Title>
|
|
127
|
+
</Vertical>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Animation Loop Control
|
|
131
|
+
|
|
132
|
+
You can control how many times animations repeat using the `animationLoop` and `highlightAnimationLoop` props.
|
|
133
|
+
|
|
134
|
+
```jsx
|
|
135
|
+
<Vertical gap={32}>
|
|
136
|
+
{/* Animation plays once (default) */}
|
|
137
|
+
<Title
|
|
138
|
+
animate={{
|
|
139
|
+
from: { opacity: 0, transform: 'translateY(-20px)' },
|
|
140
|
+
to: { opacity: 1, transform: 'translateY(0)' },
|
|
141
|
+
duration: '1s',
|
|
142
|
+
}}
|
|
143
|
+
animationLoop={1}
|
|
144
|
+
>
|
|
145
|
+
Animation Plays Once
|
|
146
|
+
</Title>
|
|
147
|
+
|
|
148
|
+
{/* Animation plays 3 times */}
|
|
149
|
+
<Title
|
|
150
|
+
animate={{
|
|
151
|
+
from: { transform: 'scale(0.8)' },
|
|
152
|
+
to: { transform: 'scale(1)' },
|
|
153
|
+
duration: '0.8s',
|
|
154
|
+
}}
|
|
155
|
+
animationLoop={3}
|
|
156
|
+
>
|
|
157
|
+
Animation Plays Three Times
|
|
158
|
+
</Title>
|
|
159
|
+
|
|
160
|
+
{/* Infinite animation loop */}
|
|
161
|
+
<Title
|
|
162
|
+
animate={{
|
|
163
|
+
from: { transform: 'translateX(-10px)' },
|
|
164
|
+
to: { transform: 'translateX(10px)' },
|
|
165
|
+
duration: '2s',
|
|
166
|
+
direction: 'alternate',
|
|
167
|
+
}}
|
|
168
|
+
animationLoop="infinite"
|
|
169
|
+
>
|
|
170
|
+
Animation Loops Infinitely
|
|
171
|
+
</Title>
|
|
172
|
+
|
|
173
|
+
{/* Highlight animation with infinite loop */}
|
|
174
|
+
<Title
|
|
175
|
+
highlightAnimate={{
|
|
176
|
+
from: { transform: 'rotate(-5deg)' },
|
|
177
|
+
to: { transform: 'rotate(5deg)' },
|
|
178
|
+
duration: '1s',
|
|
179
|
+
direction: 'alternate',
|
|
180
|
+
}}
|
|
181
|
+
highlightAnimationLoop="infinite"
|
|
182
|
+
highlightText="Wiggling"
|
|
183
|
+
highlightStyle="outline"
|
|
184
|
+
highlightColor="theme.warning"
|
|
185
|
+
>
|
|
186
|
+
Title with Wiggling Highlight
|
|
187
|
+
</Title>
|
|
188
|
+
</Vertical>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Highlight Animations
|
|
192
|
+
|
|
193
|
+
You can animate just the highlighted text using the `highlightAnimate` prop.
|
|
194
|
+
|
|
195
|
+
```jsx
|
|
196
|
+
<Title
|
|
197
|
+
highlightText="animated highlight"
|
|
198
|
+
highlightStyle="background"
|
|
199
|
+
highlightColor="theme.primary"
|
|
200
|
+
highlightAnimate={{
|
|
201
|
+
from: { opacity: 0, transform: 'scale(0.9)' },
|
|
202
|
+
to: { opacity: 1, transform: 'scale(1)' },
|
|
203
|
+
duration: '0.5s',
|
|
204
|
+
delay: '0.2s',
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
Text with animated highlight
|
|
208
|
+
</Title>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Alternating Text
|
|
212
|
+
|
|
213
|
+
The Title component can cycle through different words in place of the highlighted text using the `alternateHighlightText` and `alternateAnimation` props.
|
|
214
|
+
|
|
215
|
+
```jsx
|
|
216
|
+
<Title
|
|
217
|
+
highlightText="changing"
|
|
218
|
+
alternateHighlightText={[
|
|
219
|
+
'innovative',
|
|
220
|
+
'powerful',
|
|
221
|
+
'flexible',
|
|
222
|
+
'intuitive',
|
|
223
|
+
]}
|
|
224
|
+
alternateAnimation={true}
|
|
225
|
+
alternateDuration={2000}
|
|
226
|
+
highlightStyle="background"
|
|
227
|
+
highlightColor="theme.primary"
|
|
228
|
+
>
|
|
229
|
+
Our changing solution for your business
|
|
230
|
+
</Title>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Typewriter Effect
|
|
234
|
+
|
|
235
|
+
You can add a typewriter effect to the highlighted text using the `highlightTypewriter` prop.
|
|
236
|
+
|
|
237
|
+
```jsx
|
|
238
|
+
<Title
|
|
239
|
+
highlightText="typewriter"
|
|
240
|
+
highlightStyle="background"
|
|
241
|
+
highlightColor="theme.primary"
|
|
242
|
+
highlightTypewriter={true}
|
|
243
|
+
highlightTypewriterDuration={1500}
|
|
244
|
+
>
|
|
245
|
+
This text has a typewriter effect on the highlighted word
|
|
246
|
+
</Title>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Responsive
|
|
250
|
+
|
|
251
|
+
You can make the title responsive in two ways:
|
|
252
|
+
|
|
253
|
+
### Using the `responsive` prop (Recommended)
|
|
254
|
+
|
|
255
|
+
The `responsive` prop automatically applies responsive sizing based on the current `size` prop using a predefined typography scale:
|
|
256
|
+
|
|
257
|
+
```jsx
|
|
258
|
+
<Title
|
|
259
|
+
size="xl"
|
|
260
|
+
responsive={true}
|
|
261
|
+
highlightText="Responsive"
|
|
262
|
+
highlightStyle="background"
|
|
263
|
+
highlightColor="theme.primary"
|
|
264
|
+
>
|
|
265
|
+
Responsive XL Title (H1 scale)
|
|
266
|
+
</Title>
|
|
267
|
+
|
|
268
|
+
<Title
|
|
269
|
+
size="lg"
|
|
270
|
+
responsive={true}
|
|
271
|
+
highlightText="Responsive"
|
|
272
|
+
highlightStyle="gradient"
|
|
273
|
+
highlightColor="theme.primary"
|
|
274
|
+
highlightSecondaryColor="theme.secondary"
|
|
275
|
+
>
|
|
276
|
+
Responsive LG Title (H2 scale)
|
|
277
|
+
</Title>
|
|
278
|
+
|
|
279
|
+
<Title
|
|
280
|
+
size="md"
|
|
281
|
+
responsive={true}
|
|
282
|
+
highlightText="Responsive"
|
|
283
|
+
highlightStyle="underline"
|
|
284
|
+
highlightColor="theme.accent"
|
|
285
|
+
>
|
|
286
|
+
Responsive MD Title (H3 scale)
|
|
287
|
+
</Title>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The responsive prop maps sizes to typography scales:
|
|
291
|
+
- `xl` → H1 scale (46px mobile, 52px tablet, 58px desktop)
|
|
292
|
+
- `lg` → H2 scale (28px mobile, 36px tablet, 48px desktop)
|
|
293
|
+
- `md` → H3 scale (28px mobile, 34px tablet, 40px desktop)
|
|
294
|
+
- `sm` → T1 scale (24px mobile, 28px tablet, 32px desktop)
|
|
295
|
+
- `xs` → S1 scale (16px mobile, 18px tablet, 20px desktop)
|
|
296
|
+
|
|
297
|
+
### Using the `media` prop (Manual)
|
|
298
|
+
|
|
299
|
+
For custom responsive behavior, you can use the `media` prop:
|
|
300
|
+
|
|
301
|
+
```jsx
|
|
302
|
+
<Title
|
|
303
|
+
media={{
|
|
304
|
+
mobile: {
|
|
305
|
+
fontSize: 32,
|
|
306
|
+
lineHeight: '40px',
|
|
307
|
+
},
|
|
308
|
+
tablet: {
|
|
309
|
+
fontSize: 48,
|
|
310
|
+
lineHeight: '56px',
|
|
311
|
+
},
|
|
312
|
+
desktop: {
|
|
313
|
+
fontSize: 64,
|
|
314
|
+
lineHeight: '72px',
|
|
315
|
+
},
|
|
316
|
+
}}
|
|
317
|
+
highlightText="Responsive"
|
|
318
|
+
highlightStyle="background"
|
|
319
|
+
highlightColor="theme.primary"
|
|
320
|
+
>
|
|
321
|
+
Manual Responsive Title
|
|
322
|
+
</Title>
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Custom Styling
|
|
326
|
+
|
|
327
|
+
You can customize the title using the `views` prop.
|
|
328
|
+
|
|
329
|
+
```jsx
|
|
330
|
+
<Title
|
|
331
|
+
views={{
|
|
332
|
+
container: {
|
|
333
|
+
fontFamily: 'Georgia, serif',
|
|
334
|
+
letterSpacing: '0.05em',
|
|
335
|
+
textTransform: 'uppercase',
|
|
336
|
+
},
|
|
337
|
+
highlight: {
|
|
338
|
+
borderRadius: '8px',
|
|
339
|
+
padding: '0 12px',
|
|
340
|
+
},
|
|
341
|
+
}}
|
|
342
|
+
highlightText="Custom"
|
|
343
|
+
highlightStyle="background"
|
|
344
|
+
highlightColor="color.purple.500"
|
|
345
|
+
>
|
|
346
|
+
Title with Custom Styling
|
|
347
|
+
</Title>
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Hero Section Example
|
|
351
|
+
|
|
352
|
+
```jsx
|
|
353
|
+
<View
|
|
354
|
+
backgroundColor="color.gray.50"
|
|
355
|
+
padding={48}
|
|
356
|
+
borderRadius={8}
|
|
357
|
+
width="100%"
|
|
358
|
+
>
|
|
359
|
+
<Vertical gap={24} maxWidth={800} marginX="auto">
|
|
360
|
+
<Title
|
|
361
|
+
size="xl"
|
|
362
|
+
animate={{
|
|
363
|
+
from: { opacity: 0 },
|
|
364
|
+
to: { opacity: 1 },
|
|
365
|
+
duration: '1s',
|
|
366
|
+
iterationCount: '1',
|
|
367
|
+
}}
|
|
368
|
+
highlightText="Platform"
|
|
369
|
+
highlightStyle="gradient"
|
|
370
|
+
highlightColor="theme.primary"
|
|
371
|
+
highlightSecondaryColor="theme.secondary"
|
|
372
|
+
centered
|
|
373
|
+
>
|
|
374
|
+
Welcome to Our Platform
|
|
375
|
+
</Title>
|
|
376
|
+
|
|
377
|
+
<Text
|
|
378
|
+
textAlign="center"
|
|
379
|
+
color="color.gray.600"
|
|
380
|
+
fontSize={20}
|
|
381
|
+
lineHeight={28}
|
|
382
|
+
>
|
|
383
|
+
Build beautiful, responsive, and interactive user interfaces with our powerful component library.
|
|
384
|
+
</Text>
|
|
385
|
+
|
|
386
|
+
<Horizontal gap={16} justifyContent="center" marginTop={16}>
|
|
387
|
+
<Button variant="primary" size="lg">
|
|
388
|
+
Get Started
|
|
389
|
+
</Button>
|
|
390
|
+
<Button variant="outline" size="lg">
|
|
391
|
+
Learn More
|
|
392
|
+
</Button>
|
|
393
|
+
</Horizontal>
|
|
394
|
+
</Vertical>
|
|
395
|
+
</View>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## Types
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
export type HighlightStyle =
|
|
402
|
+
| 'underline' // Underline the text
|
|
403
|
+
| 'background' // Background color highlight
|
|
404
|
+
| 'gradient' // Gradient background
|
|
405
|
+
| 'outline' // Text with outline
|
|
406
|
+
| 'glow'; // Text with glow effect
|
|
407
|
+
|
|
408
|
+
export type TitleSize =
|
|
409
|
+
| 'xs'
|
|
410
|
+
| 'sm'
|
|
411
|
+
| 'md'
|
|
412
|
+
| 'lg'
|
|
413
|
+
| 'xl';
|
|
414
|
+
|
|
415
|
+
export interface TitleProps extends ViewProps {
|
|
416
|
+
/**
|
|
417
|
+
* The main text content of the title
|
|
418
|
+
*/
|
|
419
|
+
children: React.ReactNode;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Text to be highlighted within the title
|
|
423
|
+
*/
|
|
424
|
+
highlightText?: string | string[];
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Array of strings to cycle through, replacing the text specified in highlightText
|
|
428
|
+
*/
|
|
429
|
+
alternateHighlightText?: string[];
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The visual style of the highlighted text
|
|
433
|
+
* @default 'background'
|
|
434
|
+
*/
|
|
435
|
+
highlightStyle?: HighlightStyle;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* The color of the highlighted text or background
|
|
439
|
+
* @default 'theme.primary'
|
|
440
|
+
*/
|
|
441
|
+
highlightColor?: string;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The secondary color for gradient highlights
|
|
445
|
+
*/
|
|
446
|
+
highlightSecondaryColor?: string;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Animation for the highlighted text
|
|
450
|
+
*/
|
|
451
|
+
highlightAnimate?: AnimationProps | AnimationProps[];
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Animation for the title
|
|
455
|
+
*/
|
|
456
|
+
animate?: AnimationProps | AnimationProps[];
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Controls the animation loop behavior for the title animation
|
|
460
|
+
* @default 1 (play once)
|
|
461
|
+
*/
|
|
462
|
+
animationLoop?: number | 'infinite';
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Controls the animation loop behavior for the highlight animation
|
|
466
|
+
* @default 1 (play once)
|
|
467
|
+
*/
|
|
468
|
+
highlightAnimationLoop?: number | 'infinite';
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Size of the title
|
|
472
|
+
* @default 'xl'
|
|
473
|
+
*/
|
|
474
|
+
size?: TitleSize;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Whether to enable responsive sizing based on breakpoints
|
|
478
|
+
* When true, the title will automatically adapt its size across mobile/tablet/desktop
|
|
479
|
+
* @default false
|
|
480
|
+
*/
|
|
481
|
+
responsive?: boolean;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Whether to center the title
|
|
485
|
+
* @default false
|
|
486
|
+
*/
|
|
487
|
+
centered?: boolean;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Whether to animate the alternating highlight text
|
|
491
|
+
* @default false
|
|
492
|
+
*/
|
|
493
|
+
alternateAnimation?: boolean;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Duration in milliseconds for each alternating highlight text
|
|
497
|
+
* @default 3000
|
|
498
|
+
*/
|
|
499
|
+
alternateDuration?: number;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Whether to apply a typewriter effect to the highlighted text
|
|
503
|
+
* @default false
|
|
504
|
+
*/
|
|
505
|
+
highlightTypewriter?: boolean;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Duration in milliseconds for the typewriter effect
|
|
509
|
+
* @default 3000
|
|
510
|
+
*/
|
|
511
|
+
highlightTypewriterDuration?: number;
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## **Accessibility**
|
|
516
|
+
|
|
517
|
+
The Title component:
|
|
518
|
+
|
|
519
|
+
- Uses semantic heading elements (`<h1>`) for proper document structure
|
|
520
|
+
- Maintains proper color contrast for highlighted text
|
|
521
|
+
- Supports keyboard navigation and focus management
|
|
522
|
+
- Works with screen readers by using appropriate ARIA attributes
|
|
523
|
+
|
|
524
|
+
## **Best Practices**
|
|
525
|
+
|
|
526
|
+
- Use the Title component for main headings and important text that needs emphasis
|
|
527
|
+
- Choose highlight styles that maintain good contrast with the background
|
|
528
|
+
- Use animations sparingly to avoid distracting users
|
|
529
|
+
- Use `animationLoop` and `highlightAnimationLoop` to control animation repetition
|
|
530
|
+
- Prefer finite loop counts over infinite animations for better user experience
|
|
531
|
+
- Use the `responsive` prop for automatic responsive sizing based on predefined typography scales
|
|
532
|
+
- Consider using responsive sizing for different screen sizes
|
|
533
|
+
- Limit the use of alternating text to avoid confusion
|
|
534
|
+
- Ensure that any animations respect user preferences for reduced motion
|
|
535
|
+
- Use semantic colors from the theme system rather than hardcoded values
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
A succinct message that is displayed temporarily.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Toast } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Default**
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Button } from '@app-studio/web';
|
|
14
|
+
import { Toast } from '@app-studio/web';
|
|
15
|
+
|
|
16
|
+
export const DefaultToast = () => {
|
|
17
|
+
return (
|
|
18
|
+
<Button
|
|
19
|
+
onClick={() =>
|
|
20
|
+
Toast.success('Success', 'Your action was completed successfully.')
|
|
21
|
+
}
|
|
22
|
+
>
|
|
23
|
+
Show Success Toast
|
|
24
|
+
</Button>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### **Variants**
|
|
30
|
+
The Toast component supports different variants:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
// Info toast
|
|
34
|
+
Toast.info('Information', 'This is an informational message.');
|
|
35
|
+
|
|
36
|
+
// Success toast
|
|
37
|
+
Toast.success('Success', 'Your action was completed successfully.');
|
|
38
|
+
|
|
39
|
+
// Warning toast
|
|
40
|
+
Toast.warning('Warning', 'Please be careful with this action.');
|
|
41
|
+
|
|
42
|
+
// Error toast
|
|
43
|
+
Toast.error('Error', 'An error occurred while processing your request.');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### **Positions**
|
|
47
|
+
The Toast component can be positioned in different areas of the screen:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
// Top position
|
|
51
|
+
Toast.info('Top Toast', 'This toast appears at the top.', { position: 'top' });
|
|
52
|
+
|
|
53
|
+
// Top-right position (default)
|
|
54
|
+
Toast.info('Top Right Toast', 'This toast appears at the top-right.', { position: 'top-right' });
|
|
55
|
+
|
|
56
|
+
// Top-left position
|
|
57
|
+
Toast.info('Top Left Toast', 'This toast appears at the top-left.', { position: 'top-left' });
|
|
58
|
+
|
|
59
|
+
// Bottom position
|
|
60
|
+
Toast.info('Bottom Toast', 'This toast appears at the bottom.', { position: 'bottom' });
|
|
61
|
+
|
|
62
|
+
// Bottom-right position
|
|
63
|
+
Toast.info('Bottom Right Toast', 'This toast appears at the bottom-right.', { position: 'bottom-right' });
|
|
64
|
+
|
|
65
|
+
// Bottom-left position
|
|
66
|
+
Toast.info('Bottom Left Toast', 'This toast appears at the bottom-left.', { position: 'bottom-left' });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### **Duration**
|
|
70
|
+
The Toast component can be displayed for different durations:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
// Short duration (2 seconds)
|
|
74
|
+
Toast.info('Short Duration', 'This toast will disappear in 2 seconds.', {
|
|
75
|
+
duration: 2000,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Default duration (5 seconds)
|
|
79
|
+
Toast.info('Default Duration', 'This toast will disappear in 5 seconds.');
|
|
80
|
+
|
|
81
|
+
// Long duration (10 seconds)
|
|
82
|
+
Toast.info('Long Duration', 'This toast will disappear in 10 seconds.', {
|
|
83
|
+
duration: 10000,
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### **Actions**
|
|
88
|
+
The Toast component can include action buttons:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// Toast with an undo action
|
|
92
|
+
Toast.success('Item Deleted', 'The item has been successfully deleted.', {
|
|
93
|
+
action: () => {
|
|
94
|
+
// Handle undo action
|
|
95
|
+
console.log('Undo action triggered');
|
|
96
|
+
},
|
|
97
|
+
actionText: 'Undo',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Toast with a retry action
|
|
101
|
+
Toast.error('Failed to Save', 'There was an error saving your changes.', {
|
|
102
|
+
action: () => {
|
|
103
|
+
// Handle retry action
|
|
104
|
+
console.log('Retry action triggered');
|
|
105
|
+
},
|
|
106
|
+
actionText: 'Retry',
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### **Customization**
|
|
111
|
+
The Toast component can be customized:
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
// Custom styled toast
|
|
115
|
+
Toast.info('Custom Styled Toast', 'This toast has custom styling.', {
|
|
116
|
+
views: {
|
|
117
|
+
container: {
|
|
118
|
+
backgroundColor: 'color.purple.50',
|
|
119
|
+
borderColor: 'color.purple.300',
|
|
120
|
+
borderRadius: '12px',
|
|
121
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
122
|
+
},
|
|
123
|
+
title: {
|
|
124
|
+
color: 'color.purple.700',
|
|
125
|
+
fontSize: '18px',
|
|
126
|
+
},
|
|
127
|
+
description: {
|
|
128
|
+
color: 'color.purple.600',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
showIcon: false,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Toast without a close button
|
|
135
|
+
Toast.success('No Close Button', 'This toast does not have a close button.', {
|
|
136
|
+
isClosable: false,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Toast without an icon
|
|
140
|
+
Toast.warning('No Icon', 'This toast does not display an icon.', {
|
|
141
|
+
showIcon: false,
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### **Toast Container**
|
|
146
|
+
The Toast component requires a container to be rendered:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
// Add this to your app's root component or layout
|
|
150
|
+
<Toast.Container position="top-right" />
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### **Programmatic Control**
|
|
154
|
+
The Toast component can be controlled programmatically:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
// Show a toast and get its ID
|
|
158
|
+
const toastId = Toast.info('Hello', 'This is a toast message');
|
|
159
|
+
|
|
160
|
+
// Remove a specific toast
|
|
161
|
+
Toast.remove(toastId);
|
|
162
|
+
|
|
163
|
+
// Remove all toasts
|
|
164
|
+
Toast.removeAll();
|
|
165
|
+
```
|