File size: 5,077 Bytes
c095e08
 
 
 
 
 
3e6f1d3
c095e08
 
 
 
 
 
 
 
 
3e6f1d3
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e6f1d3
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e6f1d3
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { useState, useEffect } from 'react'
import './index.css'

// Icons
import {
  IconLive, IconTarget, IconChart, IconTrophy, IconCrown,
  IconVs, IconRefresh, IconBarChart
} from './icons'

// Pages
import LiveGames from './pages/LiveGames'
import Predictions from './pages/Predictions'
import Accuracy from './pages/Accuracy'
import MvpRace from './pages/MvpRace'
import Championship from './pages/Championship'
import HeadToHead from './pages/HeadToHead'
import Analytics from './pages/Analytics'

// Chevron icon for collapse toggle
function IconChevron({ className = '', direction = 'left' }) {
  return (
    <svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
      {direction === 'left' ? (
        <polyline points="15 18 9 12 15 6"></polyline>
      ) : (
        <polyline points="9 18 15 12 9 6"></polyline>
      )}
    </svg>
  )
}

function App() {
  const [activePage, setActivePage] = useState('live')
  const [isRefreshing, setIsRefreshing] = useState(false)
  const [sidebarCollapsed, setSidebarCollapsed] = useState(false)
  const [sidebarHovered, setSidebarHovered] = useState(false)

  const handleRefresh = () => {
    setIsRefreshing(true)
    window.location.reload()
  }

  const navSections = [
    {
      title: 'Games',
      items: [
        { id: 'live', name: 'Live Games', icon: IconLive },
        { id: 'predictions', name: 'Predictions', icon: IconTarget },
      ]
    },
    {
      title: 'Analysis',
      items: [
        { id: 'h2h', name: 'Head to Head', icon: IconVs },
        { id: 'analytics', name: 'Analytics', icon: IconBarChart },
        { id: 'accuracy', name: 'Model Accuracy', icon: IconChart },
      ]
    },
    {
      title: 'Rankings',
      items: [
        { id: 'mvp', name: 'MVP Race', icon: IconTrophy },
        { id: 'championship', name: 'Championship', icon: IconCrown },
      ]
    }
  ]

  const renderPage = () => {
    switch (activePage) {
      case 'live': return <LiveGames />
      case 'predictions': return <Predictions />
      case 'accuracy': return <Accuracy />
      case 'analytics': return <Analytics />
      case 'mvp': return <MvpRace />
      case 'championship': return <Championship />
      case 'h2h': return <HeadToHead />
      default: return <LiveGames />
    }
  }

  // Determine if sidebar should be expanded (not collapsed OR being hovered)
  const isExpanded = !sidebarCollapsed || sidebarHovered

  return (
    <div className={`app-layout ${sidebarCollapsed ? 'sidebar-collapsed' : ''}`}>
      {/* Sidebar */}
      <aside
        className={`sidebar ${sidebarCollapsed ? 'collapsed' : ''} ${sidebarHovered ? 'hovered' : ''}`}
        onMouseEnter={() => sidebarCollapsed && setSidebarHovered(true)}
        onMouseLeave={() => setSidebarHovered(false)}
      >
        <div className="sidebar-header">
          <div className="sidebar-logo">
            <div className="sidebar-logo-icon">
              <img
                src="https://cdn.nba.com/logos/leagues/logo-nba.svg"
                alt="NBA"
                style={{ width: '32px', height: '32px' }}
              />
            </div>
            <span className="sidebar-logo-text">NBA sage</span>
          </div>
          <button
            className="sidebar-toggle"
            onClick={() => {
              setSidebarCollapsed(!sidebarCollapsed)
              setSidebarHovered(false)
            }}
            title={sidebarCollapsed ? 'Expand sidebar' : 'Collapse sidebar'}
          >
            <IconChevron direction={sidebarCollapsed ? 'right' : 'left'} />
          </button>
        </div>

        <nav className="sidebar-nav">
          {navSections.map((section) => (
            <div key={section.title} className="nav-section">
              <div className="nav-section-title">{section.title}</div>
              {section.items.map((item) => (
                <div
                  key={item.id}
                  className={`nav-item ${activePage === item.id ? 'active' : ''}`}
                  onClick={() => setActivePage(item.id)}
                  title={sidebarCollapsed && !sidebarHovered ? item.name : ''}
                >
                  <item.icon className="nav-icon" />
                  <span className="nav-text">{item.name}</span>
                </div>
              ))}
            </div>
          ))}
        </nav>

        <div className="sidebar-footer">
          <button
            className="btn btn-ghost btn-block"
            onClick={handleRefresh}
            disabled={isRefreshing}
            title={sidebarCollapsed && !sidebarHovered ? 'Refresh Data' : ''}
          >
            <IconRefresh className={`nav-icon ${isRefreshing ? 'spinning' : ''}`} />
            <span className="nav-text">Refresh Data</span>
          </button>
          <div className="sidebar-version">
            NBA sage
          </div>
        </div>
      </aside>

      {/* Main Content */}
      <main className="main-content">
        {renderPage()}
      </main>
    </div>
  )
}

export default App