@@ -9,6 +9,8 @@ import AlbumCover from "@/components/getAverageColor";
9
9
import { Drawer , DrawerContent , DrawerDescription , DrawerFooter , DrawerHeader , DrawerTitle , DrawerTrigger } from "./ui/drawer" ;
10
10
import { Progress } from "./ui/progress" ;
11
11
12
+ import '@public/CSS/song-controls.css' ;
13
+
12
14
interface songControlsInterface {
13
15
songRef : any ;
14
16
songVal : string ;
@@ -138,8 +140,8 @@ export const SongControls = ({
138
140
< >
139
141
{ ! mediumScreen ? (
140
142
< div
141
- className = { `fixed bottom-2 rounded-2xl w-full max-w-[93.5vw ]
142
- left-1/2 -translate-x-1/2 py-6 px-5 bg-primary-foreground/80 backdrop-blur-lg border-2 border-t -secondary
143
+ className = { `fixed bottom-2 rounded-2xl w-full max-w-[93vw ]
144
+ left-1/2 -translate-x-1/2 py-3 px-3 bg-primary-foreground/80 backdrop-blur-lg border-2 border-secondary
143
145
flex items-center transition-all duration-500 shadow-lg ${ appearBar ? "translate-y-0" : "translate-y-24"
144
146
} `}
145
147
// onClick={hideControls}
@@ -168,8 +170,8 @@ export const SongControls = ({
168
170
< Drawer >
169
171
< DrawerTrigger asChild >
170
172
< div
171
- className = { `fixed bottom-2 rounded-2xl w-full max-w-[93.5vw ] left-1/2 -translate-x-1/2
172
- py-3 px-3 bg-primary-foreground/80 backdrop-blur-lg border-2 border-secondary flex items-center transition-all duration-500 shadow-lg
173
+ className = { `fixed bottom-2 rounded-2xl w-full max-w-[88vw ] left-1/2 -translate-x-1/2
174
+ bg-primary-foreground/80 backdrop-blur-lg border-2 border-secondary flex items-center transition-all duration-500 shadow-lg overflow-hidden
173
175
${ appearBar ? "translate-y-0" : "translate-y-24"
174
176
} `}
175
177
>
@@ -188,10 +190,6 @@ export const SongControls = ({
188
190
setOptAppear = { setOptAppear }
189
191
id = { id }
190
192
/>
191
- < Progress
192
- value = { sliderValue }
193
- className = "w-[96%] absolute bottom-1 left-2 transition-all duration-1000"
194
- />
195
193
</ div >
196
194
</ DrawerTrigger >
197
195
< DrawerContent className = "" >
@@ -307,34 +305,32 @@ const DefaultSongControls = ({
307
305
} ;
308
306
} , [ handleSkipSong , hideControls ] ) ;
309
307
310
- console . log ( songTime ) ;
311
-
312
308
return (
313
309
< >
314
310
< div className = "flex w-full justify-between items-center" >
315
- < div className = "flex items-center gap-2 select-none w-full" >
311
+ < div className = "flex items-center gap-3 select-none w-full" >
316
312
< Image src = { image } alt = { image } width = { 80 } height = { 80 } className = "rounded-lg" />
317
313
< div >
318
- < div className = "font-bold " >
314
+ < div className = "font-semibold tracking-wide " >
319
315
{ songVal !== "" ? songVal : "No Track Found" }
320
316
</ div >
321
317
< div className = "text-sm text-muted-foreground" > { songCreator } </ div >
322
318
</ div >
323
319
</ div >
324
320
325
- < div className = "flex flex-col justify-center gap-3 " >
321
+ < div className = "flex flex-col justify-center gap-1 w-full " >
326
322
< div className = "flex justify-center gap-2 ml-2" >
327
323
< Button
328
324
size = "icon"
329
- className = { `p-6 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
325
+ className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
330
326
variant = "ghost"
331
327
onClick = { ( ) => handleSkipSong ( true ) }
332
328
onKeyDown = { ( ) => pressedKeyOne }
333
329
>
334
330
< SkipBack />
335
331
</ Button >
336
332
< Button
337
- className = { `p-6 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
333
+ className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
338
334
size = "icon"
339
335
onClick = { ( ) => setIsPlaying ( songVal !== "" && ! isPlaying ) }
340
336
onKeyDown = { ( ) => pressedKeyOne }
@@ -343,7 +339,7 @@ const DefaultSongControls = ({
343
339
</ Button >
344
340
< Button
345
341
size = "icon"
346
- className = { `p-6 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
342
+ className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
347
343
variant = "ghost"
348
344
onClick = { ( ) => handleSkipSong ( false ) }
349
345
onKeyDown = { ( ) => pressedKeyOne }
@@ -352,10 +348,10 @@ const DefaultSongControls = ({
352
348
</ Button >
353
349
</ div >
354
350
< div className = "flex items-center gap-2" >
355
- < div className = "text-sm text-muted-foreground/80 w-8 text-right" > { formatTime ( currentTimeVal ) } </ div >
351
+ < div className = "text-sm text-muted-foreground/80 w-12 text-right" > { formatTime ( currentTimeVal ) } </ div >
356
352
< Progress
357
353
value = { sliderValue }
358
- className = "w-72 transition-all"
354
+ className = "transition-all h-1.5 "
359
355
/>
360
356
< div className = "text-sm text-muted-foreground/80" > { isNaN ( songTime ) ? '00:00' : formatTime ( songTime ) } </ div >
361
357
</ div >
@@ -392,43 +388,78 @@ const SongControlsSmall = ({
392
388
setOptAppear,
393
389
id,
394
390
} : songControlsInterface ) => {
391
+ const [ sliderValue , setSliderValue ] = useState ( 0 ) ;
392
+
393
+ const useEffectConst = ( ) => {
394
+ const song = songRef . current ;
395
+ if ( ! song ) return ;
396
+
397
+ const updateTime = ( ) => {
398
+ if ( song . duration ) {
399
+ setSliderValue ( Number ( ( ( song . currentTime / song . duration ) * 100 ) . toFixed ( 0 ) ) ) ;
400
+ }
401
+ } ;
402
+
403
+ song . addEventListener ( "timeupdate" , updateTime ) ;
404
+
405
+ return ( ) => {
406
+ song . removeEventListener ( "timeupdate" , updateTime ) ;
407
+ } ;
408
+ }
409
+
410
+ useEffect ( ( ) => {
411
+ useEffectConst ( ) ;
412
+ } , [ ] ) ;
413
+
414
+ useEffect ( ( ) => {
415
+ useEffectConst ( ) ;
416
+ } , [ handleSkipSong ] ) ;
417
+
395
418
return (
396
419
< >
397
- < div className = "flex items-center gap-2 flex-1 select-none mb-2" >
398
- < Image
399
- src = { image }
400
- alt = { image }
401
- width = { 60 }
402
- height = { 60 }
403
- className = "rounded-lg"
404
- />
405
- < div >
406
- < div className = "font-bold overflow-hidden whitespace-nowrap text-ellipsis w-[47vw]" >
407
- { songVal !== "" ? songVal : "No Track Found" }
420
+ < div className = "flex flex-col" >
421
+ < div className = "flex items-center py-3 px-3" >
422
+ < div className = "flex items-center gap-2 flex-1 select-none" >
423
+ < Image
424
+ src = { image }
425
+ alt = { image }
426
+ width = { 60 }
427
+ height = { 60 }
428
+ className = "rounded-lg"
429
+ />
430
+ < div >
431
+ < div className = "font-semibold overflow-hidden whitespace-nowrap text-ellipsis w-[40vw]" >
432
+ { songVal !== "" ? songVal : "No Track Found" }
433
+ </ div >
434
+ < div className = "text-sm text-muted-foreground" > { songCreator } </ div >
435
+ </ div >
408
436
</ div >
409
- < div className = "text-sm text-muted-foreground" > { songCreator } </ div >
410
- </ div >
411
- </ div >
412
437
413
- < div
414
- className = "flex justify-center gap-1 mb-2"
415
- onClick = { ( e ) => e . stopPropagation ( ) }
416
- >
417
- < Button
418
- className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
419
- size = "icon"
420
- onClick = { ( ) => setIsPlaying ( songVal !== "" && ! isPlaying ) }
421
- >
422
- { ! isPlaying ? < Play size = '36' /> : < Pause size = '36' /> }
423
- </ Button >
424
- < Button
425
- size = "icon"
426
- className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
427
- variant = "ghost"
428
- onClick = { ( ) => handleSkipSong ( false ) }
429
- >
430
- < SkipForward />
431
- </ Button >
438
+ < div
439
+ className = "flex justify-center gap-1"
440
+ onClick = { ( e ) => e . stopPropagation ( ) }
441
+ >
442
+ < Button
443
+ className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
444
+ size = "icon"
445
+ onClick = { ( ) => setIsPlaying ( songVal !== "" && ! isPlaying ) }
446
+ >
447
+ { ! isPlaying ? < Play size = '36' /> : < Pause size = '36' /> }
448
+ </ Button >
449
+ < Button
450
+ size = "icon"
451
+ className = { `p-5 rounded-full ${ songVal !== "" ? "" : "opacity-50 cursor-not-allowed" } ` }
452
+ variant = "ghost"
453
+ onClick = { ( ) => handleSkipSong ( false ) }
454
+ >
455
+ < SkipForward />
456
+ </ Button >
457
+ </ div >
458
+ </ div >
459
+ < Progress
460
+ value = { sliderValue }
461
+ className = "transition-all duration-1000 h-1 rounded-none w-full"
462
+ />
432
463
</ div >
433
464
</ >
434
465
) ;
@@ -486,7 +517,7 @@ const MiniPlayer = ({
486
517
487
518
return (
488
519
< div
489
- className = { `overflow-y-auto overflow-x-hidden p-8 flex flex-col gap-2 transition-all bg-primary-foreground` }
520
+ className = { `p-8 flex flex-col gap-2 transition-all bg-primary-foreground` }
490
521
>
491
522
{ /* <Button variant='outline' size='icon' onClick={() => setAppear(false)} className="bg-transparent border-none cursor-pointer absolute top-3 left-3 rounded-full">
492
523
<ChevronDown />
@@ -502,9 +533,9 @@ const MiniPlayer = ({
502
533
className = "rounded-xl shadow-lg"
503
534
/>
504
535
</ div >
505
- < div className = "flex flex-col" >
506
- < div className = "text-xl font-bold " > { songVal || "Unknown" } </ div >
507
- < div className = "text-lg text-muted-foreground -translate-y-1" >
536
+ < div className = "flex flex-col overflow-hidden " >
537
+ < div className = "text-2xl font-semibold w-full overflow-hidden whitespace-pre scrolling-text relative " > { songVal || "Unknown" } </ div >
538
+ < div className = "text-md text-muted-foreground -translate-y-1" >
508
539
{ songCreator || "Unknown" }
509
540
</ div >
510
541
</ div >
@@ -555,7 +586,7 @@ const MiniPlayer = ({
555
586
className="w-full h-full rounded-xl px-4 py-3 mt-8"
556
587
style={{ background: albumAverageColorFR }}
557
588
>
558
- <div className="text-lg font-bold ">Lyrics</div>
589
+ <div className="text-lg font-semibold ">Lyrics</div>
559
590
<div className="text-primary/80">
560
591
<div>WIP</div>
561
592
</div>
0 commit comments