Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>☕</text></svg>" />
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 32 32%22><rect width=%2232%22 height=%2232%22 rx=%226%22 fill=%22%23BA0C2F%22/></svg>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FRC 2713 Software Training</title>
</head>
Expand Down
40 changes: 40 additions & 0 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"dependencies": {
"@codemirror/lang-python": "^6.2.1",
"@codemirror/theme-one-dark": "^6.1.3",
"@fontsource/barlow": "^5.3.0",
"@fontsource/barlow-condensed": "^5.3.0",
"@fontsource/open-sans": "^5.3.0",
"@fontsource/roboto-mono": "^5.3.0",
"@radix-ui/react-dialog": "^1.1.18",
"@radix-ui/react-separator": "^1.1.11",
"@radix-ui/react-slot": "^1.3.0",
Expand Down
22 changes: 22 additions & 0 deletions site/public/brand/2713-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions site/public/brand/2713-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 75 additions & 10 deletions site/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,86 @@
import { HashRouter, Route, Routes } from 'react-router-dom'
import { HashRouter, Link, Route, Routes, useLocation } from 'react-router-dom'
import { ChevronRight } from 'lucide-react'
import { AppSidebar } from './components/AppSidebar'
import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'
import { getLesson, lessonNumber } from '@/lib/lessons'
import { ProgressProvider, useProgress } from '@/lib/progress'
import { LessonIndex } from './routes/LessonIndex'
import { LessonView } from './routes/LessonView'

function HeaderBreadcrumb() {
const { pathname } = useLocation()
const match = /^\/lesson\/([^/]+)(?:\/(\d+))?/.exec(pathname)

if (!match) {
return (
<span className="brand-subheading text-sm text-muted-foreground">All lessons</span>
)
}

const slug = match[1]
const lesson = getLesson(slug)
if (!lesson) {
return (
<span className="brand-subheading text-sm text-muted-foreground">All lessons</span>
)
}

const num = lessonNumber(slug)
const pageCount = lesson.pages.length
const requested = match[2] ? Number(match[2]) : 1
const currentPage = Number.isFinite(requested)
? Math.min(Math.max(requested, 1), pageCount)
: 1

return (
<nav aria-label="Breadcrumb" className="flex min-w-0 items-center gap-1.5 text-sm">
<Link
to="/"
className="shrink-0 text-[var(--link)] no-underline hover:underline"
>
All lessons
</Link>
<ChevronRight className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
<span className="brand-figures shrink-0 text-xs font-semibold text-[var(--emphasis)]">
{num}
</span>
<span className="brand-subheading truncate text-foreground" title={lesson.title}>
{lesson.title}
</span>
{pageCount > 1 && (
<span className="brand-figures ml-1 hidden shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground sm:inline-block">
Page {currentPage} / {pageCount}
</span>
)}
</nav>
)
}

function HeaderProgress() {
const { user, completedCount, totalLessons, loading } = useProgress()
if (loading || !user) return null
const pct = totalLessons > 0 ? Math.round((completedCount / totalLessons) * 100) : 0

return (
<div className="ml-auto flex items-center gap-3 text-xs text-muted-foreground">
<span className="tabular-nums font-medium text-foreground">
{completedCount} / {totalLessons} completed
<div className="ml-auto flex shrink-0 items-center gap-3 text-xs text-muted-foreground">
<div className="flex items-center gap-2">
<div
className="hidden h-1.5 w-16 overflow-hidden rounded-full bg-muted sm:block"
aria-hidden="true"
>
<div
className="h-full rounded-full bg-primary transition-[width] duration-300"
style={{ width: `${pct}%` }}
/>
</div>
<span className="brand-figures font-medium text-foreground">
{completedCount} / {totalLessons}
</span>
</div>
<span className="hidden sm:inline text-border" aria-hidden="true">
·
</span>
<span className="hidden sm:inline text-border">·</span>
<span className="hidden sm:inline truncate max-w-[180px]" title={user.name}>
<span className="hidden sm:inline truncate max-w-[160px]" title={user.name}>
{user.name}
</span>
</div>
Expand All @@ -28,11 +94,10 @@ function App() {
<SidebarProvider>
<AppSidebar />
<SidebarInset>
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background/80 px-4 backdrop-blur">
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2.5 border-b bg-background/90 px-4 backdrop-blur">
<SidebarTrigger />
<span className="text-sm font-medium text-muted-foreground">
FRC 2713 Software Training
</span>
<div className="h-4 w-px bg-border" aria-hidden="true" />
<HeaderBreadcrumb />
<HeaderProgress />
</header>
<Routes>
Expand Down
60 changes: 46 additions & 14 deletions site/src/components/AppSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Check } from 'lucide-react'
import { BookOpen, Check } from 'lucide-react'
import { NavLink, useLocation } from 'react-router-dom'
import {
Sidebar,
Expand All @@ -18,19 +18,46 @@ import { useProgress } from '@/lib/progress'
export function AppSidebar() {
const { pathname } = useLocation()
const { isCompleted, user } = useProgress()
const baseUrl = import.meta.env.BASE_URL

return (
<Sidebar>
<SidebarHeader className="px-3 py-3 text-base font-semibold text-foreground">
FRC 2713 Training
<SidebarHeader className="flex h-14 justify-center border-b border-sidebar-border p-0">
<NavLink
to="/"
className="flex h-full items-center gap-1 pr-3 no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sidebar-ring"
>
<span className="brand-mark">
<picture>
<source
srcSet={`${baseUrl}brand/2713-white.svg`}
media="(prefers-color-scheme: dark)"
/>
<img
src={`${baseUrl}brand/2713-red.svg`}
alt="Red Hawk Robotics 2713"
/>
</picture>
</span>
<span className="brand-subheading whitespace-nowrap text-sm tracking-tight text-[var(--ink)]">
Software Training
</span>
</NavLink>
</SidebarHeader>
<SidebarContent>
<SidebarGroup>
<SidebarContent className="pb-6">
<SidebarGroup className="pb-1">
<SidebarGroupContent>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton asChild isActive={pathname === '/'}>
<NavLink to="/">All lessons</NavLink>
<SidebarMenuButton
asChild
isActive={pathname === '/'}
className="data-[active=true]:bg-sidebar-accent data-[active=true]:font-semibold data-[active=true]:text-sidebar-accent-foreground data-[active=true]:shadow-[inset_3px_0_0_var(--hawk-red)]"
>
<NavLink to="/">
<BookOpen className="size-4 shrink-0 text-muted-foreground" />
<span>All lessons</span>
</NavLink>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
Expand All @@ -39,11 +66,11 @@ export function AppSidebar() {
{lessonSections.map((section) => {
const doneInSection = section.lessons.filter((l) => isCompleted(l.slug)).length
return (
<SidebarGroup key={section.title}>
<SidebarGroupLabel className="justify-between">
<SidebarGroup key={section.title} className="pt-2 pb-1">
<SidebarGroupLabel className="brand-subheading justify-between text-[11px] uppercase tracking-wider text-muted-foreground">
<span>{section.title}</span>
{user && (
<span className="tabular-nums text-[11px] font-normal text-muted-foreground">
<span className="brand-figures text-[11px] font-normal text-muted-foreground">
{doneInSection}/{section.lessons.length}
</span>
)}
Expand All @@ -54,12 +81,17 @@ export function AppSidebar() {
const to = `/lesson/${lesson.slug}`
const active = pathname === to || pathname.startsWith(`${to}/`)
const done = isCompleted(lesson.slug)
const num = lessons.indexOf(lesson) + 1
return (
<SidebarMenuItem key={lesson.slug}>
<SidebarMenuButton asChild isActive={active}>
<NavLink to={to}>
<span className="w-5 shrink-0 text-right font-medium tabular-nums text-primary">
{lessons.indexOf(lesson) + 1}
<SidebarMenuButton
asChild
isActive={active}
className="data-[active=true]:bg-sidebar-accent data-[active=true]:font-semibold data-[active=true]:text-sidebar-accent-foreground data-[active=true]:shadow-[inset_3px_0_0_var(--hawk-red)]"
>
<NavLink to={to} title={`${num}. ${lesson.title}`}>
<span className="brand-figures w-5 shrink-0 text-right text-xs font-semibold text-[var(--emphasis)]">
{num}
</span>
<span className="truncate flex-1">{lesson.title}</span>
{done && (
Expand Down
Loading
Loading