({ spotify }: { spotify: string })
| 1 | import { useState, useEffect } from 'react'; |
| 2 | |
| 3 | function Spotify({ spotify }: { spotify: string }) { |
| 4 | const [isLoading, setIsLoading] = useState(true); |
| 5 | |
| 6 | useEffect(() => { |
| 7 | const timer = setTimeout(() => { |
| 8 | setIsLoading(false); |
| 9 | }, 400); |
| 10 | |
| 11 | return () => clearTimeout(timer); |
| 12 | }, []); |
| 13 | |
| 14 | return ( |
| 15 | <div className="mt-4 overflow-hidden"> |
| 16 | {isLoading ? ( |
| 17 | <div className="animate-pulse flex space-x-4"> |
| 18 | <div className="flex-1 space-y-4 py-1"> |
| 19 | <div className="h-4 bg-gray-200 rounded w-3/4"></div> |
| 20 | <div className="space-y-2"> |
| 21 | <div className="h-4 bg-gray-200 rounded"></div> |
| 22 | <div className="h-4 bg-gray-200 rounded w-5/6"></div> |
| 23 | </div> |
| 24 | </div> |
| 25 | </div> |
| 26 | ) : ( |
| 27 | <iframe |
| 28 | src={`https://open.spotify.com/embed/track/${spotify}`} |
| 29 | width='100%' |
| 30 | height='80' |
| 31 | allow="encrypted-media" |
| 32 | ></iframe> |
| 33 | )} |
| 34 | </div> |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | export default Spotify; |
nothing calls this directly
no outgoing calls
no test coverage detected