Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit a3c6b27

Browse files
Web: Lernbereich zur schmalen Leiste einklappen (#69)
Einklapp-Knopf mit Seitenleisten-Symbol oben im Lernbereich; eingeklappt bleibt am Rand die Leiste „🎓 Lernen“ zum Wiederöffnen. ?learn wird nach dem Laden aus der Adresse genommen, damit Neuladen die Wahl respektiert. Claude-Session: https://claude.ai/code/session_01DBp3WTokQmZjowfLKr5dtG Co-authored-by: Claude <noreply@anthropic.com>
1 parent c2407bc commit a3c6b27

12 files changed

Lines changed: 681 additions & 584 deletions

File tree

‎web/src/i18n/de.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
/* Lernbereich (Lektionen gibt es vorerst nur auf Deutsch) */
4747
"web_learn_title" = "Lernen";
4848
"web_learn_toggle_title" = "Lektionen, Aufgaben und Nachschlagen ein- oder ausblenden";
49+
"web_learn_hide" = "Lernbereich einklappen";
50+
"web_learn_show" = "Lernbereich aufklappen: Lektionen, Aufgaben und Nachschlagen";
4951
"web_learn_lessons" = "Lektionen";
5052
"web_learn_tasks" = "Aufgaben";
5153
"web_learn_reference" = "Nachschlagen";

‎web/src/i18n/en.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
/* Learning area (lessons are German only for now) */
4747
"web_learn_title" = "Learn";
4848
"web_learn_toggle_title" = "Show or hide lessons, exercises and reference";
49+
"web_learn_hide" = "Collapse the learning area";
50+
"web_learn_show" = "Expand the learning area: lessons, exercises and reference";
4951
"web_learn_lessons" = "Lessons";
5052
"web_learn_tasks" = "Exercises";
5153
"web_learn_reference" = "Reference";

‎web/src/i18n/pt-PT.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
"web_run_dropped_fmt" = "… %d linhas anteriores ocultas";
4545
"web_learn_title" = "Aprender";
4646
"web_learn_toggle_title" = "Mostrar ou ocultar lições, exercícios e consulta";
47+
"web_learn_hide" = "Recolher a área de aprendizagem";
48+
"web_learn_show" = "Expandir a área de aprendizagem: lições, exercícios e consulta";
4749
"web_learn_lessons" = "Lições";
4850
"web_learn_tasks" = "Exercícios";
4951
"web_learn_reference" = "Consulta";

‎web/src/ui/app.ts‎

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { createCanvasMeasure } from '../core/textMeasurement'
2929
import { decodeDocument, encodeDocument } from '../core/xmlCodec'
3030
import { DiagramRenderer, displayElement, el, flattenNodes, samePath } from './renderer'
3131
import { CodePanel } from './codePanel'
32-
import { LearnPanel, type LearnHost } from './learnPanel'
32+
import { LearnPanel, sidebarIcon, type LearnHost } from './learnPanel'
3333
import type { Exercise } from '../learn/lessonFormat'
3434
import { progress } from '../learn/progress'
3535
import { currentLanguage, offeredLanguages, setLanguage, t, type LanguageCode } from './i18n'
@@ -220,6 +220,7 @@ export class App {
220220
private shell: HTMLElement
221221
private learning = false
222222
private learnButton?: HTMLButtonElement
223+
private railButton?: HTMLButtonElement
223224
private exerciseSaveTimer?: number
224225
private resizeObserver?: ResizeObserver
225226
private renderedHostSize = { width: -1, height: -1 }
@@ -259,11 +260,18 @@ export class App {
259260
this.shell = document.createElement('div')
260261
this.shell.className = 'shell'
261262
root.replaceWith(this.shell)
262-
this.shell.append(this.learn.element, this.learnResizer(), root)
263+
this.shell.append(this.learnRail(), this.learn.element, this.learnResizer(), root)
263264
const learnOpen = storedValue(learnKey)
264-
// Link „Zu den Lektionen“ der Webseite: …/app/?learn
265-
const fromSite = new URLSearchParams(location.search).has('learn')
266-
this.setLearning(fromSite || (learnOpen === null ? window.innerWidth > 1100 : learnOpen === '1'), false)
265+
// Link „Zu den Lektionen“ der Webseite: …/app/?learn. Danach aus der Adresse nehmen,
266+
// sonst öffnet jedes Neuladen den Lernbereich wieder, obwohl man ihn eingeklappt hat.
267+
const params = new URLSearchParams(location.search)
268+
const fromSite = params.has('learn')
269+
if (fromSite) {
270+
params.delete('learn')
271+
const query = params.toString()
272+
history.replaceState(history.state, '', `${location.pathname}${query ? `?${query}` : ''}${location.hash}`)
273+
}
274+
this.setLearning(fromSite || (learnOpen === null ? window.innerWidth > 1100 : learnOpen === '1'), fromSite)
267275
const z = Number(storedValue(zoomKey))
268276
if (zoomSteps.some((s) => s.value === z)) this.zoom = z
269277
this.buildUI()
@@ -461,6 +469,7 @@ export class App {
461469
this.buildUI()
462470
this.render()
463471
this.learn.render()
472+
this.labelLearnRail()
464473
}
465474

466475
// MARK: - Lernbereich
@@ -473,8 +482,23 @@ export class App {
473482
if (this.canvasHost) this.renderDiagramOnly()
474483
}
475484

485+
/** Schmale Leiste am Rand, solange der Lernbereich eingeklappt ist. */
486+
private learnRail(): HTMLElement {
487+
this.railButton = h('button', { class: 'learn-rail' }) as HTMLButtonElement
488+
this.labelLearnRail()
489+
this.railButton.addEventListener('click', () => this.setLearning(true))
490+
return this.railButton
491+
}
492+
493+
private labelLearnRail() {
494+
if (!this.railButton) return
495+
this.railButton.title = t('web_learn_show')
496+
this.railButton.innerHTML = `${sidebarIcon}<span>🎓 ${e(t('web_learn_title'))}</span>`
497+
}
498+
476499
private learnHost(): LearnHost {
477500
return {
501+
collapse: () => this.setLearning(false),
478502
openExercise: (ex: Exercise, doc: VSDocument) => {
479503
const existing = this.tabs.findIndex((tab) => tab.exerciseId === ex.id)
480504
if (existing >= 0) {

‎web/src/ui/learnPanel.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ export interface LearnHost {
3232
/** Reiter einer Übung auf den Startzustand setzen (falls offen). */
3333
resetExercise(id: string, doc: VSDocument): void
3434
preview(doc: VSDocument): SVGSVGElement | undefined
35+
/** Lernbereich zur schmalen Leiste einklappen. */
36+
collapse(): void
3537
}
3638

39+
/** Seitenleisten-Symbol wie in Finder, Mail und Safari (kein ✕: Einklappen ist kein Schließen). */
40+
export const sidebarIcon =
41+
'<svg viewBox="0 0 20 16" width="18" height="15" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="1" width="18" height="14" rx="3"/><path d="M7.5 1v14"/><path d="M3.5 4.5h2M3.5 7h2M3.5 9.5h2" stroke-linecap="round"/></svg>'
42+
3743
type TabName = 'lessons' | 'tasks' | 'reference'
3844

3945
const sections = (): { name: string; lessons: Lesson[] }[] => {
@@ -119,8 +125,11 @@ export class LearnPanel {
119125
})
120126
tabs.append(b)
121127
}
128+
const hide = html('button', { class: 'learn-hide', title: t('web_learn_hide'), 'aria-label': t('web_learn_hide') }, sidebarIcon)
129+
hide.addEventListener('click', () => this.host.collapse())
130+
const head = h('div', { class: 'learn-head' }, tabs, hide)
122131
this.body = h('div', { class: 'learn-body' })
123-
this.element.replaceChildren(tabs, this.body)
132+
this.element.replaceChildren(head, this.body)
124133
if (this.tab === 'lessons') {
125134
const lesson = lessons.find((l) => l.id === this.lessonId)
126135
if (lesson) this.renderLesson(lesson)

‎web/src/ui/styles.css‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,50 @@ button.danger-text:not(:disabled) {
789789
cursor: col-resize;
790790
user-select: none;
791791
}
792-
.learn-tabs {
792+
/* Kopfzeile: Reiter und Einklapp-Knopf (Seitenleisten-Symbol wie auf dem Mac). */
793+
.learn-head {
794+
display: flex;
795+
align-items: flex-start;
796+
gap: 6px;
793797
margin: 10px 12px 0;
794798
}
799+
.learn-tabs {
800+
flex: 1;
801+
min-width: 0;
802+
}
803+
.learn-hide {
804+
flex: none;
805+
min-height: 30px;
806+
padding: 4px 7px;
807+
display: inline-flex;
808+
align-items: center;
809+
color: var(--muted);
810+
}
811+
/* Eingeklappt: schmale Leiste am Rand, ein Tipp klappt den Lernbereich wieder auf. */
812+
.learn-rail {
813+
flex: none;
814+
display: flex;
815+
flex-direction: column;
816+
align-items: center;
817+
gap: 10px;
818+
width: 36px;
819+
padding: 10px 0;
820+
border: none;
821+
border-radius: 0;
822+
border-inline-end: 1px solid var(--border);
823+
background: var(--panel);
824+
cursor: pointer;
825+
}
826+
.learn-rail:hover {
827+
background: var(--accent-soft);
828+
}
829+
.learn-rail span {
830+
writing-mode: vertical-rl;
831+
white-space: nowrap;
832+
}
833+
.shell.learning .learn-rail {
834+
display: none;
835+
}
795836
.learn-body {
796837
overflow-y: auto;
797838
/* Sonst: Scrollbalken erscheint → Vorschaubilder schmaler und kürzer → Scrollbalken verschwindet → … */
@@ -1194,6 +1235,17 @@ button[data-action='learn'][aria-pressed='true'] {
11941235
.shell .learn {
11951236
width: auto !important;
11961237
}
1238+
.learn-rail {
1239+
flex-direction: row;
1240+
justify-content: center;
1241+
width: auto;
1242+
padding: 4px 0;
1243+
border-inline-end: none;
1244+
border-bottom: 1px solid var(--border);
1245+
}
1246+
.learn-rail span {
1247+
writing-mode: horizontal-tb;
1248+
}
11971249
.shell {
11981250
flex-direction: column;
11991251
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const e=`/* Texte, die es nur in der Web-Version gibt. Alle anderen kommen aus d
4646
/* Lernbereich (Lektionen gibt es vorerst nur auf Deutsch) */
4747
"web_learn_title" = "Lernen";
4848
"web_learn_toggle_title" = "Lektionen, Aufgaben und Nachschlagen ein- oder ausblenden";
49+
"web_learn_hide" = "Lernbereich einklappen";
50+
"web_learn_show" = "Lernbereich aufklappen: Lektionen, Aufgaben und Nachschlagen";
4951
"web_learn_lessons" = "Lektionen";
5052
"web_learn_tasks" = "Aufgaben";
5153
"web_learn_reference" = "Nachschlagen";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const e=`/* Texts that exist only in the web version. Everything else comes from
4646
/* Learning area (lessons are German only for now) */
4747
"web_learn_title" = "Learn";
4848
"web_learn_toggle_title" = "Show or hide lessons, exercises and reference";
49+
"web_learn_hide" = "Collapse the learning area";
50+
"web_learn_show" = "Expand the learning area: lessons, exercises and reference";
4951
"web_learn_lessons" = "Lessons";
5052
"web_learn_tasks" = "Exercises";
5153
"web_learn_reference" = "Reference";
Lines changed: 574 additions & 574 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)