Spaces:
Running
Running
Download algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx from iamfebin/algospaced-dsa: direct link, hf CLI and curl.
- Browser
- Download file 21.2 kB
-
https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx
- Command line
-
hf download hf://spaces/iamfebin/algospaced-dsa/algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx
-
curl -L -o DesktopWindowContainer.tsx https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx
21.2 kB
| import React, { lazy, Suspense, useCallback } from 'react'; | |
| import WindowShell from '../WindowShell'; | |
| import type { WindowsMap } from '../../types/windowTypes'; | |
| import type { ProblemItem } from '../../types/reviewTypes'; | |
| import { useOSStore } from '../../stores/useOSStore'; | |
| const ReviewQueue = lazy(() => import('../ReviewQueue')); | |
| const JourneyPath = lazy(() => import('../JourneyPath')); | |
| const TerminalEmulator = lazy(() => import('../TerminalEmulator')); | |
| const PythonChallenge = lazy(() => import('../PythonChallenge')); | |
| const MySQLPlayground = lazy(() => import('../MySQLPlayground')); | |
| const FileExplorer = lazy(() => import('../FileExplorer')); | |
| const Settings = lazy(() => import('../Settings')); | |
| const CreateProblemForm = lazy(() => import('../CreateProblemForm')); | |
| const PrincessChamber = lazy(() => import('../../features/companion/components/PrincessChamber')); | |
| const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow')); | |
| const CardManager = lazy(() => import('../card-manager/CardManager')); | |
| const StoreWindow = lazy(() => import('../store/StoreWindow')); | |
| interface DesktopWindowContainerProps { | |
| windows?: WindowsMap; | |
| activeWindow?: string; | |
| setActiveWindow?: (id: string) => void; | |
| isMobile: boolean; | |
| openWindow?: (id: string) => void; | |
| closeWindow?: (id: string) => void; | |
| minimizeWindow?: (id: string) => void; | |
| overrideProblemId?: string | null; | |
| setOverrideProblemId?: (id: string | null) => void; | |
| editingProblem?: ProblemItem | null; | |
| openEditProblem?: (problem: ProblemItem) => void; | |
| handleSelectProblemForReview?: (problemId: string) => void; | |
| refreshExplorerTrigger?: number; | |
| triggerRefreshExplorer?: () => void; | |
| wallpaperUrl: string; | |
| setWallpaperUrl: (url: string) => void; | |
| syncing: boolean; | |
| syncResult: string | null; | |
| triggerSync: () => void; | |
| } | |
| export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({ | |
| windows: propsWindows, | |
| activeWindow: propsActiveWindow, | |
| setActiveWindow: propsSetActiveWindow, | |
| isMobile, | |
| openWindow: propsOpenWindow, | |
| closeWindow: propsCloseWindow, | |
| minimizeWindow: propsMinimizeWindow, | |
| overrideProblemId: propsOverrideProblemId, | |
| setOverrideProblemId: propsSetOverrideProblemId, | |
| editingProblem: propsEditingProblem, | |
| openEditProblem: propsOpenEditProblem, | |
| handleSelectProblemForReview: propsHandleSelectProblem, | |
| refreshExplorerTrigger: propsRefreshExplorerTrigger, | |
| triggerRefreshExplorer: propsTriggerRefreshExplorer, | |
| wallpaperUrl, | |
| setWallpaperUrl, | |
| syncing, | |
| syncResult, | |
| triggerSync | |
| }) => { | |
| const storeWindows = useOSStore(s => s.windows); | |
| const storeActiveWindow = useOSStore(s => s.activeWindow); | |
| const storeSetActiveWindow = useOSStore(s => s.setActiveWindow); | |
| const storeOpenWindow = useOSStore(s => s.openWindow); | |
| const storeCloseWindow = useOSStore(s => s.closeWindow); | |
| const storeMinimizeWindow = useOSStore(s => s.minimizeWindow); | |
| const storeOverrideProblemId = useOSStore(s => s.overrideProblemId); | |
| const storeSetOverrideProblemId = useOSStore(s => s.setOverrideProblemId); | |
| const storeEditingProblem = useOSStore(s => s.editingProblem); | |
| const storeOpenEditProblem = useOSStore(s => s.openEditProblem); | |
| const storeHandleSelectProblem = useOSStore(s => s.handleSelectProblemForReview); | |
| const storeRefreshTrigger = useOSStore(s => s.refreshExplorerTrigger); | |
| const storeTriggerRefresh = useOSStore(s => s.triggerRefreshExplorer); | |
| const windows = propsWindows ?? storeWindows; | |
| const activeWindow = propsActiveWindow ?? storeActiveWindow; | |
| const setActiveWindow = propsSetActiveWindow ?? storeSetActiveWindow; | |
| const openWindow = propsOpenWindow ?? storeOpenWindow; | |
| const closeWindow = propsCloseWindow ?? storeCloseWindow; | |
| const minimizeWindow = propsMinimizeWindow ?? storeMinimizeWindow; | |
| const overrideProblemId = propsOverrideProblemId !== undefined ? propsOverrideProblemId : storeOverrideProblemId; | |
| const setOverrideProblemId = propsSetOverrideProblemId ?? storeSetOverrideProblemId; | |
| const editingProblem = propsEditingProblem !== undefined ? propsEditingProblem : storeEditingProblem; | |
| const openEditProblem = propsOpenEditProblem ?? storeOpenEditProblem; | |
| const handleSelectProblemForReview = propsHandleSelectProblem ?? storeHandleSelectProblem; | |
| const refreshExplorerTrigger = propsRefreshExplorerTrigger ?? storeRefreshTrigger; | |
| const triggerRefreshExplorer = propsTriggerRefreshExplorer ?? storeTriggerRefresh; | |
| const handleClearOverride = useCallback(() => setOverrideProblemId(null), [setOverrideProblemId]); | |
| const handleOpenJourney = useCallback(() => openWindow('journey'), [openWindow]); | |
| const handleOpenCreateProblem = useCallback(() => openWindow('createProblem'), [openWindow]); | |
| const handleOpenCardManager = useCallback(() => openWindow('cardManager'), [openWindow]); | |
| return ( | |
| <> | |
| {/* 1. Daily Review Queue Window */} | |
| <WindowShell | |
| id="queue" | |
| title="Daily Queue.exe" | |
| icon="terminal" | |
| isOpen={windows.queue.isOpen} | |
| isMinimized={windows.queue.isMinimized} | |
| onClose={() => closeWindow('queue')} | |
| onMinimize={() => minimizeWindow('queue')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="980px" | |
| defaultHeight="680px" | |
| minWidth={440} | |
| minHeight={360} | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading ReviewQueue.exe... | |
| </div> | |
| } | |
| > | |
| <ReviewQueue | |
| overrideProblemId={overrideProblemId} | |
| onClearOverride={handleClearOverride} | |
| onOpenWindow={openWindow} | |
| onOpenJourney={handleOpenJourney} | |
| onOpenCreateProblem={handleOpenCreateProblem} | |
| onOpenEditProblem={openEditProblem} | |
| onOpenCardManager={handleOpenCardManager} | |
| refreshTrigger={refreshExplorerTrigger} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 2. Journey Path Map Window */} | |
| <WindowShell | |
| id="journey" | |
| title="Journey_Path.exe" | |
| icon="route" | |
| isOpen={windows.journey.isOpen} | |
| isMinimized={windows.journey.isMinimized} | |
| onClose={() => closeWindow('journey')} | |
| onMinimize={() => minimizeWindow('journey')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="980px" | |
| defaultHeight="680px" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading JourneyPath.exe... | |
| </div> | |
| } | |
| > | |
| <JourneyPath onSelectProblemForReview={handleSelectProblemForReview} /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 3. Command Line Terminal Window */} | |
| <WindowShell | |
| id="terminal" | |
| title="Arcade Terminal.com" | |
| icon="terminal" | |
| isOpen={windows.terminal.isOpen} | |
| isMinimized={windows.terminal.isMinimized} | |
| onClose={() => closeWindow('terminal')} | |
| onMinimize={() => minimizeWindow('terminal')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="640px" | |
| defaultHeight="450px" | |
| titleBarColor="#1e293b" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading Terminal.exe... | |
| </div> | |
| } | |
| > | |
| <TerminalEmulator onOpenWindow={openWindow} onClose={() => closeWindow('terminal')} /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 4. Google Drive Sync Dialog Window */} | |
| <WindowShell | |
| id="sync" | |
| title="Drive_Sync.sys" | |
| icon="cloud_sync" | |
| isOpen={windows.sync.isOpen} | |
| isMinimized={windows.sync.isMinimized} | |
| onClose={() => closeWindow('sync')} | |
| onMinimize={() => minimizeWindow('sync')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="480px" | |
| defaultHeight="320px" | |
| titleBarColor="#855400" | |
| isMobile={isMobile} | |
| > | |
| <div className="w-full h-full bg-[#fdf8e1] p-6 flex flex-col justify-between"> | |
| <div className="space-y-4"> | |
| <div className="flex items-center gap-3 border-b-2 border-dashed border-ink-black pb-3"> | |
| <span className="material-symbols-outlined text-4xl text-[#855400] animate-bounce"> | |
| cloud_sync | |
| </span> | |
| <div> | |
| <h4 className="font-arcade text-[10px] font-bold text-ink-black"> | |
| DRIVE NOTES SYNCHRONIZATION | |
| </h4> | |
| <span className="text-[8px] font-arcade text-trash-gray font-bold uppercase mt-1 block"> | |
| Importing LeetCode sheets | |
| </span> | |
| </div> | |
| </div> | |
| {syncing ? ( | |
| <div className="space-y-3 py-2"> | |
| <span className="text-[9px] font-arcade text-ink-black font-bold block animate-pulse"> | |
| SYNC PROCESS RUNNING... | |
| </span> | |
| <div className="w-full h-6 bg-white border-[3px] border-ink-black relative overflow-hidden select-none"> | |
| <div className="absolute inset-y-0 left-0 bg-[#ffe24c] border-r-2 border-ink-black w-[75%] animate-pulse" /> | |
| </div> | |
| <p className="text-[9px] font-sans text-trash-gray leading-normal font-semibold"> | |
| Connecting to Supabase partition, requesting Google Drive manifest, indexing note items... | |
| </p> | |
| </div> | |
| ) : ( | |
| <div className="p-3 bg-white border-[3px] border-ink-black text-xs font-semibold text-ink-black leading-relaxed shadow-[2px_2px_0px_0px_#1E293B]"> | |
| {syncResult || 'Idle. Ready to synchronize review data logs from Sheets drive storage.'} | |
| </div> | |
| )} | |
| </div> | |
| <div className="flex gap-3 justify-end pt-4 border-t border-slate-200"> | |
| <button | |
| onClick={() => closeWindow('sync')} | |
| className="px-4 py-2 bg-white hover:bg-slate-100 text-ink-black border-[3px] border-ink-black font-bold text-xs shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer" | |
| > | |
| CLOSE | |
| </button> | |
| <button | |
| onClick={triggerSync} | |
| disabled={syncing} | |
| className="px-4 py-2 bg-[#ffcc00] hover:bg-yellow-300 text-ink-black border-[3px] border-ink-black font-bold text-xs shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none disabled:opacity-50 cursor-pointer" | |
| > | |
| {syncing ? 'SYNCING...' : 'SYNC NOW'} | |
| </button> | |
| </div> | |
| </div> | |
| </WindowShell> | |
| {/* GitHub Solutions Sync Station Window */} | |
| <WindowShell | |
| id="github" | |
| title="GitHub_Sync.exe" | |
| icon="terminal" | |
| isOpen={windows.github?.isOpen ?? false} | |
| isMinimized={windows.github?.isMinimized ?? false} | |
| onClose={() => closeWindow('github')} | |
| onMinimize={() => minimizeWindow('github')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="620px" | |
| defaultHeight="520px" | |
| titleBarColor="#24292e" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading GitHub_Sync.exe... | |
| </div> | |
| } | |
| > | |
| <GitHubSyncWindow onClose={() => closeWindow('github')} /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 5. My Computer Window (Interactive File Explorer) */} | |
| <WindowShell | |
| id="computer" | |
| title="File Explorer" | |
| icon="desktop_windows" | |
| isOpen={windows.computer.isOpen} | |
| isMinimized={windows.computer.isMinimized} | |
| onClose={() => closeWindow('computer')} | |
| onMinimize={() => minimizeWindow('computer')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="640px" | |
| defaultHeight="480px" | |
| titleBarColor="#006686" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading FileExplorer.exe... | |
| </div> | |
| } | |
| > | |
| <FileExplorer | |
| onSetWallpaper={setWallpaperUrl} | |
| activeWallpaperUrl={wallpaperUrl} | |
| onOpenCreateProblem={() => openWindow('createProblem')} | |
| onOpenQueue={() => openWindow('queue')} | |
| onOpenJourney={() => openWindow('journey')} | |
| refreshTrigger={refreshExplorerTrigger} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 5b. Create Problem Window */} | |
| {windows.createProblem?.isOpen && ( | |
| <WindowShell | |
| id="createProblem" | |
| title="Create Problem" | |
| icon="note_add" | |
| isOpen={windows.createProblem.isOpen} | |
| isMinimized={windows.createProblem.isMinimized} | |
| onClose={() => closeWindow('createProblem')} | |
| onMinimize={() => minimizeWindow('createProblem')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="640px" | |
| defaultHeight="700px" | |
| titleBarColor="#a855f7" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading CreateForm.exe... | |
| </div> | |
| } | |
| > | |
| <CreateProblemForm | |
| onClose={() => closeWindow('createProblem')} | |
| onSuccess={() => { | |
| triggerRefreshExplorer(); | |
| openWindow('queue'); | |
| }} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| )} | |
| {/* 5c. Edit Problem Window */} | |
| {windows.editProblem?.isOpen && ( | |
| <WindowShell | |
| id="editProblem" | |
| title={ | |
| editingProblem | |
| ? `Edit Problem: #${editingProblem.problem_number ?? '—'} ${editingProblem.name}` | |
| : 'Edit Problem' | |
| } | |
| icon="edit_note" | |
| isOpen={windows.editProblem.isOpen} | |
| isMinimized={windows.editProblem.isMinimized} | |
| onClose={() => closeWindow('editProblem')} | |
| onMinimize={() => minimizeWindow('editProblem')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="760px" | |
| defaultHeight="720px" | |
| defaultX={30} | |
| defaultY={25} | |
| titleBarColor="#059669" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading EditProblem.exe... | |
| </div> | |
| } | |
| > | |
| <CreateProblemForm | |
| key={editingProblem?.id || (editingProblem?.problem_number !== undefined ? String(editingProblem.problem_number) : 'edit-problem')} | |
| mode="edit" | |
| initialProblem={editingProblem} | |
| onClose={() => closeWindow('editProblem')} | |
| onSuccess={() => { | |
| closeWindow('editProblem'); | |
| triggerRefreshExplorer(); | |
| openWindow('queue'); | |
| }} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| )} | |
| {/* 6. Daily Python Challenge Window */} | |
| <WindowShell | |
| id="python" | |
| title="Python Challenge" | |
| icon="sports_esports" | |
| isOpen={windows.python.isOpen} | |
| isMinimized={windows.python.isMinimized} | |
| onClose={() => closeWindow('python')} | |
| onMinimize={() => minimizeWindow('python')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="620px" | |
| defaultHeight="580px" | |
| titleBarColor="#9d4edd" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading PythonChallenge.exe... | |
| </div> | |
| } | |
| > | |
| <PythonChallenge /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 7. MySQL Playground Window */} | |
| <WindowShell | |
| id="mysql" | |
| title="MySQL Playground" | |
| icon="database" | |
| isOpen={windows.mysql.isOpen} | |
| isMinimized={windows.mysql.isMinimized} | |
| onClose={() => closeWindow('mysql')} | |
| onMinimize={() => minimizeWindow('mysql')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="660px" | |
| defaultHeight="580px" | |
| titleBarColor="#0ea5e9" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading MySQLPlayground.exe... | |
| </div> | |
| } | |
| > | |
| <MySQLPlayground /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 8. API Control Panel Window */} | |
| <WindowShell | |
| id="settings" | |
| title="API Configuration" | |
| icon="key" | |
| isOpen={windows.settings?.isOpen} | |
| isMinimized={windows.settings?.isMinimized} | |
| onClose={() => closeWindow('settings')} | |
| onMinimize={() => minimizeWindow('settings')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="520px" | |
| defaultHeight="460px" | |
| titleBarColor="#10b981" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading APIConfig.exe... | |
| </div> | |
| } | |
| > | |
| <Settings /> | |
| </Suspense> | |
| </WindowShell> | |
| {/* 9. Princess Tower Companion - JRPG Dialogue Stage */} | |
| {windows.companion?.isOpen && !windows.companion.isMinimized && ( | |
| <Suspense fallback={null}> | |
| <PrincessChamber | |
| onClose={() => closeWindow('companion')} | |
| onMinimize={() => minimizeWindow('companion')} | |
| isActive={activeWindow === 'companion'} | |
| onFocus={() => setActiveWindow('companion')} | |
| isMobile={isMobile} | |
| /> | |
| </Suspense> | |
| )} | |
| {/* 10. Anki Card Manager Window */} | |
| {windows.cardManager?.isOpen && ( | |
| <WindowShell | |
| id="cardManager" | |
| title="FSRS Card Manager" | |
| icon="style" | |
| isOpen={windows.cardManager.isOpen} | |
| isMinimized={windows.cardManager.isMinimized} | |
| onClose={() => closeWindow('cardManager')} | |
| onMinimize={() => minimizeWindow('cardManager')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="1020px" | |
| defaultHeight="700px" | |
| minWidth={520} | |
| minHeight={420} | |
| titleBarColor="#0284c7" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading CardManager.exe... | |
| </div> | |
| } | |
| > | |
| <CardManager | |
| onOpenQueue={() => openWindow('queue')} | |
| onOpenCreateProblem={() => openWindow('createProblem')} | |
| onOpenEditProblem={openEditProblem} | |
| onSelectProblemForReview={handleSelectProblemForReview} | |
| refreshTrigger={refreshExplorerTrigger} | |
| onRefreshExplorer={triggerRefreshExplorer} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| )} | |
| {/* 13. Store Window */} | |
| {windows.store?.isOpen && ( | |
| <WindowShell | |
| id="store" | |
| title="Store" | |
| icon="storefront" | |
| isOpen={windows.store.isOpen} | |
| isMinimized={windows.store.isMinimized} | |
| onClose={() => closeWindow('store')} | |
| onMinimize={() => minimizeWindow('store')} | |
| activeWindow={activeWindow} | |
| setActiveWindow={setActiveWindow} | |
| defaultWidth="940px" | |
| defaultHeight="660px" | |
| minWidth={460} | |
| minHeight={380} | |
| titleBarColor="#d97706" | |
| isMobile={isMobile} | |
| > | |
| <Suspense | |
| fallback={ | |
| <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse"> | |
| Loading Emporium.sys... | |
| </div> | |
| } | |
| > | |
| <StoreWindow | |
| onClose={() => closeWindow('store')} | |
| onOpenCompanion={() => openWindow('companion')} | |
| /> | |
| </Suspense> | |
| </WindowShell> | |
| )} | |
| </> | |
| ); | |
| }; | |