diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx index 21b792a..4e619fd 100644 --- a/src/pages/DashboardPage.tsx +++ b/src/pages/DashboardPage.tsx @@ -1,8 +1,10 @@ import { useState, useEffect } from 'react' import { useAuth } from '@/hooks/use-auth' import { useDashboardStats, type TimePeriod } from '@/hooks/use-dashboard-stats' -import { formatSize, formatSizeObject } from '@/lib/format-size' +import { formatSizeObject } from '@/lib/format-size' import NumberFlow from '@number-flow/react' +import { Volume2, Music, List, HardDrive, Users } from 'lucide-react' +import { useTheme } from '@/hooks/use-theme' const PERIOD_OPTIONS = [ { value: 'today' as TimePeriod, label: 'Today' }, @@ -19,11 +21,110 @@ const LIMIT_OPTIONS = [ { value: 50, label: 'Top 50' }, ] +// Theme-aware color schemes +const lightModeColors = { + sounds: { + gradient: 'from-blue-300/10 to-blue-600/20', + border: 'border-blue-200/50', + iconBg: 'from-blue-500 to-blue-600', + textGradient: 'from-blue-600 to-blue-700', + text: 'text-blue-600', + textMuted: 'text-blue-600/70', + itemBg: 'from-blue-50/50 to-indigo-50/50', + itemBorder: 'border-blue-100/50', + itemHover: 'hover:from-blue-50 hover:to-indigo-50', + }, + tracks: { + gradient: 'from-green-500/10 to-green-600/20', + border: 'border-green-200/50', + iconBg: 'from-green-500 to-green-600', + textGradient: 'from-green-600 to-green-700', + text: 'text-green-600', + textMuted: 'text-green-500/70', + itemBg: 'from-green-50/50 to-emerald-50/50', + itemBorder: 'border-green-100/50', + itemHover: 'hover:from-green-50 hover:to-emerald-50', + }, + playlists: { + gradient: 'from-purple-500/10 to-purple-600/20', + border: 'border-purple-200/50', + iconBg: 'from-purple-500 to-purple-600', + textGradient: 'from-purple-600 to-purple-700', + text: 'text-purple-600', + textMuted: 'text-purple-600/70', + itemBg: 'from-purple-50/50 to-pink-50/50', + itemBorder: 'border-purple-100/50', + itemHover: 'hover:from-purple-50 hover:to-pink-50', + }, + storage: { + gradient: 'from-orange-500/10 to-orange-600/20', + border: 'border-orange-200/50', + iconBg: 'from-orange-500 to-orange-600', + textGradient: 'from-orange-600 to-orange-700', + text: 'text-orange-600', + textMuted: 'text-orange-600/70', + itemBg: 'from-orange-50/50 to-red-50/50', + itemBorder: 'border-orange-100/50', + itemHover: 'hover:from-orange-50 hover:to-red-50', + }, +} + +const darkModeColors = { + sounds: { + gradient: 'from-blue-800/20 to-blue-900/30', + border: 'border-blue-700/50', + iconBg: 'from-blue-600 to-blue-700', + textGradient: 'from-blue-400 to-blue-300', + text: 'text-blue-400', + textMuted: 'text-blue-400/70', + itemBg: 'from-blue-900/20 to-indigo-900/20', + itemBorder: 'border-blue-700/30', + itemHover: 'hover:from-blue-900/30 hover:to-indigo-900/30', + }, + tracks: { + gradient: 'from-green-800/20 to-green-900/30', + border: 'border-green-700/50', + iconBg: 'from-green-600 to-green-700', + textGradient: 'from-green-400 to-green-300', + text: 'text-green-400', + textMuted: 'text-green-400/70', + itemBg: 'from-green-900/20 to-emerald-900/20', + itemBorder: 'border-green-700/30', + itemHover: 'hover:from-green-900/30 hover:to-emerald-900/30', + }, + playlists: { + gradient: 'from-purple-800/20 to-purple-900/30', + border: 'border-purple-700/50', + iconBg: 'from-purple-600 to-purple-700', + textGradient: 'from-purple-400 to-purple-300', + text: 'text-purple-400', + textMuted: 'text-purple-400/70', + itemBg: 'from-purple-900/20 to-pink-900/20', + itemBorder: 'border-purple-700/30', + itemHover: 'hover:from-purple-900/30 hover:to-pink-900/30', + }, + storage: { + gradient: 'from-orange-800/20 to-orange-900/30', + border: 'border-orange-700/50', + iconBg: 'from-orange-600 to-orange-700', + textGradient: 'from-orange-400 to-orange-300', + text: 'text-orange-400', + textMuted: 'text-orange-400/70', + itemBg: 'from-orange-900/20 to-red-900/20', + itemBorder: 'border-orange-700/30', + itemHover: 'hover:from-orange-900/30 hover:to-red-900/30', + }, +} + export function DashboardPage() { const { user } = useAuth() const [selectedPeriod, setSelectedPeriod] = useState('today') const [selectedLimit, setSelectedLimit] = useState(5) const { stats, topSounds, topTracks, topUsers, loading, error, refresh } = useDashboardStats(selectedPeriod, selectedLimit) + const { theme } = useTheme() + + // Theme-aware color selection + const colors = theme === 'dark' ? darkModeColors : lightModeColors // Auto-refresh every 10 seconds useEffect(() => { @@ -51,42 +152,54 @@ export function DashboardPage() { <> {/* Statistics Cards */}
-
+
+
+ +
-
+
-
+
Sounds
-
+
+
+ +
-
+
-
+
Tracks
-
+
+
+ +
-
+
-
+
Playlists
-
+
+
+ +
-
+
{(() => { const sizeObj = formatSizeObject(stats.total_size, true) return ( @@ -96,7 +209,7 @@ export function DashboardPage() { ) })()}
-
+
Total Size
@@ -133,17 +246,29 @@ export function DashboardPage() {
{/* Top Sounds Section */}
-

Played Sounds

+
+
+ +
+

+ Played Sounds +

+
{topSounds && topSounds.sounds.length > 0 ? (
{topSounds.sounds.map((sound, index) => (
-
+
{index + 1}
@@ -154,8 +279,8 @@ export function DashboardPage() {
-
-
+
+
{sound.play_count === 1 ? 'play' : 'plays'}
@@ -171,17 +296,29 @@ export function DashboardPage() { {/* Top Tracks Section */}
-

Played Tracks

+
+
+ +
+

+ Played Tracks +

+
{topTracks && topTracks.tracks.length > 0 ? (
{topTracks.tracks.map((track, index) => (
-
+
{index + 1}
@@ -192,8 +329,8 @@ export function DashboardPage() {
-
-
+
+
{track.play_count === 1 ? 'play' : 'plays'}
@@ -209,17 +346,29 @@ export function DashboardPage() { {/* Top Users Section */}
-

Users

+
+
+ +
+

+ Top Users +

+
{topUsers && topUsers.users.length > 0 ? (
{topUsers.users.map((user, index) => (
-
+
{index + 1}
@@ -227,7 +376,7 @@ export function DashboardPage() { {user.name} )}
@@ -239,8 +388,8 @@ export function DashboardPage() {
-
-
+
+
{user.play_count === 1 ? 'play' : 'plays'}