-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpreviews.tsx
More file actions
2361 lines (2233 loc) · 72.1 KB
/
previews.tsx
File metadata and controls
2361 lines (2233 loc) · 72.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"use client";
import { useState } from 'react';
import { createPortal } from 'react-dom';
import { motion, AnimatePresence } from 'framer-motion';
import {
Plus,
Settings,
Heart,
Share2,
Trash2,
Download,
LayoutDashboard,
Zap,
} from 'lucide-react';
import {
Accordion,
AccordionItem,
AccordionTrigger,
AccordionContent,
Avatar,
AvatarGroup,
Button,
Input,
Checkbox,
Switch,
Select,
Badge,
Skeleton,
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
DateSelect,
Dialog,
DialogTrigger,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
DialogClose,
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
Image,
Modal,
Popover,
PopoverTrigger,
PopoverContent,
Progress,
CircularProgress,
Reveal,
SearchInput,
Sidebar,
Slider,
MultiSelect,
Table,
TableHead,
TableBody,
TableRow,
TableHeaderCell,
TableCell,
Tabs,
TabsList,
TabsTrigger,
TabsContent,
Textarea,
Tooltip,
TooltipTrigger,
TooltipContent,
Upload,
ContextMenu,
LineChart,
BarChart,
AreaChart,
PieChart,
DonutChart,
StackedBarChart,
CloseButton,
Topbar,
} from '@pikoloo/darwin-ui';
import { containerVariants, itemVariants } from './animations';
// Component preview wrapper with animations
export function AnimatedPreviewWrapper({ children, componentKey }: { children: React.ReactNode; componentKey: string }) {
return (
<AnimatePresence mode="wait">
<motion.div
key={componentKey}
className="component-preview"
initial={{ opacity: 0, scale: 0.95, filter: "blur(4px)" }}
animate={{
opacity: 1,
scale: 1,
filter: "blur(0px)",
transition: {
type: "spring",
stiffness: 300,
damping: 25
}
}}
exit={{
opacity: 0,
scale: 0.95,
filter: "blur(4px)",
transition: { duration: 0.2 }
}}
>
{children}
</motion.div>
</AnimatePresence>
);
}
// Button preview with micro-interactions
function ButtonPreview() {
const [loading, setLoading] = useState(false);
const handleLoadingClick = () => {
setLoading(true);
setTimeout(() => setLoading(false), 2000);
};
return (
<motion.div
className="space-y-6"
variants={containerVariants}
initial="hidden"
animate="show"
>
{/* Text Buttons */}
<div>
<div className="text-xs text-muted-foreground mb-3 uppercase tracking-wider">Text Buttons</div>
<div className="flex flex-wrap gap-3">
{[
{ variant: 'primary' as const, label: 'Primary' },
{ variant: 'secondary' as const, label: 'Secondary' },
{ variant: 'outline' as const, label: 'Outline' },
{ variant: 'ghost' as const, label: 'Ghost' },
{ variant: 'destructive' as const, label: 'Destructive' },
].map((btn, i) => (
<motion.div
key={btn.variant}
variants={itemVariants}
custom={i}
whileHover={{ y: -2 }}
whileTap={{ scale: 0.95 }}
>
<Button type="button" variant={btn.variant}>{btn.label}</Button>
</motion.div>
))}
<motion.div
variants={itemVariants}
whileHover={{ y: -2 }}
whileTap={{ scale: 0.95 }}
>
<Button type="button" variant="primary" loading={loading} onClick={handleLoadingClick}>
{loading ? 'Loading...' : 'Click me'}
</Button>
</motion.div>
</div>
</div>
{/* Icon Buttons */}
<div>
<div className="text-xs text-muted-foreground mb-3 uppercase tracking-wider">Icon Buttons</div>
<div className="flex flex-wrap gap-3 items-center">
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="primary" size="icon">
<Plus className="h-4 w-4" />
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="secondary" size="icon">
<Settings className="h-4 w-4" />
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="outline" size="icon">
<Heart className="h-4 w-4" />
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="ghost" size="icon">
<Share2 className="h-4 w-4" />
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="destructive" size="icon">
<Trash2 className="h-4 w-4" />
</Button>
</motion.div>
</div>
</div>
{/* Buttons with Icons */}
<div>
<div className="text-xs text-muted-foreground mb-3 uppercase tracking-wider">With Icons</div>
<div className="flex flex-wrap gap-3">
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="primary">
<Plus className="h-4 w-4 mr-2" />
Create New
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="secondary">
<Download className="h-4 w-4 mr-2" />
Download
</Button>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ y: -2 }} whileTap={{ scale: 0.95 }}>
<Button type="button" variant="outline">
<Share2 className="h-4 w-4 mr-2" />
Share
</Button>
</motion.div>
</div>
</div>
</motion.div>
);
}
function InputPreview() {
const [value, setValue] = useState('');
const [errorValue, setErrorValue] = useState('');
const [successValue, setSuccessValue] = useState('Valid input');
return (
<motion.div
className="flex flex-col gap-3 w-full max-w-xs"
variants={containerVariants}
initial="hidden"
animate="show"
>
{[
{ placeholder: 'Type something...', value, onChange: setValue, state: {} },
{ placeholder: 'Error state', value: errorValue, onChange: setErrorValue, state: { error: true } },
{ placeholder: 'Success state', value: successValue, onChange: setSuccessValue, state: { success: true } },
].map((input, i) => (
<motion.div
key={input.placeholder}
variants={itemVariants}
custom={i}
whileFocus={{ scale: 1.02 }}
>
<Input
placeholder={input.placeholder}
value={input.value}
onChange={(e) => input.onChange(e.target.value)}
{...input.state}
/>
</motion.div>
))}
</motion.div>
);
}
function CheckboxPreview() {
const [checked1, setChecked1] = useState(false);
const [checked2, setChecked2] = useState(true);
const [checked3, setChecked3] = useState(false);
return (
<motion.div
className="flex flex-col gap-3"
variants={containerVariants}
initial="hidden"
animate="show"
>
{[
{ label: 'Unchecked option', checked: checked1, onChange: setChecked1 },
{ label: 'Checked option', checked: checked2, onChange: setChecked2 },
{ label: 'Indeterminate', checked: checked3, onChange: setChecked3, indeterminate: !checked3 },
].map((cb, i) => (
<motion.div
key={cb.label}
variants={itemVariants}
custom={i}
whileHover={{ x: 4 }}
whileTap={{ scale: 0.98 }}
>
<Checkbox
label={cb.label}
checked={cb.checked}
onChange={cb.onChange}
indeterminate={cb.indeterminate}
/>
</motion.div>
))}
</motion.div>
);
}
function SelectPreview() {
const [value, setValue] = useState('option1');
return (
<motion.div
className="w-full max-w-xs"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ type: "spring", stiffness: 300, damping: 25 }}
>
<motion.div whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }}>
<Select
value={value}
onChange={(e) => setValue(e.target.value)}
>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</Select>
</motion.div>
</motion.div>
);
}
function WindowPreview() {
return (
<motion.div
className="w-full max-w-sm"
initial={{ opacity: 0, y: 20, scale: 0.9 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
transition={{ type: "spring", stiffness: 300, damping: 25 }}
>
<div className="rounded-lg border border-border bg-card shadow-sm overflow-hidden">
<div className="flex items-center justify-between border-b border-border px-3 py-2 bg-muted/50">
<motion.div
className="flex gap-1.5"
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay: 0.2 }}
>
{['bg-red-500', 'bg-yellow-500', 'bg-green-500'].map((color, i) => (
<motion.div
key={color}
className={`w-3 h-3 rounded-full ${color}`}
initial={{ scale: 0 }}
animate={{ scale: 1 }}
transition={{ delay: 0.3 + i * 0.1, type: "spring", stiffness: 500, damping: 15 }}
whileHover={{ scale: 1.2 }}
/>
))}
</motion.div>
<motion.div
className="text-xs font-medium text-muted-foreground"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 0.4 }}
>
My Window
</motion.div>
<div className="w-12" />
</div>
<motion.div
className="p-4 text-sm text-muted-foreground"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 0.5 }}
>
Window content goes here...
</motion.div>
</div>
</motion.div>
);
}
// Badge Preview
function BadgePreview() {
return (
<motion.div
className="flex flex-wrap gap-2"
variants={containerVariants}
initial="hidden"
animate="show"
>
{[
{ variant: undefined, label: 'Default' },
{ variant: 'secondary' as const, label: 'Secondary' },
{ variant: 'outline' as const, label: 'Outline' },
{ variant: 'success' as const, label: 'Success' },
{ variant: 'warning' as const, label: 'Warning' },
{ variant: 'destructive' as const, label: 'Destructive' },
{ variant: 'info' as const, label: 'Info' },
{ variant: 'new' as const, label: 'New' },
].map((badge, i) => (
<motion.div
key={badge.label}
variants={itemVariants}
custom={i}
whileHover={{ scale: 1.1, y: -2 }}
whileTap={{ scale: 0.95 }}
>
<Badge variant={badge.variant}>{badge.label}</Badge>
</motion.div>
))}
</motion.div>
);
}
// Card Preview
function CardPreview() {
return (
<motion.div
className="w-full max-w-sm"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ type: "spring", stiffness: 300, damping: 25 }}
>
<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>This is a description of the card content.</CardDescription>
</CardHeader>
<CardContent>
<p className="text-muted-foreground text-sm">
Cards can contain any content including text, images, and other components.
</p>
</CardContent>
<CardFooter className="flex gap-2">
<Button type="button" variant="primary" size="sm">Action</Button>
<Button type="button" variant="ghost" size="sm">Cancel</Button>
</CardFooter>
</Card>
</motion.div>
);
}
// Charts Preview with dynamic switching
type ChartType = 'bar' | 'line' | 'area' | 'stacked' | 'pie' | 'donut';
function ChartsPreview() {
const [chartType, setChartType] = useState<ChartType>('bar');
// Time-series data for bar/line/area/stacked
const timeSeriesData = [
{ name: 'Jan', revenue: 4000, expenses: 2400, profit: 1600 },
{ name: 'Feb', revenue: 3000, expenses: 1398, profit: 1602 },
{ name: 'Mar', revenue: 5000, expenses: 3200, profit: 1800 },
{ name: 'Apr', revenue: 2780, expenses: 1908, profit: 872 },
{ name: 'May', revenue: 1890, expenses: 1200, profit: 690 },
];
// Category data for pie/donut
const pieData = [
{ category: 'Product A', sales: 400 },
{ category: 'Product B', sales: 300 },
{ category: 'Product C', sales: 200 },
{ category: 'Product D', sales: 100 },
];
const chartTypeOptions: { value: ChartType; label: string }[] = [
{ value: 'bar', label: 'Bar' },
{ value: 'line', label: 'Line' },
{ value: 'area', label: 'Area' },
{ value: 'stacked', label: 'Stacked' },
{ value: 'pie', label: 'Pie' },
{ value: 'donut', label: 'Donut' },
];
const renderChart = () => {
switch (chartType) {
case 'bar':
return (
<BarChart
data={timeSeriesData}
xKey="name"
bars={[
{ dataKey: 'revenue', name: 'Revenue', fill: '#60a5fa' },
{ dataKey: 'expenses', name: 'Expenses', fill: '#f87171' },
]}
height={220}
showLegend
/>
);
case 'line':
return (
<LineChart
data={timeSeriesData}
xKey="name"
lines={[
{ dataKey: 'revenue', name: 'Revenue', stroke: '#60a5fa' },
{ dataKey: 'expenses', name: 'Expenses', stroke: '#34d399' },
]}
height={220}
showLegend
/>
);
case 'area':
return (
<AreaChart
data={timeSeriesData}
xKey="name"
areas={[
{ dataKey: 'revenue', name: 'Revenue', fill: '#60a5fa', stroke: '#60a5fa' },
{ dataKey: 'profit', name: 'Profit', fill: '#34d399', stroke: '#34d399' },
]}
height={220}
showLegend
stacked
/>
);
case 'stacked':
return (
<StackedBarChart
data={timeSeriesData}
xKey="name"
stackKeys={[
{ dataKey: 'expenses', name: 'Expenses', fill: '#f87171' },
{ dataKey: 'profit', name: 'Profit', fill: '#34d399' },
]}
height={220}
showLegend
/>
);
case 'pie':
return (
<PieChart
data={pieData}
nameKey="category"
valueKey="sales"
height={280}
outerRadius={70}
showLegend
/>
);
case 'donut':
return (
<DonutChart
data={pieData}
nameKey="category"
valueKey="sales"
height={280}
innerRadius={50}
outerRadius={70}
showLegend
/>
);
default:
return null;
}
};
return (
<motion.div
className="w-full min-w-0 space-y-4"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.3 }}
style={{ width: '100%' }}
>
{/* Chart type selector */}
<div className="flex flex-wrap gap-2">
{chartTypeOptions.map((option) => (
<Button
key={option.value}
type="button"
variant={chartType === option.value ? 'primary' : 'ghost'}
size="sm"
onClick={() => setChartType(option.value)}
>
{option.label}
</Button>
))}
</div>
{/* Chart display with animation */}
<div className="w-full min-w-0">
<AnimatePresence mode="wait">
<motion.div
key={chartType}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.2 }}
style={{ width: '100%', height: chartType === 'pie' || chartType === 'donut' ? 280 : 220 }}
>
{renderChart()}
</motion.div>
</AnimatePresence>
</div>
</motion.div>
);
}
// CloseButton Preview
function CloseButtonPreview() {
return (
<motion.div
className="flex items-center gap-4"
variants={containerVariants}
initial="hidden"
animate="show"
>
<motion.div variants={itemVariants} className="flex flex-col items-center gap-2">
<CloseButton onClick={() => {}} />
<span className="text-xs text-muted-foreground">Default</span>
</motion.div>
<motion.div variants={itemVariants} className="flex flex-col items-center gap-2">
<div className="p-3 bg-muted/50 rounded-lg border border-border">
<div className="flex items-center gap-3">
<span className="text-sm text-muted-foreground">Dismissible item</span>
<CloseButton onClick={() => {}} />
</div>
</div>
<span className="text-xs text-muted-foreground">In context</span>
</motion.div>
</motion.div>
);
}
// ContextMenu Preview
function ContextMenuPreview() {
const menuItems = [
{ label: 'Cut', onClick: () => {} },
{ label: 'Copy', onClick: () => {} },
{ label: 'Paste', onClick: () => {} },
{ label: '', onClick: () => {}, separator: true },
{ label: 'Delete', onClick: () => {}, destructive: true },
];
return (
<motion.div
className="w-full"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<ContextMenu.fromItems items={menuItems}>
<div className="p-8 border border-dashed border-border rounded-lg text-center">
<p className="text-muted-foreground text-sm">Right-click here to open context menu</p>
</div>
</ContextMenu.fromItems>
</motion.div>
);
}
// Modal Preview
function ModalPreview() {
const [isOpen, setIsOpen] = useState(false);
// Check if we're in the browser (for SSR compatibility with portal)
const isBrowser = typeof window !== 'undefined';
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<Button type="button" variant="primary" onClick={() => setIsOpen(true)}>
Open Modal
</Button>
{/* Use portal to render modal at document body level to escape stacking context */}
{isBrowser && createPortal(
<Modal isOpen={isOpen} onClose={() => setIsOpen(false)} title="Example Modal">
<div className="space-y-4">
<p className="text-muted-foreground">
This is a modal dialog. You can put any content here.
</p>
<div className="flex gap-2 justify-end">
<Button type="button" variant="ghost" onClick={() => setIsOpen(false)}>Cancel</Button>
<Button type="button" variant="primary" onClick={() => setIsOpen(false)}>Confirm</Button>
</div>
</div>
</Modal>,
document.body
)}
</motion.div>
);
}
// MultiSelect Preview
function MultiSelectPreview() {
const [selected, setSelected] = useState<string[]>(['react']);
const options = [
{ label: 'React', value: 'react' },
{ label: 'Vue', value: 'vue' },
{ label: 'Angular', value: 'angular' },
{ label: 'Svelte', value: 'svelte' },
{ label: 'Solid', value: 'solid' },
];
return (
<motion.div
className="w-full max-w-xs"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
>
<MultiSelect
value={selected}
onChange={setSelected}
options={options}
placeholder="Select frameworks..."
/>
</motion.div>
);
}
// SearchInput Preview
function SearchInputPreview() {
const [query, setQuery] = useState('');
return (
<motion.div
className="w-full max-w-sm"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
>
<SearchInput
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search components..."
/>
</motion.div>
);
}
// Skeleton Preview
function SkeletonPreview() {
return (
<motion.div
className="flex flex-col gap-3 w-full max-w-sm"
variants={containerVariants}
initial="hidden"
animate="show"
>
<motion.div
className="flex items-center gap-3"
variants={itemVariants}
>
<motion.div
animate={{ opacity: [0.5, 1, 0.5] }}
transition={{ duration: 2, repeat: Infinity }}
>
<Skeleton className="h-12 w-12 rounded-full" />
</motion.div>
<div className="flex-1 space-y-2">
<Skeleton className="h-4 w-3/4" />
<Skeleton className="h-3 w-1/2" />
</div>
</motion.div>
<motion.div variants={itemVariants}>
<Skeleton className="h-24 w-full rounded-lg" />
</motion.div>
<motion.div className="flex gap-2" variants={itemVariants}>
<Skeleton className="h-8 w-20 rounded-md" />
<Skeleton className="h-8 w-20 rounded-md" />
</motion.div>
</motion.div>
);
}
// Switch Preview
function SwitchPreview() {
const [enabled1, setEnabled1] = useState(false);
const [enabled2, setEnabled2] = useState(true);
return (
<motion.div
className="flex flex-col gap-3"
variants={containerVariants}
initial="hidden"
animate="show"
>
<motion.div variants={itemVariants} whileHover={{ x: 4 }}>
<Switch
label="Enable notifications"
checked={enabled1}
onChange={setEnabled1}
/>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ x: 4 }}>
<Switch
label="Dark mode"
checked={enabled2}
onChange={setEnabled2}
/>
</motion.div>
<motion.div variants={itemVariants} whileHover={{ x: 4 }}>
<Switch
label="Disabled"
checked={false}
disabled
/>
</motion.div>
</motion.div>
);
}
// Table Preview
function TablePreview() {
const data = [
{ id: 1, name: 'John Doe', email: 'john@example.com', status: 'Active' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'Pending' },
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', status: 'Inactive' },
];
return (
<motion.div
className="w-full overflow-auto"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<Table>
<TableHead>
<TableRow>
<TableHeaderCell>Name</TableHeaderCell>
<TableHeaderCell>Email</TableHeaderCell>
<TableHeaderCell>Status</TableHeaderCell>
</TableRow>
</TableHead>
<TableBody>
{data.map((row) => (
<TableRow key={row.id}>
<TableCell>{row.name}</TableCell>
<TableCell>{row.email}</TableCell>
<TableCell>
<Badge variant={row.status === 'Active' ? 'success' : row.status === 'Pending' ? 'warning' : 'secondary'}>
{row.status}
</Badge>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</motion.div>
);
}
// Accordion Preview
function AccordionPreview() {
return (
<motion.div
className="w-full max-w-md"
variants={containerVariants}
initial="hidden"
animate="show"
>
<Accordion type="single" defaultValue="item-1">
<motion.div variants={itemVariants}>
<AccordionItem value="item-1">
<AccordionTrigger>What is Darwin UI?</AccordionTrigger>
<AccordionContent>
Darwin UI is a beautiful, macOS-inspired React component library with native-feeling interactions and smooth animations.
</AccordionContent>
</AccordionItem>
</motion.div>
<motion.div variants={itemVariants}>
<AccordionItem value="item-2">
<AccordionTrigger>Is it accessible?</AccordionTrigger>
<AccordionContent>
Yes! All components are ARIA-compliant with full keyboard navigation support.
</AccordionContent>
</AccordionItem>
</motion.div>
<motion.div variants={itemVariants}>
<AccordionItem value="item-3">
<AccordionTrigger>Can I customize it?</AccordionTrigger>
<AccordionContent>
Absolutely. Darwin UI supports extensive theming and customization through CSS variables and Tailwind.
</AccordionContent>
</AccordionItem>
</motion.div>
</Accordion>
</motion.div>
);
}
// Avatar Preview
function AvatarPreview() {
return (
<motion.div
className="flex flex-col gap-6"
variants={containerVariants}
initial="hidden"
animate="show"
>
<motion.div variants={itemVariants} className="flex flex-col gap-2">
<span className="text-xs text-muted-foreground">Single Avatar</span>
<div className="flex items-center gap-3">
<Avatar src="https://i.pravatar.cc/150?img=1" alt="User" size="sm" />
<Avatar src="https://i.pravatar.cc/150?img=2" alt="User" size="md" />
<Avatar src="https://i.pravatar.cc/150?img=3" alt="User" size="lg" />
<Avatar fallback="John Doe" size="md" />
</div>
</motion.div>
<motion.div variants={itemVariants} className="flex flex-col gap-2">
<span className="text-xs text-muted-foreground">Avatar Group</span>
<AvatarGroup max={4}>
<Avatar src="https://i.pravatar.cc/150?img=4" alt="User 1" />
<Avatar src="https://i.pravatar.cc/150?img=5" alt="User 2" />
<Avatar src="https://i.pravatar.cc/150?img=6" alt="User 3" />
<Avatar src="https://i.pravatar.cc/150?img=7" alt="User 4" />
<Avatar src="https://i.pravatar.cc/150?img=8" alt="User 5" />
<Avatar src="https://i.pravatar.cc/150?img=9" alt="User 6" />
</AvatarGroup>
</motion.div>
</motion.div>
);
}
// DateSelect Preview
function DateSelectPreview() {
const [dateConfig, setDateConfig] = useState<{ startDate?: Date } | null>(null);
return (
<motion.div
className="w-full max-w-sm"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ type: "spring", stiffness: 300, damping: 25 }}
>
<DateSelect
label="Select a date"
onChange={(config) => setDateConfig(config)}
/>
{dateConfig?.startDate && (
<motion.p
className="mt-2 text-xs text-muted-foreground"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
Selected: {dateConfig.startDate.toLocaleDateString()}
</motion.p>
)}
</motion.div>
);
}
// Dialog Preview
function DialogPreview() {
const [open, setOpen] = useState(false);
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button type="button" variant="primary">Open Dialog</Button>
</DialogTrigger>
<DialogContent>
<DialogClose />
<DialogHeader>
<DialogTitle>Confirm Action</DialogTitle>
<DialogDescription>
Are you sure you want to proceed? This action cannot be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button type="button" variant="ghost">Cancel</Button>
</DialogClose>
<Button type="button" variant="primary" onClick={() => setOpen(false)}>Confirm</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</motion.div>
);
}
// DropdownMenu Preview
function DropdownMenuPreview() {
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button type="button" variant="outline">Open Menu</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem onSelect={() => {}}>Profile</DropdownMenuItem>
<DropdownMenuItem onSelect={() => {}}>Settings</DropdownMenuItem>
<DropdownMenuItem onSelect={() => {}}>Preferences</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => {}} destructive>Log out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</motion.div>
);
}
// Image Preview
function ImagePreview() {
return (
<motion.div
className="flex flex-col gap-4"
variants={containerVariants}
initial="hidden"
animate="show"
>