From 227fbcc16634fa2d4ed7ed6adf3a7e14f5a8a208 Mon Sep 17 00:00:00 2001 From: John Enderson Date: Sun, 2 Aug 2026 20:44:22 -0300 Subject: [PATCH] feat(navbar): adiciona selo "ouvindo agora" com dados do Last.fm Novo NowPlayingBadge, so aparece quando ha uma faixa tocando de verdade. Duas variantes: capa + faixa + artista no desktop (entre os links e os icones de preferencias), so a capa com um ponto verde pulsante no mobile (ao lado do botao de menu). Reaproveita o endpoint /api/lastfm/now-playing que a home ja consulta e a cor spotify que o badge "ao vivo" da home ja usa. Co-Authored-By: Claude Sonnet 5 --- src/base/components/Navbar/Navbar.tsx | 33 +++-- .../components/Navbar/NowPlayingBadge.tsx | 116 ++++++++++++++++++ 2 files changed, 136 insertions(+), 13 deletions(-) create mode 100644 src/base/components/Navbar/NowPlayingBadge.tsx diff --git a/src/base/components/Navbar/Navbar.tsx b/src/base/components/Navbar/Navbar.tsx index cd236b1..9edfca3 100644 --- a/src/base/components/Navbar/Navbar.tsx +++ b/src/base/components/Navbar/Navbar.tsx @@ -14,6 +14,7 @@ import { import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { LanguageSelector } from './LanguageSelector'; +import { NowPlayingBadge } from './NowPlayingBadge'; import { PreferencesPanel } from './PreferencesPanel'; import { SITE_NAME } from '@/lib/site'; @@ -125,22 +126,28 @@ export const Navbar = () => { })} -
- - +
+ +
+ + +
- +
+ + +
diff --git a/src/base/components/Navbar/NowPlayingBadge.tsx b/src/base/components/Navbar/NowPlayingBadge.tsx new file mode 100644 index 0000000..b205570 --- /dev/null +++ b/src/base/components/Navbar/NowPlayingBadge.tsx @@ -0,0 +1,116 @@ +'use client'; + +import Image from 'next/image'; +import Link from 'next/link'; +import { useState } from 'react'; + +import useSWR from 'swr'; + +import { LastfmTrack } from '@/types/Lastfm'; + +type NowPlayingResponse = { + nowPlaying: LastfmTrack | null; +}; + +const jsonFetcher = (url: string) => fetch(url).then((r) => r.json()); + +const NowPlayingArt = ({ + track, + size, +}: { + track: LastfmTrack; + size: number; +}) => { + const [failed, setFailed] = useState(false); + + if (!track.imageUrl || failed) { + return ( +