GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — tutorials/src/App.tsx at main · SitecorePowerShell/tutorials Expand file tree/ Copy pathApp.tsxMore file actions 1438 lines (1369 loc) · 54.5 KB / Copy pathApp.tsxFile metadata and controls1438 lines (1369 loc) · 54.5 KB 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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 import { useState, useEffect, useCallback, useRef, useMemo } from "react"; import type { ConsoleEntry, QuizResult } from "./types"; import type { PipelineStage } from "./builder/assembleCommand"; import { LESSONS } from "./lessons/loader"; import { QUIZZES, getQuizForModule } from "./quizzes/loader"; import { validateTask } from "./validation/validator"; import { LocalProvider } from "./providers/LocalProvider"; import { SpeRemotingProvider } from "./providers/SpeRemotingProvider"; import type { ExecutionProvider, ConnectionConfig, ConnectionTestResult } from "./providers/types"; import { loadProgress, saveProgress, clearProgress } from "./hooks/useSessionProgress"; import { loadUIPreferences, saveUIPreferences, type ActivePanel } from "./hooks/useUIPreferences"; import { useMediaQuery } from "./hooks/useMediaQuery"; import { Sidebar } from "./components/Sidebar"; import { LessonPanel } from "./components/LessonPanel"; import { QuizPanel } from "./components/QuizPanel"; import { ReplEditor } from "./components/ReplEditor"; import { IseEditor } from "./components/IseEditor"; import { BuilderEditor } from "./components/BuilderEditor"; import { EditorWithBuilderToggle } from "./components/EditorWithBuilderToggle"; import { TreePanel } from "./components/TreePanel"; import { MobileTabBar, type MobilePanel } from "./components/MobileTabBar"; import { colors, fonts, fontSizes, fontSizesMobile, applyTheme, getInitialThemeMode, type ThemeMode } from "./theme"; import { GlobalA11yStyles } from "./components/GlobalA11yStyles"; import { LandingPage } from "./components/LandingPage"; import { VirtualTour, DESKTOP_STEPS, MOBILE_STEPS } from "./components/VirtualTour"; import { useTourState } from "./hooks/useTourState"; import { HelpPanel } from "./components/HelpPanel"; import { KeyboardShortcuts } from "./components/KeyboardShortcuts"; import { ConnectionManager } from "./components/ConnectionManager"; import { CheatSheetDrawer } from "./components/CheatSheetDrawer"; const initialProgress = loadProgress(); const initialPrefs = loadUIPreferences(); const initialTheme = getInitialThemeMode(); applyTheme(initialTheme); export default function SPETutorial() { const [currentLesson, setCurrentLesson] = useState(initialProgress.currentLesson); const [currentTask, setCurrentTask] = useState(initialProgress.currentTask); const [code, setCode] = useState(""); const [consoleOutput, setConsoleOutput] = useState<ConsoleEntry[]>([]); const [completedTasks, setCompletedTasks] = useState< Record<string, boolean> >(initialProgress.completedTasks); const [taskAttempts, setTaskAttempts] = useState<Record<string, number>>(initialProgress.taskAttempts); const [revealedHintLevel, setRevealedHintLevel] = useState(0); const [sidebarCollapsed, setSidebarCollapsed] = useState(initialProgress.sidebarCollapsed); const [activePanel, setActivePanel] = useState<ActivePanel>(initialPrefs.activePanel); const [commandHistory, setCommandHistory] = useState<string[]>([]); const [historyIndex, setHistoryIndex] = useState(-1); const [mobilePanel, setMobilePanel] = useState<MobilePanel>("lesson"); const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false); const [lessonPanelHeight, setLessonPanelHeight] = useState(200); const [lessonPanelCollapsed, setLessonPanelCollapsed] = useState(initialPrefs.lessonPanelCollapsed); const [layoutStacked, setLayoutStacked] = useState(initialPrefs.layoutStacked); const [cwd, setCwd] = useState("/sitecore/content/Home"); const [builderToggleActive, setBuilderToggleActive] = useState(false); const [builderStages, setBuilderStages] = useState<PipelineStage[]>([]); const [builderSelectedStageId, setBuilderSelectedStageId] = useState<string | null>(null); const [a11yAnnouncement, setA11yAnnouncement] = useState(""); const [themeMode, setThemeMode] = useState<ThemeMode>(initialTheme); const [activeQuiz, setActiveQuiz] = useState<string | null>(null); const [quizResults, setQuizResults] = useState<Record<string, QuizResult>>(initialProgress.quizResults); const [helpPanelCmdlet, setHelpPanelCmdlet] = useState<string | null>(null); const [shortcutsOpen, setShortcutsOpen] = useState(false); const [cheatSheetOpen, setCheatSheetOpen] = useState(false); const [isExecuting, setIsExecuting] = useState(false); const [variablesSnapshot, setVariablesSnapshot] = useState<Record<string, unknown> | null>(null); const [latestError, setLatestError] = useState<string | undefined>(undefined); const [connectionConfig, setConnectionConfig] = useState<ConnectionConfig | null>(null); const [connectionInfo, setConnectionInfo] = useState<ConnectionTestResult | null>(null); const tour = useTourState(); const providerRef = useRef<ExecutionProvider>(new LocalProvider()); const lessonPanelRef = useRef<HTMLDivElement>(null); const isDraggingLessonPanel = useRef(false); const editorHeightRef = useRef(initialPrefs.editorHeight); const hasInitializedHeight = useRef(false); const isMobile = useMediaQuery("(max-width: 767px)"); const isTablet = useMediaQuery("(min-width: 768px) and (max-width: 1024px)"); const fs = isMobile ? fontSizesMobile : fontSizes; const lesson = LESSONS[currentLesson]; const task = lesson?.tasks?.[currentTask]; const isISE = lesson?.mode === "ise"; const isBuilder = lesson?.mode === "builder"; // Provide tree for TreePanel — wraps provider's tree in expected shape const treeForPanel = useMemo( () => ({ sitecore: providerRef.current.getTree() }), [connectionConfig] ); const totalTasks = LESSONS.reduce((sum, l) => sum + l.tasks.length, 0); const completedCount = Object.keys(completedTasks).length; const showLanding = currentLesson === -1; const activeQuizData = activeQuiz ? QUIZZES.find((q) => q.id === activeQuiz) : undefined; // Determine if the current lesson is the last in its module and a quiz is available const quizNextLabel = (() => { if (!lesson) return undefined; const nextIdx = currentLesson + 1; const isLastInModule = nextIdx >= LESSONS.length || LESSONS[nextIdx].module !== lesson.module; if (!isLastInModule) return undefined; const quiz = getQuizForModule(lesson.module); if (!quiz || quizResults[quiz.id]?.completed) return undefined; return "Take Module Quiz →"; })(); // Persist progress to localStorage useEffect(() => { saveProgress({ currentLesson, currentTask, completedTasks, taskAttempts, sidebarCollapsed, quizResults, }); }, [currentLesson, currentTask, completedTasks, taskAttempts, sidebarCollapsed, quizResults]); // Initialize lesson panel height from saved percentage once container is measured useEffect(() => { if (hasInitializedHeight.current) return; const container = lessonPanelRef.current?.parentElement; if (!container) return; const containerH = container.getBoundingClientRect().height; if (containerH > 0) { const maxHeight = containerH * 0.5; const targetHeight = containerH * (initialPrefs.lessonPanelHeightPercent / 100); setLessonPanelHeight(Math.max(80, Math.min(targetHeight, maxHeight))); hasInitializedHeight.current = true; } }); // Persist UI preferences to localStorage useEffect(() => { const container = lessonPanelRef.current?.parentElement; const containerH = container?.getBoundingClientRect().height; const heightPercent = containerH && containerH > 0 ? (lessonPanelHeight / containerH) * 100 : initialPrefs.lessonPanelHeightPercent; saveUIPreferences({ layoutStacked, lessonPanelHeightPercent: Math.round(heightPercent), editorHeight: editorHeightRef.current, activePanel, lessonPanelCollapsed, }); }, [layoutStacked, lessonPanelHeight, activePanel, lessonPanelCollapsed]); const handleThemeToggle = useCallback(() => { setThemeMode((prev) => { const next = prev === "dark" ? "light" : "dark"; applyTheme(next); try { localStorage.setItem("spe-theme-mode", next); } catch { /* ignore */ } return next; }); }, []); const handleGetStarted = useCallback(() => { setCurrentLesson(0); setCurrentTask(0); // Prompt "Would you like a tour?" for first-time visitors setTimeout(() => tour.promptTour(), 400); }, []); const handleResetProgress = useCallback(() => { clearProgress(); setCurrentLesson(-1); setCurrentTask(0); setCompletedTasks({}); setTaskAttempts({}); setSidebarCollapsed(false); setQuizResults({}); setActiveQuiz(null); }, []); const handleBuilderInsert = useCallback((command: string) => { if (isISE) { setCode((prev) => prev ? prev + "\n" + command + "\n" : command + "\n"); } else { setCode(command); } setBuilderToggleActive(false); }, [isISE]); // Switch provider when connection config changes useEffect(() => { if (connectionConfig) { providerRef.current = new SpeRemotingProvider(connectionConfig); } else { providerRef.current = new LocalProvider(); setConnectionInfo(null); } setCwd(providerRef.current.getCwd()); }, [connectionConfig]); // Async connect handler — tests connection before switching provider const handleConnect = useCallback(async (config: ConnectionConfig): Promise<ConnectionTestResult> => { const provider = new SpeRemotingProvider(config); const result = await provider.testConnection(); if (result.connected) { setConnectionConfig(config); setConnectionInfo(result); } return result; }, []); const handleDisconnect = useCallback(() => { setConnectionConfig(null); }, []); const handleReset = useCallback(() => { setConsoleOutput([]); providerRef.current.reset(); setCwd(providerRef.current.getCwd()); const t = LESSONS[currentLesson]?.tasks?.[currentTask]; setCode(t?.starterCode || "# Write your script here\n"); }, [currentLesson, currentTask]); // Reset editor, output, and cwd when switching lessons or tasks useEffect(() => { setConsoleOutput([]); setRevealedHintLevel(0); setBuilderToggleActive(false); setBuilderStages([]); setBuilderSelectedStageId(null); // Reset provider state (cwd, variables) on lesson/task change providerRef.current.reset(); setCwd(providerRef.current.getCwd()); if (isBuilder) { setCode(""); // Builder drives code via onCodeChange } else if (isISE && task?.starterCode) { setCode(task.starterCode); } else if (isISE) { setCode("# Write your script here\n"); } else { setCode(""); } }, [currentLesson, currentTask]); const handleRun = useCallback((codeOverride?: string) => { const effective = typeof codeOverride === "string" ? codeOverride : code; if (!effective.trim()) return; if (isExecuting) return; const taskKey = `${currentLesson}-${currentTask}`; // Handle clear commands in console mode const trimmed = effective.trim().toLowerCase(); if (trimmed === "clear-host" || trimmed === "clear" || trimmed === "cls") { setConsoleOutput([]); const historyEntry = effective.trim().split("\n").map((l) => l.trim()).filter(Boolean).join(" "); setCommandHistory((prev) => [...prev, historyEntry]); setHistoryIndex(-1); setCode(""); return; } const provider = providerRef.current; const currentCwd = provider.getCwd(); const cwdDisplay = `master:\\${currentCwd.replace(/^\/sitecore\//, "").replace(/\//g, "\\")}`; // Build command echo entries synchronously const echoEntries: ConsoleEntry[] = []; if (!isISE && !isBuilder) { echoEntries.push({ type: "command", text: effective.trim(), cwd: cwdDisplay }); } if (isISE) { echoEntries.push({ type: "script", text: effective.trim() }); } // Normalize for REPL mode const scriptToRun = isISE ? effective : effective .split("\n") .map((l) => l.trim()) .filter((l) => l && !l.startsWith("#")) .join(" "); // Execute via provider (async — supports both local and remote) setIsExecuting(true); const executePromise = isISE ? provider.executeScript(scriptToRun) : provider.executeCommand(scriptToRun); executePromise .then((providerResult) => { let newOutput: ConsoleEntry[] = [ ...consoleOutput, ...echoEntries, ...providerResult.entries, ]; // Sync cwd from provider if (providerResult.cwd && providerResult.cwd !== cwd) { setCwd(providerResult.cwd); } // Snapshot variables for the Variables panel (LocalProvider only; // remote providers don't expose runspace state). Shallow-clone so // resetPerExecution on the next run doesn't mutate this React state. if (typeof provider.getVariables === "function") { const vars = provider.getVariables(); setVariablesSnapshot(vars ? { ...vars } : null); } const errEntry = providerResult.entries.find((e) => e.type === "error"); setLatestError(errEntry ? errEntry.text : undefined); // Validate against current task (always uses local engine) if (task) { const validation = validateTask(effective.trim(), task); if (validation.passed) { newOutput.push({ type: "success", text: `✓ ${task.successMessage || "Correct!"}`, }); setCompletedTasks((prev) => ({ ...prev, [taskKey]: true })); setA11yAnnouncement( `Task completed: ${task.successMessage || "Correct!"}` ); setTimeout(() => setA11yAnnouncement(""), 3000); } else { setTaskAttempts((prev) => ({ ...prev, [taskKey]: (prev[taskKey] || 0) + 1, })); newOutput.push({ type: "hint", text: validation.feedback || "", }); if (validation.partial) { newOutput.push({ type: "partial", text: validation.partial.join(" → "), }); } } } // Prune old entries to prevent unbounded growth const MAX_ENTRIES = 500; if (newOutput.length > MAX_ENTRIES) { newOutput = newOutput.slice(newOutput.length - MAX_ENTRIES); } setConsoleOutput(newOutput); if (!isISE && !isBuilder) { const historyEntry = effective .trim() .split("\n") .map((l) => l.trim()) .filter(Boolean) .join(" "); setCommandHistory((prev) => [...prev, historyEntry]); setHistoryIndex(-1); setCode(""); } }) .catch((err) => { setConsoleOutput((prev) => [ ...prev, ...echoEntries, { type: "error", text: `Execution failed: ${err instanceof Error ? err.message : String(err)}`, }, ]); }) .finally(() => { setIsExecuting(false); }); }, [code, consoleOutput, currentLesson, currentTask, task, isISE, isBuilder, isExecuting, cwd]); const advanceTask = () => { if (currentTask < lesson.tasks.length - 1) { setCurrentTask(currentTask + 1); } else { // Last task in lesson — check if this is the last lesson in the module // and a quiz is available const currentModule = lesson.module; const nextLessonIdx = currentLesson + 1; const isLastInModule = nextLessonIdx >= LESSONS.length || LESSONS[nextLessonIdx].module !== currentModule; if (isLastInModule) { const quiz = getQuizForModule(currentModule); if (quiz && !quizResults[quiz.id]?.completed) { setActiveQuiz(quiz.id); return; } } if (currentLesson < LESSONS.length - 1) { setCurrentLesson(currentLesson + 1); setCurrentTask(0); } } }; const goToLesson = (idx: number) => { setCurrentLesson(idx); setCurrentTask(0); setActiveQuiz(null); if (isMobile) { setMobileSidebarOpen(false); setMobilePanel("lesson"); } }; const goToQuiz = (quizId: string) => { setActiveQuiz(quizId); if (isMobile) { setMobileSidebarOpen(false); setMobilePanel("lesson"); } }; const handleQuizComplete = useCallback((result: QuizResult) => { if (!activeQuiz) return; setQuizResults((prev) => ({ ...prev, [activeQuiz]: result })); }, [activeQuiz]); const handleQuizSkip = useCallback(() => { // Navigate to the first lesson of the next module if (activeQuiz) { const quiz = QUIZZES.find((q) => q.id === activeQuiz); if (quiz) { const nextModuleLesson = LESSONS.findIndex( (l, i) => i > 0 && l.module !== quiz.module && LESSONS[i - 1]?.module === quiz.module ); if (nextModuleLesson >= 0) { setCurrentLesson(nextModuleLesson); setCurrentTask(0); } } } setActiveQuiz(null); }, [activeQuiz]); const goToTask = (taskIdx: number) => { setCurrentTask(taskIdx); }; const isTaskComplete = (lessonIdx: number, taskIdx: number) => !!completedTasks[`${lessonIdx}-${taskIdx}`]; const currentTaskComplete = isTaskComplete(currentLesson, currentTask); const currentTaskKey = `${currentLesson}-${currentTask}`; const currentAttempts = taskAttempts[currentTaskKey] || 0; // Auto-collapse sidebar on tablet useEffect(() => { if (isTablet && !sidebarCollapsed) { setSidebarCollapsed(true); } }, [isTablet]); // Lesson panel resize drag handlers const handleLessonDragStart = useCallback((e: React.MouseEvent) => { e.preventDefault(); isDraggingLessonPanel.current = true; document.body.style.cursor = "row-resize"; document.body.style.userSelect = "none"; }, []); useEffect(() => { const handleMouseMove = (e: MouseEvent) => { if (!isDraggingLessonPanel.current || !lessonPanelRef.current) return; const panelTop = lessonPanelRef.current.getBoundingClientRect().top; const containerHeight = lessonPanelRef.current.parentElement!.getBoundingClientRect().height; const newHeight = e.clientY - panelTop; const maxHeight = containerHeight * 0.5; const clamped = Math.max(80, Math.min(newHeight, maxHeight)); setLessonPanelHeight(clamped); }; const handleMouseUp = () => { if (isDraggingLessonPanel.current) { isDraggingLessonPanel.current = false; document.body.style.cursor = ""; document.body.style.userSelect = ""; } }; document.addEventListener("mousemove", handleMouseMove); document.addEventListener("mouseup", handleMouseUp); return () => { document.removeEventListener("mousemove", handleMouseMove); document.removeEventListener("mouseup", handleMouseUp); }; }, []); // Close mobile sidebar on Escape useEffect(() => { if (!mobileSidebarOpen) return; const handleEsc = (e: KeyboardEvent) => { if (e.key === "Escape") setMobileSidebarOpen(false); }; document.addEventListener("keydown", handleEsc); return () => document.removeEventListener("keydown", handleEsc); }, [mobileSidebarOpen]); // Toggle keyboard shortcuts with ? key (only when not focused on an input) useEffect(() => { const handleKey = (e: KeyboardEvent) => { const tag = (e.target as HTMLElement)?.tagName; if (tag === "INPUT" || tag === "TEXTAREA") return; if (e.key === "?" && !e.ctrlKey && !e.metaKey) { e.preventDefault(); setShortcutsOpen((prev) => !prev); } }; document.addEventListener("keydown", handleKey); return () => document.removeEventListener("keydown", handleKey); }, []); // --- LANDING PAGE --- if (showLanding) { return ( <div style={{ height: isMobile ? "100dvh" : "100vh", width: "100vw", fontFamily: fonts.sans, background: colors.bgBase, color: colors.textPrimary, overflow: "hidden", }} > <GlobalA11yStyles /> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" /> <LandingPage onGetStarted={handleGetStarted} isMobile={isMobile} themeMode={themeMode} onThemeToggle={handleThemeToggle} /> </div> ); } // --- MOBILE LAYOUT --- if (isMobile) { return ( <div style={{ height: "100dvh", width: "100vw", display: "flex", flexDirection: "column", fontFamily: fonts.sans, background: colors.bgBase, color: colors.textPrimary, overflow: "hidden", minWidth: 320, }} > <GlobalA11yStyles /> <a href="#main-content" className="skip-link">Skip to editor</a> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" /> {/* Mobile top bar */} <header style={{ height: 52, background: colors.bgPanel, borderBottom: `1px solid ${colors.borderBase}`, display: "flex", alignItems: "center", padding: "0 12px", gap: 10, flexShrink: 0, }} > <button data-tour="mobile-menu" onClick={() => setMobileSidebarOpen(true)} aria-label="Open navigation" style={{ background: "none", border: "none", color: colors.textSecondary, fontSize: 22, cursor: "pointer", padding: 8, minWidth: 44, minHeight: 44, display: "flex", alignItems: "center", justifyContent: "center", }} > ☰ </button> <div style={{ flex: 1, minWidth: 0 }}> <div style={{ fontSize: fs.body, color: colors.textPrimary, fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", }} > {activeQuizData ? activeQuizData.title : lesson.title} </div> <div style={{ fontSize: fs.xs, color: colors.textMuted }}> {activeQuizData ? activeQuizData.module : `Task ${currentTask + 1}/${lesson.tasks.length}`} </div> </div> <div style={{ position: "relative" }}> <ConnectionManager isConnected={!!connectionConfig} connectionInfo={connectionInfo} onConnect={handleConnect} onDisconnect={handleDisconnect} isExecuting={isExecuting} /> </div> <button onClick={() => setCheatSheetOpen(true)} aria-label="Open cheat sheet" style={{ background: "none", border: "none", color: colors.textSecondary, fontSize: 18, cursor: "pointer", padding: 8, minWidth: 44, minHeight: 44, display: "flex", alignItems: "center", justifyContent: "center", }} > 📋 </button> <div style={{ fontSize: fs.xs, color: activeQuizData ? colors.statusHint : isBuilder ? colors.syntaxBrace : isISE ? colors.accentSecondary : colors.accentPrimary, padding: "4px 10px", background: colors.bgOverlay, borderRadius: 4, border: `1px solid ${activeQuizData ? colors.statusHint + "44" : isBuilder ? colors.syntaxBrace + "44" : isISE ? colors.borderAccentIse : colors.borderBase}`, }} > {activeQuizData ? "Quiz" : isBuilder ? "Builder" : isISE ? "ISE" : "Console"} </div> </header> {/* Mobile sidebar overlay */} {mobileSidebarOpen && ( <> <div onClick={() => setMobileSidebarOpen(false)} style={{ position: "fixed", inset: 0, background: "rgba(0,0,0,0.6)", zIndex: 100, }} /> <div style={{ position: "fixed", top: 0, left: 0, bottom: 0, width: "80%", maxWidth: 320, zIndex: 101 }}> <Sidebar lessons={LESSONS} currentLesson={currentLesson} completedTasks={completedTasks} totalTasks={totalTasks} completedCount={completedCount} collapsed={false} onToggle={() => setMobileSidebarOpen(false)} onGoToLesson={goToLesson} onResetProgress={handleResetProgress} themeMode={themeMode} onThemeToggle={handleThemeToggle} isMobile={true} onClose={() => setMobileSidebarOpen(false)} quizzes={QUIZZES} quizResults={quizResults} onGoToQuiz={goToQuiz} activeQuiz={activeQuiz} /> </div> </> )} {/* Active panel content — use CSS display toggling instead of conditional rendering so components stay mounted and preserve state (e.g. builder stages) */} <main id="main-content" style={{ flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }}> <div style={{ flex: 1, display: mobilePanel === "lesson" ? "flex" : "none", flexDirection: "column", overflow: "hidden" }}> {activeQuizData ? ( <QuizPanel quiz={activeQuizData} existingResult={quizResults[activeQuizData.id]} onComplete={handleQuizComplete} onSkip={handleQuizSkip} isMobile={true} /> ) : ( <LessonPanel lesson={lesson} task={task} currentTask={currentTask} currentLesson={currentLesson} currentTaskComplete={currentTaskComplete} attempts={currentAttempts} revealedHintLevel={revealedHintLevel} onRevealHint={(level) => setRevealedHintLevel(level)} onAdvanceTask={advanceTask} onGoToTask={goToTask} isTaskComplete={isTaskComplete} lessonsLength={LESSONS.length} nextLabel={quizNextLabel} isMobile={true} /> )} </div> <div data-tour="editor" style={{ flex: 1, display: mobilePanel === "editor" ? "flex" : "none", flexDirection: "column", minWidth: 0, minHeight: 0 }}> {isBuilder ? ( <BuilderEditor code={code} onCodeChange={setCode} onRun={handleRun} onClear={() => setConsoleOutput([])} consoleOutput={consoleOutput} isMobile={true} builderConfig={task?.builderConfig} onShowHelp={setHelpPanelCmdlet} /> ) : ( <EditorWithBuilderToggle mode={isISE ? "ise" : "repl"} builderActive={builderToggleActive} onToggleBuilder={setBuilderToggleActive} onInsertCode={handleBuilderInsert} builderStages={builderStages} onBuilderStagesChange={setBuilderStages} builderSelectedStageId={builderSelectedStageId} onBuilderSelectedStageIdChange={setBuilderSelectedStageId} isMobile={true} onShowHelp={setHelpPanelCmdlet} editorElement={isISE ? ( <IseEditor code={code} onCodeChange={setCode} onRun={handleRun} onClear={() => setConsoleOutput([])} onReset={handleReset} consoleOutput={consoleOutput} commandHistory={commandHistory} tree={treeForPanel} variablesSnapshot={variablesSnapshot} cwd={cwd} latestError={latestError} isMobile={true} onShowHelp={setHelpPanelCmdlet} /> ) : ( <ReplEditor code={code} onCodeChange={setCode} onRun={handleRun} onClear={() => setConsoleOutput([])} consoleOutput={consoleOutput} commandHistory={commandHistory} historyIndex={historyIndex} onHistoryIndexChange={setHistoryIndex} tree={treeForPanel} isMobile={true} cwd={cwd} onShowHelp={setHelpPanelCmdlet} /> )} /> )} </div> <div style={{ flex: 1, display: mobilePanel === "tree" ? "flex" : "none", flexDirection: "column", overflow: "hidden" }}> <TreePanel tree={treeForPanel} isMobile={true} /> </div> </main> {/* Bottom tab bar */} <div data-tour="mobile-tabs"> <MobileTabBar activeTab={mobilePanel} onTabChange={setMobilePanel} showTreeTab={true} /> </div> {/* Help panel overlay */} {helpPanelCmdlet && ( <div style={{ position: "fixed", inset: 0, zIndex: 90 }}> <div onClick={() => setHelpPanelCmdlet(null)} style={{ position: "absolute", inset: 0, background: "rgba(0,0,0,0.4)" }} /> <div style={{ position: "absolute", bottom: 0, left: 0, right: 0, maxHeight: "70vh", display: "flex", flexDirection: "column", background: colors.bgPanel, borderTop: `1px solid ${colors.borderBase}`, borderRadius: "12px 12px 0 0" }}> <HelpPanel cmdletName={helpPanelCmdlet} onClose={() => setHelpPanelCmdlet(null)} onNavigate={setHelpPanelCmdlet} isMobile={true} /> </div> </div> )} {/* Cheat sheet drawer (mobile) */} <CheatSheetDrawer open={cheatSheetOpen} onClose={() => setCheatSheetOpen(false)} isMobile={true} lessonId={lesson?.id} /> {/* Virtual tour */} <VirtualTour phase={tour.phase} currentStep={tour.currentStep} isMobile={true} onAccept={tour.acceptTour} onDismiss={tour.dismissTour} onNext={() => tour.nextStep(MOBILE_STEPS.length)} onPrev={tour.prevStep} /> {/* Screen reader announcements */} <div aria-live="assertive" role="status" style={{ position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0,0,0,0)", whiteSpace: "nowrap" }} > {a11yAnnouncement} </div> </div> ); } // --- DESKTOP / TABLET LAYOUT --- return ( <div style={{ height: "100vh", width: "100vw", display: "flex", fontFamily: fonts.sans, background: colors.bgBase, color: colors.textPrimary, overflow: "hidden", }} > <GlobalA11yStyles /> <a href="#main-content" className="skip-link">Skip to editor</a> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" /> {/* SIDEBAR */} <div data-tour="sidebar"> <Sidebar lessons={LESSONS} currentLesson={currentLesson} completedTasks={completedTasks} totalTasks={totalTasks} completedCount={completedCount} collapsed={sidebarCollapsed} onToggle={() => setSidebarCollapsed(!sidebarCollapsed)} onGoToLesson={goToLesson} onResetProgress={handleResetProgress} themeMode={themeMode} onThemeToggle={handleThemeToggle} onStartTour={tour.startTour} quizzes={QUIZZES} quizResults={quizResults} onGoToQuiz={goToQuiz} activeQuiz={activeQuiz} /> </div> {/* MAIN CONTENT AREA */} <div style={{ flex: 1, display: "flex", flexDirection: "column", minWidth: 0, }} > {/* Top bar */} <header style={{ height: 48, background: colors.bgPanel, borderBottom: `1px solid ${colors.borderBase}`, display: "flex", alignItems: "center", padding: "0 20px", gap: 16, flexShrink: 0, }} > <div style={{ fontSize: fontSizes.body, color: colors.textSecondary }}> <span style={{ color: colors.accentPrimary, fontWeight: 600 }}> {activeQuizData ? activeQuizData.module : lesson.module} </span> <span style={{ margin: "0 8px", color: colors.borderDim }}>/</span> <span style={{ color: colors.textPrimary }}> {activeQuizData ? activeQuizData.title : lesson.title} </span> </div> <div style={{ flex: 1 }} /> <div style={{ position: "relative" }}> <ConnectionManager isConnected={!!connectionConfig} connectionInfo={connectionInfo} onConnect={handleConnect} onDisconnect={handleDisconnect} isExecuting={isExecuting} /> </div> {!activeQuizData && ( <> <button onClick={() => setCheatSheetOpen((v) => !v)} aria-label="Toggle cheat sheet" aria-pressed={cheatSheetOpen} title="Cheat sheet (quick reference)" style={{ background: cheatSheetOpen ? colors.bgActive : "transparent", border: `1px solid ${colors.borderMedium}`, color: colors.textSecondary, padding: "5px 12px", borderRadius: 4, cursor: "pointer", fontSize: fontSizes.base, fontFamily: "inherit", }} > 📋 Cheat sheet </button> <button onClick={() => setLayoutStacked(!layoutStacked)} aria-label={layoutStacked ? "Switch to side-by-side layout" : "Switch to stacked layout"} title={layoutStacked ? "Switch to side-by-side layout" : "Switch to stacked layout"} style={{ background: "transparent", border: `1px solid ${colors.borderMedium}`, color: colors.textSecondary, padding: "5px 12px", borderRadius: 4, cursor: "pointer", fontSize: fontSizes.base, fontFamily: "inherit", }} > {layoutStacked ? "⬌ Side-by-side" : "⬍ Stacked"} </button> <div style={{ fontSize: fontSizes.sm, color: isBuilder ? colors.syntaxBrace : isISE ? colors.accentSecondary : colors.accentPrimary, padding: "4px 10px", background: colors.bgOverlay, borderRadius: 4, border: `1px solid ${isBuilder ? colors.syntaxBrace + "44" : isISE ? colors.borderAccentIse : colors.borderBase}`, }} > {isBuilder ? "Builder" : isISE ? "ISE" : "Console"} </div> <div style={{ fontSize: fontSizes.sm, color: colors.textMuted, padding: "4px 10px", background: colors.bgOverlay, borderRadius: 4, }} > Task {currentTask + 1} of {lesson.tasks.length} </div> </> )} {activeQuizData && ( <div style={{ fontSize: fontSizes.sm, color: colors.statusHint, padding: "4px 10px", background: colors.bgOverlay, |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |