From 0c99be55ecc5d385fc87d252ca1b2b24c3fec34b Mon Sep 17 00:00:00 2001 From: zadit <75159257+insvrgent@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:32:12 +0700 Subject: [PATCH] ok --- src/components/MusicPlayer.css | 11 +++-- src/components/MusicPlayer.js | 75 ++++++++++++++-------------------- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/src/components/MusicPlayer.css b/src/components/MusicPlayer.css index 10a26be..419a975 100644 --- a/src/components/MusicPlayer.css +++ b/src/components/MusicPlayer.css @@ -77,7 +77,7 @@ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7); /* Text shadow for readability */ - margin-bottom: -47px; + margin-bottom: 25px; } .progress-container { @@ -198,14 +198,19 @@ flex-grow: 1; border: none; border-radius: 25px; - /* Round the corners */ padding: 10px 15px; font-size: 16px; outline: none; - /* Remove default outline */ background-color: #f4efe6; text-align: center; + transition: background-color 0.3s ease; /* Smooth transition for the effect */ } + +.search-box input[type="text"].clicked { + background-color: #d0c7b3; /* The color when clicked */ +} + + .search-box input[type="text"]::placeholder { font-weight: bold; opacity: 0.7; diff --git a/src/components/MusicPlayer.js b/src/components/MusicPlayer.js index 7b49652..a684588 100644 --- a/src/components/MusicPlayer.js +++ b/src/components/MusicPlayer.js @@ -84,11 +84,10 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo const fetchColor = async () => { if ( - currentSong.item && - currentSong.item.album && - currentSong.item.album.images[0] + currentSong && + currentSong.image ) { - const imageUrl = currentSong.item.album.images[0].url; + const imageUrl = currentSong.image; try { const dominantColor = await getDominantColor(imageUrl); // Calculate luminance (YIQ color space) to determine if subtitle should be black or white @@ -128,10 +127,11 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo }); socket.on("updateCurrentSong", (response) => { + console.log(response) setCurrentSong(response); - setCurrentTime(response.progress_ms / 1000); // Convert milliseconds to seconds - setLyricProgressMs(response.progress_ms); - setTrackLength(convertToMilliseconds(response.item.length)); + // setCurrentTime(response.progress_ms / 1000); // Convert milliseconds to seconds + // setLyricProgressMs(response.progress_ms); + // setTrackLength(convertToMilliseconds(response.item.length)); }); @@ -345,8 +345,8 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo useEffect(() => { // Update the messages based on currentSong const newMessages = [ - currentSong != null && currentSong.item != undefined - ? `${currentSong.item.artists[0].name} - ${currentSong.item.name}` + currentSong != null && currentSong != undefined + ? `${currentSong.name} - ${currentSong.artist}` : "Menunggu musik favoritmu", "Klik untuk putar musik favoritmu" ]; @@ -385,12 +385,17 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo }, 1000); // 1 second timeout (same as the CSS transition duration) }; + function modifyUrl(url) { + // Use a regular expression to find the part of the URL that starts with '=' + return url.replace(/=(w\d+)-(h\d+)-/, '=w255-h255-'); +} + return (