|
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8"> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 | | - <title>Spotify Now Playing Widget</title> |
| 6 | + <title>Spotify Now Playing Widget - Modern Glass</title> |
7 | 7 | <style> |
| 8 | + @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap'); |
| 9 | + |
8 | 10 | body { |
9 | | - font-family: Arial, sans-serif; |
| 11 | + font-family: 'Poppins', sans-serif; /* Modern font */ |
10 | 12 | display: flex; |
11 | 13 | justify-content: center; |
12 | 14 | align-items: center; |
13 | 15 | height: 100vh; |
14 | | - background-color: #121212; |
15 | | - color: #fff; |
| 16 | + background: linear-gradient(135deg, #1d2127 0%, #0d0f12 100%); /* Darker, subtle gradient */ |
| 17 | + color: #e0e0e0; /* Lighter text for contrast */ |
| 18 | + margin: 0; |
| 19 | + overflow: hidden; /* Prevent scrollbars */ |
16 | 20 | } |
17 | 21 |
|
18 | 22 | .widget-container { |
19 | | - background-color: #1a1a1a; |
20 | | - padding: 20px; |
21 | | - border-radius: 10px; |
22 | | - box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5); |
| 23 | + background: rgba(255, 255, 255, 0.08); /* Semi-transparent background */ |
| 24 | + backdrop-filter: blur(15px) saturate(180%); /* Frosted glass effect */ |
| 25 | + -webkit-backdrop-filter: blur(15px) saturate(180%); /* For Safari */ |
| 26 | + border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle white border */ |
| 27 | + border-radius: 20px; /* More rounded corners */ |
| 28 | + box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); /* Stronger, diffused shadow */ |
| 29 | + padding: 25px 35px; /* Increased padding */ |
23 | 30 | text-align: center; |
| 31 | + max-width: 320px; /* Max width for a compact widget */ |
| 32 | + width: 90%; /* Responsive width */ |
| 33 | + transition: all 0.3s ease; /* Smooth transitions for hover effects */ |
| 34 | + } |
| 35 | + |
| 36 | + .widget-container:hover { |
| 37 | + box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45); /* Slightly more prominent shadow on hover */ |
| 38 | + transform: translateY(-2px); /* Slight lift effect */ |
24 | 39 | } |
25 | 40 |
|
26 | 41 | #login-button { |
27 | | - background-color: #1db954; |
| 42 | + background-color: #1ed760; /* Spotify green */ |
28 | 43 | color: white; |
29 | | - padding: 10px 20px; |
| 44 | + padding: 12px 25px; /* Larger button */ |
30 | 45 | border: none; |
31 | 46 | border-radius: 500px; |
32 | | - font-weight: bold; |
| 47 | + font-weight: 600; /* Bolder font weight */ |
33 | 48 | cursor: pointer; |
34 | 49 | text-decoration: none; |
35 | 50 | display: inline-block; |
| 51 | + transition: background-color 0.2s ease, transform 0.2s ease; /* Smooth hover */ |
| 52 | + } |
| 53 | + |
| 54 | + #login-button:hover { |
| 55 | + background-color: #1ab24e; /* Darker green on hover */ |
| 56 | + transform: translateY(-1px); |
| 57 | + } |
| 58 | + |
| 59 | + #login-section p { |
| 60 | + font-size: 0.95em; |
| 61 | + color: #b0b0b0; /* Subtler text */ |
| 62 | + margin-bottom: 25px; |
36 | 63 | } |
37 | 64 |
|
38 | 65 | #now-playing { |
39 | 66 | display: none; |
| 67 | + opacity: 0; /* Start hidden for fade-in */ |
| 68 | + transition: opacity 0.5s ease; /* Fade-in effect */ |
| 69 | + } |
| 70 | + |
| 71 | + #now-playing.visible { |
| 72 | + opacity: 1; /* Make visible */ |
40 | 73 | } |
41 | 74 |
|
42 | 75 | #album-art { |
43 | | - width: 150px; |
44 | | - height: 150px; |
45 | | - border-radius: 8px; |
46 | | - margin-bottom: 15px; |
| 76 | + width: 160px; /* Slightly larger album art */ |
| 77 | + height: 160px; |
| 78 | + border-radius: 12px; /* More rounded album art */ |
| 79 | + margin-bottom: 20px; |
| 80 | + box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25); /* Shadow for album art */ |
| 81 | + object-fit: cover; /* Ensure image covers the area */ |
47 | 82 | } |
48 | 83 |
|
49 | 84 | #track-title { |
50 | | - font-size: 1.5em; |
51 | | - font-weight: bold; |
| 85 | + font-size: 1.6em; /* Slightly larger title */ |
| 86 | + font-weight: 700; /* Bold title */ |
| 87 | + margin-bottom: 5px; |
| 88 | + color: #ffffff; /* Pure white title */ |
| 89 | + white-space: nowrap; /* Prevent title from wrapping prematurely */ |
| 90 | + overflow: hidden; /* Hide overflow */ |
| 91 | + text-overflow: ellipsis; /* Add ellipsis for long titles */ |
52 | 92 | } |
53 | 93 |
|
54 | 94 | #artist-name { |
55 | | - font-size: 1.2em; |
56 | | - color: #b3b3b3; |
| 95 | + font-size: 1.1em; /* Adjusted artist name size */ |
| 96 | + color: #b0b0b0; /* Subtler artist name */ |
| 97 | + margin-top: 0; |
| 98 | + white-space: nowrap; |
| 99 | + overflow: hidden; |
| 100 | + text-overflow: ellipsis; |
57 | 101 | } |
58 | 102 | </style> |
59 | 103 | </head> |
|
73 | 117 | </div> |
74 | 118 |
|
75 | 119 | <script> |
76 | | - const clientId = 'd6d3071a35dc4874af1dcf110017ec8d'; // REPLACE WITH YOUR CLIENT ID |
77 | | - const redirectUri = 'https://erasmusdev.github.io/FlockersDevHub/Player.html'; |
| 120 | + const clientId = 'd6d3071a35dc4874af1dcf110017ec8d'; // YOUR CLIENT ID HERE |
| 121 | + const redirectUri = 'https://erasmusdev.github.io/FlockersDevHub/Player.html'; // YOUR GITHUB PAGES URL HERE |
78 | 122 | const authEndpoint = 'https://accounts.spotify.com/authorize'; |
79 | 123 | const tokenEndpoint = 'https://accounts.spotify.com/api/token'; |
80 | 124 | const scope = 'user-read-currently-playing'; |
|
118 | 162 | if (accessToken) { |
119 | 163 | loginSection.style.display = 'none'; |
120 | 164 | nowPlayingSection.style.display = 'block'; |
| 165 | + nowPlayingSection.classList.add('visible'); // Add visible class for fade-in |
121 | 166 | getCurrentlyPlaying(); |
122 | 167 | setInterval(getCurrentlyPlaying, 5000); |
123 | 168 | } else { |
|
177 | 222 | async function getCurrentlyPlaying() { |
178 | 223 | let accessToken = localStorage.getItem('accessToken'); |
179 | 224 | if (!accessToken) { |
180 | | - // No token, or token expired and not refreshed, show login button |
181 | 225 | localStorage.clear(); |
182 | 226 | location.reload(); |
183 | 227 | return; |
|
199 | 243 | } |
200 | 244 |
|
201 | 245 | if (response.status === 401) { |
202 | | - // Token expired or invalid, clear and force re-login |
203 | 246 | localStorage.clear(); |
204 | 247 | location.reload(); |
205 | 248 | return; |
|
211 | 254 | artistName.innerText = data.item.artists.map(artist => artist.name).join(', '); |
212 | 255 | albumArt.src = data.item.album.images[0].url; |
213 | 256 | albumArt.style.display = "block"; |
| 257 | + nowPlayingSection.classList.add('visible'); // Ensure visible on updates |
214 | 258 | } else { |
215 | 259 | trackTitle.innerText = "Nothing playing right now."; |
216 | 260 | artistName.innerText = ""; |
|
0 commit comments