codebybrody commited on
Commit
2a4b2a2
·
verified ·
1 Parent(s): 64667cf

Upload 62 files

Browse files
components/DetailView.tsx CHANGED
@@ -7,6 +7,8 @@ import { IconPicker } from './IconPicker';
7
  import { ArrowLeft, Download, ExternalLink, Trash2, Edit2, Plus, Save, X, Check, Copy, Sparkles, Link as LinkIcon, ClipboardCheck } from 'lucide-react';
8
  import { ConfirmDialog } from './ConfirmDialog';
9
  import { Editor } from '@tiptap/react';
 
 
10
 
11
  interface DetailViewProps {
12
  item: DataItem;
@@ -19,6 +21,14 @@ interface DetailViewProps {
19
  }
20
 
21
  export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate, onDelete, onDuplicate, isEditable = false }) => {
 
 
 
 
 
 
 
 
22
  const [isEditMode, setIsEditMode] = useState(false);
23
  const [editedItem, setEditedItem] = useState<DataItem>(item);
24
  const [editingBlockId, setEditingBlockId] = useState<string | null>(null);
@@ -565,34 +575,42 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
565
  </div>
566
  )}
567
 
568
- {(editedItem.visitUrl || editedItem.downloadUrl) && (
569
- <div className="flex flex-col sm:flex-row gap-3 pt-6 mt-2 border-t border-white/5">
570
- {editedItem.visitUrl && (
571
- <a href={editedItem.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
572
- <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
573
- <ExternalLink size={16} /> Visitar Enlace
574
- </button>
575
- </a>
576
- )}
577
- {editedItem.downloadUrl && (
578
- <a href={editedItem.downloadUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
579
- <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
580
- <Download size={16} /> Descargar
581
- </button>
582
- </a>
583
  )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  </div>
585
- )}
586
 
587
  {editedItem.linkGroups && editedItem.linkGroups.length > 0 && (
588
  <div className="space-y-4 pt-6 mt-2 border-t border-white/5">
589
  {editedItem.linkGroups.map((group) => {
590
  if (!group.visitUrl && !group.downloadUrl) return null;
 
591
  return (
592
  <div key={group.id} className="w-full">
593
  {group.title && (
594
  <h4 className="text-sm font-medium text-gray-400 mb-2">{group.title}</h4>
595
  )}
 
 
 
596
  <div className="flex flex-col sm:flex-row gap-3">
597
  {group.visitUrl && (
598
  <a href={group.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
@@ -734,8 +752,11 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
734
  </div>
735
  )}
736
 
737
- {(item.visitUrl || item.downloadUrl) && (
738
- <div className="flex flex-col sm:flex-row gap-3 pt-6 mt-2">
 
 
 
739
  {item.visitUrl && (
740
  <a href={item.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
741
  <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
@@ -744,25 +765,30 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
744
  </a>
745
  )}
746
  {item.downloadUrl && (
747
- <a href={item.downloadUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
748
  <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
749
  <Download size={16} /> Descargar
750
  </button>
751
  </a>
752
  )}
753
  </div>
754
- )}
 
755
 
756
 
757
  {item.linkGroups && item.linkGroups.length > 0 && (
758
  <div className="space-y-4 pt-6 mt-2 border-t border-white/5">
759
  {item.linkGroups.map((group) => {
760
  if (!group.visitUrl && !group.downloadUrl) return null;
 
761
  return (
762
  <div key={group.id} className="w-full">
763
  {group.title && (
764
  <h4 className="text-sm font-medium text-gray-400 mb-2">{group.title}</h4>
765
  )}
 
 
 
766
  <div className="flex flex-col sm:flex-row gap-3">
767
  {group.visitUrl && (
768
  <a href={group.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
 
7
  import { ArrowLeft, Download, ExternalLink, Trash2, Edit2, Plus, Save, X, Check, Copy, Sparkles, Link as LinkIcon, ClipboardCheck } from 'lucide-react';
8
  import { ConfirmDialog } from './ConfirmDialog';
9
  import { Editor } from '@tiptap/react';
10
+ import { FishAudioPlayer } from './FishAudioPlayer';
11
+
12
 
13
  interface DetailViewProps {
14
  item: DataItem;
 
21
  }
22
 
23
  export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate, onDelete, onDuplicate, isEditable = false }) => {
24
+ const getFishAudioId = (url: string | undefined) => {
25
+ if (!url) return null;
26
+ const match = url.match(/fish\.audio\/(?:[a-z]{2}\/)?(?:app\/)?m\/([a-f0-9]+)/i);
27
+ return match ? match[1] : null;
28
+ };
29
+
30
+
31
+
32
  const [isEditMode, setIsEditMode] = useState(false);
33
  const [editedItem, setEditedItem] = useState<DataItem>(item);
34
  const [editingBlockId, setEditingBlockId] = useState<string | null>(null);
 
575
  </div>
576
  )}
577
 
578
+ <div className="flex flex-col gap-3 pt-6 mt-2 border-t border-white/5">
579
+ {editedItem.visitUrl && getFishAudioId(editedItem.visitUrl) && (
580
+ <FishAudioPlayer modelId={getFishAudioId(editedItem.visitUrl)!} className="mb-2" />
 
 
 
 
 
 
 
 
 
 
 
 
581
  )}
582
+ <div className="flex flex-col sm:flex-row gap-3">
583
+ {editedItem.visitUrl && (
584
+ <a href={editedItem.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
585
+ <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
586
+ <ExternalLink size={16} /> Visitar Enlace
587
+ </button>
588
+ </a>
589
+ )}
590
+ {editedItem.downloadUrl && (
591
+ <a href={editedItem.downloadUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
592
+ <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
593
+ <Download size={16} /> Descargar
594
+ </button>
595
+ </a>
596
+ )}
597
+ </div>
598
  </div>
599
+
600
 
601
  {editedItem.linkGroups && editedItem.linkGroups.length > 0 && (
602
  <div className="space-y-4 pt-6 mt-2 border-t border-white/5">
603
  {editedItem.linkGroups.map((group) => {
604
  if (!group.visitUrl && !group.downloadUrl) return null;
605
+ const fishAudioId = getFishAudioId(group.visitUrl || '');
606
  return (
607
  <div key={group.id} className="w-full">
608
  {group.title && (
609
  <h4 className="text-sm font-medium text-gray-400 mb-2">{group.title}</h4>
610
  )}
611
+ {fishAudioId && (
612
+ <FishAudioPlayer modelId={fishAudioId} className="mb-3" />
613
+ )}
614
  <div className="flex flex-col sm:flex-row gap-3">
615
  {group.visitUrl && (
616
  <a href={group.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
 
752
  </div>
753
  )}
754
 
755
+ <div className="flex flex-col gap-3 pt-6 mt-2 border-t border-white/5">
756
+ {item.visitUrl && getFishAudioId(item.visitUrl) && (
757
+ <FishAudioPlayer modelId={getFishAudioId(item.visitUrl)!} className="mb-2" />
758
+ )}
759
+ <div className="flex flex-col sm:flex-row gap-3">
760
  {item.visitUrl && (
761
  <a href={item.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
762
  <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
 
765
  </a>
766
  )}
767
  {item.downloadUrl && (
768
+ <a href={item.downloadUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
769
  <button className="w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-primary/30 text-primary hover:bg-primary/10 transition-colors text-sm font-medium">
770
  <Download size={16} /> Descargar
771
  </button>
772
  </a>
773
  )}
774
  </div>
775
+ </div>
776
+
777
 
778
 
779
  {item.linkGroups && item.linkGroups.length > 0 && (
780
  <div className="space-y-4 pt-6 mt-2 border-t border-white/5">
781
  {item.linkGroups.map((group) => {
782
  if (!group.visitUrl && !group.downloadUrl) return null;
783
+ const fishAudioId = getFishAudioId(group.visitUrl || '');
784
  return (
785
  <div key={group.id} className="w-full">
786
  {group.title && (
787
  <h4 className="text-sm font-medium text-gray-400 mb-2">{group.title}</h4>
788
  )}
789
+ {fishAudioId && (
790
+ <FishAudioPlayer modelId={fishAudioId} className="mb-3" />
791
+ )}
792
  <div className="flex flex-col sm:flex-row gap-3">
793
  {group.visitUrl && (
794
  <a href={group.visitUrl} target="_blank" rel="noopener noreferrer" className="flex-1 flex w-full">
components/FishAudioPlayer.tsx ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Play, Pause, Volume2, Loader2 } from 'lucide-react';
3
+
4
+ interface FishAudioPlayerProps {
5
+ modelId: string;
6
+ className?: string;
7
+ }
8
+
9
+ export const FishAudioPlayer: React.FC<FishAudioPlayerProps> = ({ modelId, className = "" }) => {
10
+ const [audioUrl, setAudioUrl] = useState<string | null>(null);
11
+ const [loading, setLoading] = useState(true);
12
+ const [error, setError] = useState<string | null>(null);
13
+ const [isPlaying, setIsPlaying] = useState(false);
14
+ const audioRef = React.useRef<HTMLAudioElement | null>(null);
15
+
16
+ useEffect(() => {
17
+ const fetchModel = async () => {
18
+ try {
19
+ setLoading(true);
20
+ const response = await fetch(`https://api.fish.audio/model/${modelId}`);
21
+ if (!response.ok) throw new Error('Failed to fetch model info');
22
+ const data = await response.json();
23
+
24
+ if (data.samples && data.samples.length > 0 && data.samples[0].audio) {
25
+ setAudioUrl(data.samples[0].audio);
26
+ } else {
27
+ setError('No audio sample found');
28
+ }
29
+ } catch (err) {
30
+ console.error('Error loading Fish Audio:', err);
31
+ setError('Error loading preview');
32
+ } finally {
33
+ setLoading(false);
34
+ }
35
+ };
36
+
37
+ if (modelId) {
38
+ fetchModel();
39
+ }
40
+ }, [modelId]);
41
+
42
+ const togglePlay = () => {
43
+ if (!audioRef.current) return;
44
+
45
+ if (isPlaying) {
46
+ audioRef.current.pause();
47
+ } else {
48
+ audioRef.current.play();
49
+ }
50
+ setIsPlaying(!isPlaying);
51
+ };
52
+
53
+ if (loading) {
54
+ return (
55
+ <div className={`flex items-center gap-3 p-4 bg-white/5 rounded-xl border border-white/10 animate-pulse ${className}`}>
56
+ <div className="w-10 h-10 rounded-full bg-white/10 flex items-center justify-center">
57
+ <Loader2 className="animate-spin text-primary" size={20} />
58
+ </div>
59
+ <div className="flex-1 space-y-2">
60
+ <div className="h-2 bg-white/10 rounded w-1/3"></div>
61
+ <div className="h-1 bg-white/5 rounded w-full"></div>
62
+ </div>
63
+ </div>
64
+ );
65
+ }
66
+
67
+ if (error || !audioUrl) {
68
+ return null; // Don't show anything if there's an error
69
+ }
70
+
71
+ return (
72
+ <div className={`flex items-center gap-4 p-4 bg-primary/5 rounded-xl border border-primary/20 group hover:bg-primary/10 transition-all duration-300 ${className}`}>
73
+ <button
74
+ onClick={togglePlay}
75
+ className="w-12 h-12 rounded-full bg-primary text-background flex items-center justify-center hover:scale-105 active:scale-95 transition-transform shadow-lg shadow-primary/20"
76
+ >
77
+ {isPlaying ? <Pause size={24} fill="currentColor" /> : <Play size={24} fill="currentColor" className="ml-1" />}
78
+ </button>
79
+
80
+ <div className="flex-1">
81
+ <div className="flex items-center justify-between mb-1">
82
+ <span className="text-xs font-bold text-primary uppercase tracking-wider">Demo de Voz</span>
83
+ <Volume2 size={14} className="text-primary/60" />
84
+ </div>
85
+ <div className="relative h-1.5 bg-white/10 rounded-full overflow-hidden">
86
+ <div className={`absolute inset-0 bg-primary/30 ${isPlaying ? 'animate-shimmer' : ''}`} style={{ width: '100%', backgroundSize: '200% 100%' }}></div>
87
+ {/* We could add a proper progress bar here if we wanted to be more fancy */}
88
+ </div>
89
+ </div>
90
+
91
+ <audio
92
+ ref={audioRef}
93
+ src={audioUrl}
94
+ onEnded={() => setIsPlaying(false)}
95
+ onPause={() => setIsPlaying(false)}
96
+ onPlay={() => setIsPlaying(true)}
97
+ className="hidden"
98
+ />
99
+ </div>
100
+ );
101
+ };
index.css CHANGED
@@ -7,8 +7,10 @@
7
  :root {
8
  --foreground-rgb: 255, 255, 255;
9
  --background-rgb: 10, 10, 10;
 
10
  }
11
 
 
12
  body {
13
  margin: 0;
14
  padding: 0;
@@ -80,4 +82,15 @@ hr {
80
  .prose hr {
81
  border-top: 1px solid rgba(255, 255, 255, 0.2);
82
  margin: 2rem 0;
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
7
  :root {
8
  --foreground-rgb: 255, 255, 255;
9
  --background-rgb: 10, 10, 10;
10
+ --primary-rgb: 187, 134, 252;
11
  }
12
 
13
+
14
  body {
15
  margin: 0;
16
  padding: 0;
 
82
  .prose hr {
83
  border-top: 1px solid rgba(255, 255, 255, 0.2);
84
  margin: 2rem 0;
85
+ }
86
+
87
+ @keyframes shimmer {
88
+ 0% { background-position: -200% 0; }
89
+ 100% { background-position: 200% 0; }
90
+ }
91
+
92
+ .animate-shimmer {
93
+ background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.1) 25%, rgba(var(--primary-rgb), 0.3) 50%, rgba(var(--primary-rgb), 0.1) 75%);
94
+ background-size: 200% 100%;
95
+ animation: shimmer 2s infinite linear;
96
+ }