diff --git a/apps/web/src/pages/charts/realtime/Realtime.tsx b/apps/web/src/pages/charts/realtime/Realtime.tsx index fcca5bfc..7b636b8d 100644 --- a/apps/web/src/pages/charts/realtime/Realtime.tsx +++ b/apps/web/src/pages/charts/realtime/Realtime.tsx @@ -5,6 +5,7 @@ import { import { Link } from "@tanstack/react-router"; import { TableBuilder, TableBuilderColumn } from "baseui/table-semantic"; import Artist from "../../../components/Icons/Artist"; +import ContentLoader from "react-content-loader"; type Row = { id: string; @@ -29,212 +30,304 @@ type ArtistRow = { }; function Realtime() { - const { data: artists } = useTopArtistsQuery(); - const { data: tracks } = useTopTracksQuery(); + const { data: artists, isLoading: artistsLoading } = useTopArtistsQuery(); + const { data: tracks, isLoading: tracksLoading } = useTopTracksQuery(); return ( <>

Top Tracks

- ({ - id: x.id, - title: x.title, - artist: x.artist, - albumArtist: x.albumArtist, - albumArt: x.albumArt, - uri: x.uri, - scrobbles: x.scrobbles, - albumUri: x.albumUri, - artistUri: x.artistUri, - index, - }))} - divider="clean" - overrides={{ - TableHeadRow: { - style: { - display: "none", + {tracksLoading && ( +
+ + {/* Row 1 */} + + + + + + {/* Row 2 */} + + + + + + {/* Row 3 */} + + + + + + {/* Row 4 */} + + + + + + {/* Row 5 */} + + + + + + {/* Row 6 */} + + + + + +
+ )} + {!tracksLoading && ( + ({ + id: x.id, + title: x.title, + artist: x.artist, + albumArtist: x.albumArtist, + albumArt: x.albumArt, + uri: x.uri, + scrobbles: x.scrobbles, + albumUri: x.albumUri, + artistUri: x.artistUri, + index, + }))} + divider="clean" + overrides={{ + TableHeadRow: { + style: { + display: "none", + }, }, - }, - TableBodyCell: { - style: { - verticalAlign: "center", + TableBodyCell: { + style: { + verticalAlign: "center", + }, }, - }, - TableBodyRow: { - style: { - backgroundColor: "var(--color-background)", - ":hover": { - backgroundColor: "var(--color-menu-hover)", + TableBodyRow: { + style: { + backgroundColor: "var(--color-background)", + ":hover": { + backgroundColor: "var(--color-menu-hover)", + }, }, }, - }, - TableEmptyMessage: { - style: { - backgroundColor: "var(--color-background)", + TableEmptyMessage: { + style: { + backgroundColor: "var(--color-background)", + }, }, - }, - Table: { - style: { - backgroundColor: "var(--color-background)", + Table: { + style: { + backgroundColor: "var(--color-background)", + }, }, - }, - }} - > - - {(row: Row) => ( -
-
-
- {row.index + 1} -
-
- {row.albumUri && ( - - {!!row.albumArt && ( - {row.title} - )} - {!row.albumArt && ( -
- )} - - )} - {!row.albumUri && ( + }} + > + + {(row: Row) => ( +
- {!!row.albumArt && ( - {row.title} - )} - {!row.albumArt && ( -
- )} +
+ {row.index + 1} +
- )} -
- - {row.title} - - {row.artistUri && ( + {row.albumUri && ( - {row.albumArtist} + {!!row.albumArt && ( + {row.title} + )} + {!row.albumArt && ( +
+ )} )} - {!row.artistUri && ( -
- {row.albumArtist} + {!row.albumUri && ( +
+ {!!row.albumArt && ( + {row.title} + )} + {!row.albumArt && ( +
+ )}
)} +
+ + {row.title} + + {row.artistUri && ( + + {row.albumArtist} + + )} + {!row.artistUri && ( +
+ {row.albumArtist} +
+ )} +
-
- )} - - + )} + + + )}

Top Artists

- ({ - id: x.id, - name: x.name, - picture: x.picture, - uri: x.uri, - scrobbles: x.scrobbles, - index, - }))} - divider="clean" - overrides={{ - TableHeadRow: { - style: { - display: "none", + {artistsLoading && ( +
+ + {/* Row 1 */} + + + + + {/* Row 2 */} + + + + + {/* Row 3 */} + + + + + {/* Row 4 */} + + + + + {/* Row 5 */} + + + + + {/* Row 6 */} + + + + +
+ )} + {!artistsLoading && ( + ({ + id: x.id, + name: x.name, + picture: x.picture, + uri: x.uri, + scrobbles: x.scrobbles, + index, + }))} + divider="clean" + overrides={{ + TableHeadRow: { + style: { + display: "none", + }, }, - }, - TableBodyCell: { - style: { - verticalAlign: "middle", + TableBodyCell: { + style: { + verticalAlign: "middle", + }, }, - }, - TableBodyRow: { - style: { - backgroundColor: "var(--color-background)", - ":hover": { - backgroundColor: "var(--color-menu-hover)", + TableBodyRow: { + style: { + backgroundColor: "var(--color-background)", + ":hover": { + backgroundColor: "var(--color-menu-hover)", + }, }, }, - }, - TableEmptyMessage: { - style: { - backgroundColor: "var(--color-background)", + TableEmptyMessage: { + style: { + backgroundColor: "var(--color-background)", + }, }, - }, - Table: { - style: { - backgroundColor: "var(--color-background)", + Table: { + style: { + backgroundColor: "var(--color-background)", + }, }, - }, - }} - > - - {(row: ArtistRow) => ( - diff --git a/apps/web/src/pages/charts/weekly/Weekly.tsx b/apps/web/src/pages/charts/weekly/Weekly.tsx index 15a91cfa..6d36f449 100644 --- a/apps/web/src/pages/charts/weekly/Weekly.tsx +++ b/apps/web/src/pages/charts/weekly/Weekly.tsx @@ -6,6 +6,7 @@ import dayjs from "dayjs"; import numeral from "numeral"; import { useEffect, useRef } from "react"; import { LabelSmall } from "baseui/typography"; +import ContentLoader from "react-content-loader"; type ArtistRow = { id: string; @@ -52,6 +53,62 @@ function Weekly() {
{range}
+ {isLoading && ( + + {/* Header Row */} + + + + + {/* Row 1 */} + + + + + + + {/* Row 2 */} + + + + + + + {/* Row 3 */} + + + + + + + {/* Row 4 */} + + + + + + + {/* Row 5 */} + + + + + + + {/* Row 6 */} + + + + + + + )} {!isLoading && ( <>