feat: project scaffolding - SPA shell, dark theme CSS, hash router, API client

Dieser Commit ist enthalten in:
hafroese 2026-04-02 23:01:01 +02:00
Commit 28150c2e1c
4 geänderte Dateien mit 462 neuen und 0 gelöschten Zeilen

310
edu/css/style.css Normale Datei
Datei anzeigen

@ -0,0 +1,310 @@
/* === Sol2 Training — Dark Theme === */
:root {
--bg-primary: #1a1a2e;
--bg-secondary: #16213e;
--bg-card: #1e3a5f;
--bg-input: #0f1629;
--text-primary: #e0e0e0;
--text-secondary: #888;
--text-muted: #666;
--accent: #4fc3f7;
--accent-hover: #81d4fa;
--green: #4caf50;
--orange: #ff9800;
--red: #ff5252;
--purple: #ce93d8;
--border: #2a3a5e;
--radius: 8px;
--radius-lg: 12px;
--shadow: 0 2px 8px rgba(0,0,0,0.3);
--max-width: 960px;
--nav-height: 56px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
min-height: 100vh;
}
/* === Screens === */
.screen { min-height: 100vh; }
/* === Login === */
.login-box {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
background: var(--bg-secondary);
padding: 48px;
border-radius: var(--radius-lg);
border: 1px solid var(--border);
text-align: center;
width: 100%;
max-width: 400px;
}
.login-box h1 { color: var(--accent); margin-bottom: 4px; font-size: 28px; }
.login-box .subtitle { color: var(--text-secondary); margin-bottom: 32px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; }
/* === Inputs & Buttons === */
input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
background: var(--bg-input);
border: 1px solid var(--border);
color: var(--text-primary);
padding: 12px 16px;
border-radius: var(--radius);
font-size: 14px;
outline: none;
transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }
.btn {
padding: 10px 24px;
border: none;
border-radius: var(--radius);
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--bg-primary); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-small { padding: 6px 12px; font-size: 12px; background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-small:hover { border-color: var(--accent); color: var(--accent); }
.btn-green { background: var(--green); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-muted { background: var(--text-muted); color: #fff; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; }
/* === Top Navigation === */
.top-nav {
display: flex;
align-items: center;
background: var(--bg-secondary);
padding: 0 24px;
height: var(--nav-height);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 100;
}
.nav-brand { color: var(--accent); font-weight: 700; font-size: 18px; margin-right: 32px; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
color: var(--text-secondary);
text-decoration: none;
padding: 8px 16px;
border-radius: var(--radius);
font-size: 14px;
transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--accent); background: rgba(79,195,247,0.1); }
.nav-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-user span { color: var(--text-secondary); font-size: 13px; }
/* === Content Area === */
.content-area {
max-width: var(--max-width);
margin: 0 auto;
padding: 32px 24px;
}
/* === Module Tiles (Dashboard) === */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.module-tile {
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 24px;
text-align: center;
cursor: pointer;
transition: border-color 0.2s, transform 0.2s;
}
.module-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-tile .tile-icon { font-size: 36px; margin-bottom: 12px; }
.module-tile .tile-title { color: var(--accent); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.module-tile .tile-info { color: var(--text-secondary); font-size: 12px; margin-bottom: 12px; }
/* === Progress Bar === */
.progress-bar { background: #333; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-bar .fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.progress-bar .fill-green { background: var(--green); }
.progress-bar .fill-accent { background: var(--accent); }
.progress-segmented { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 1px; }
.progress-segmented .seg-correct { background: var(--green); }
.progress-segmented .seg-wrong { background: var(--red); }
.progress-segmented .seg-open { background: #333; }
/* === Cards / Deck List === */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.deck-card {
background: var(--bg-card);
border-radius: var(--radius-lg);
padding: 20px;
cursor: pointer;
transition: transform 0.2s;
border: 1px solid transparent;
}
.deck-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.deck-card .deck-name { color: var(--accent); font-size: 15px; font-weight: 600; }
.deck-card .deck-info { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.deck-card .deck-due { color: var(--orange); font-size: 12px; margin-top: 8px; }
/* === Flashcard Study === */
.study-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.study-deck-name { color: var(--accent); font-size: 14px; }
.study-counter { color: var(--text-muted); font-size: 13px; }
.study-stats { display: flex; gap: 16px; font-size: 13px; }
.stat-correct { color: var(--green); }
.stat-wrong { color: var(--red); }
.stat-open { color: var(--text-muted); }
.flashcard {
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 24px;
min-height: 200px;
}
.flashcard .card-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.flashcard .card-level {
background: var(--bg-input);
color: var(--accent);
padding: 3px 10px;
border-radius: 4px;
font-size: 11px;
text-transform: uppercase;
}
.flashcard .card-last-review { color: var(--text-muted); font-size: 11px; }
.flashcard .card-question { color: #fff; font-size: 18px; line-height: 1.6; margin-bottom: 16px; }
.flashcard .card-answer {
border-top: 1px solid var(--border);
padding-top: 16px;
color: var(--text-primary);
font-size: 14px;
line-height: 1.7;
}
.flashcard .card-answer-label { color: var(--green); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.card-answer-hidden { text-align: center; padding: 24px 0; }
.rating-buttons { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
.rating-buttons .btn { min-width: 80px; }
/* === Code blocks === */
code {
background: var(--bg-input);
padding: 2px 6px;
border-radius: 4px;
color: var(--accent);
font-family: 'Consolas', 'Fira Code', monospace;
font-size: 0.9em;
}
pre { background: var(--bg-input); padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 12px 0; }
pre code { background: none; padding: 0; }
/* === Tutorial === */
.tutorial-list { display: flex; flex-direction: column; gap: 12px; }
.tutorial-item {
display: flex; align-items: center; gap: 16px;
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px 20px;
cursor: pointer;
transition: border-color 0.2s;
}
.tutorial-item:hover { border-color: var(--accent); }
.tutorial-item .tut-number { color: var(--accent); font-size: 24px; font-weight: 700; min-width: 40px; }
.tutorial-item .tut-title { color: #fff; font-size: 15px; }
.tutorial-item .tut-info { color: var(--text-secondary); font-size: 12px; }
.tutorial-item .tut-check { color: var(--green); font-size: 20px; margin-left: auto; }
.tutorial-content { background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 32px; border: 1px solid var(--border); line-height: 1.8; }
.tutorial-content h1, .tutorial-content h2, .tutorial-content h3 { color: var(--accent); margin: 24px 0 12px; }
.tutorial-content h1 { font-size: 24px; }
.tutorial-content h2 { font-size: 20px; }
.tutorial-content h3 { font-size: 16px; }
.tutorial-content p { margin-bottom: 12px; }
.tutorial-content table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.tutorial-content th, .tutorial-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.tutorial-content th { background: var(--bg-input); color: var(--accent); }
/* === Quiz === */
.quiz-option {
display: block;
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 14px 20px;
margin-bottom: 8px;
cursor: pointer;
transition: border-color 0.2s;
width: 100%;
text-align: left;
color: var(--text-primary);
font-size: 14px;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.selected { border-color: var(--accent); background: rgba(79,195,247,0.1); }
.quiz-option.correct { border-color: var(--green); background: rgba(76,175,80,0.1); }
.quiz-option.wrong { border-color: var(--red); background: rgba(255,82,82,0.1); }
/* === Cheat Sheets === */
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.sheet-card {
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
cursor: pointer;
transition: border-color 0.2s;
}
.sheet-card:hover { border-color: var(--accent); }
.sheet-card .sheet-title { color: var(--accent); font-weight: 600; }
.sheet-card .sheet-cat { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.sheet-content { background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 32px; border: 1px solid var(--border); line-height: 1.8; }
/* === Admin === */
.admin-section { margin-bottom: 32px; }
.admin-section h2 { color: var(--accent); margin-bottom: 16px; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; }
.user-table th { background: var(--bg-input); color: var(--accent); font-size: 13px; }
/* === Page Headers === */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; color: #fff; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
/* === Misc === */
.search-bar { margin-bottom: 20px; }
.search-bar input { width: 100%; max-width: 400px; }
.back-link { display: inline-block; color: var(--text-secondary); text-decoration: none; font-size: 13px; margin-bottom: 16px; }
.back-link:hover { color: var(--accent); }
.empty-state { text-align: center; padding: 48px 0; color: var(--text-secondary); }
.loading { text-align: center; padding: 48px 0; color: var(--text-muted); }
/* === Responsive === */
@media (max-width: 768px) {
.top-nav { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
.nav-brand { font-size: 16px; margin-right: 0; }
.nav-links { order: 3; width: 100%; overflow-x: auto; gap: 0; padding-bottom: 4px; }
.nav-link { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.nav-user { margin-left: auto; }
.content-area { padding: 20px 16px; }
.module-grid { grid-template-columns: 1fr 1fr; }
.deck-grid { grid-template-columns: 1fr; }
.flashcard .card-question { font-size: 16px; }
.rating-buttons { flex-wrap: wrap; }
.login-box { padding: 32px 24px; margin: 0 16px; }
}
@media (max-width: 480px) {
.module-grid { grid-template-columns: 1fr; }
}

55
edu/index.html Normale Datei
Datei anzeigen

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sol2 Training</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<!-- Login screen -->
<div id="login-screen" class="screen" style="display:none;">
<div class="login-box">
<h1>Sol2 Training</h1>
<p class="subtitle">Solution2 / Omnis Studio</p>
<form id="login-form">
<input type="text" id="login-user" placeholder="Benutzername" required autocomplete="username">
<input type="password" id="login-pass" placeholder="Passwort" required autocomplete="current-password">
<button type="submit" class="btn btn-primary">Anmelden</button>
<div id="login-error" class="error-msg" style="display:none;"></div>
</form>
</div>
</div>
<!-- App -->
<div id="app" class="screen" style="display:none;">
<nav class="top-nav">
<div class="nav-brand">Sol2 Training</div>
<div class="nav-links">
<a href="#/dashboard" class="nav-link" data-route="dashboard">Dashboard</a>
<a href="#/flashcards" class="nav-link" data-route="flashcards">Flashcards</a>
<a href="#/tutorials" class="nav-link" data-route="tutorials">Tutorials</a>
<a href="#/quiz" class="nav-link" data-route="quiz">Quiz</a>
<a href="#/cheatsheets" class="nav-link" data-route="cheatsheets">Cheat Sheets</a>
<a href="#/admin" class="nav-link nav-admin" data-route="admin" style="display:none;">Admin</a>
</div>
<div class="nav-user">
<span id="nav-username"></span>
<button id="logout-btn" class="btn btn-small">Abmelden</button>
</div>
</nav>
<main id="content" class="content-area"></main>
</div>
<script src="/js/api.js"></script>
<script src="/js/markdown.js"></script>
<script src="/js/auth.js"></script>
<script src="/js/dashboard.js"></script>
<script src="/js/flashcards.js"></script>
<script src="/js/tutorials.js"></script>
<script src="/js/quiz.js"></script>
<script src="/js/cheatsheets.js"></script>
<script src="/js/admin.js"></script>
<script src="/js/app.js"></script>
</body>
</html>

24
edu/js/api.js Normale Datei
Datei anzeigen

@ -0,0 +1,24 @@
'use strict';
var API = {
base: '/api',
request: function(method, path, body) {
var opts = {
method: method,
headers: { 'Content-Type': 'application/json' },
credentials: 'same-origin'
};
if (body) opts.body = JSON.stringify(body);
return fetch(this.base + path, opts).then(function(resp) {
return resp.json().then(function(data) {
if (!resp.ok) throw { status: resp.status, message: data.error || 'Fehler' };
return data;
});
});
},
get: function(path) { return this.request('GET', path); },
post: function(path, body) { return this.request('POST', path, body); },
del: function(path) { return this.request('DELETE', path); }
};

73
edu/js/app.js Normale Datei
Datei anzeigen

@ -0,0 +1,73 @@
'use strict';
var App = {
currentUser: null,
routes: {
dashboard: null, // set after all scripts load
flashcards: null,
tutorials: null,
quiz: null,
cheatsheets: null,
admin: null
},
init: function() {
this.routes.dashboard = Dashboard;
this.routes.flashcards = Flashcards;
this.routes.tutorials = Tutorials;
this.routes.quiz = Quiz;
this.routes.cheatsheets = CheatSheets;
this.routes.admin = Admin;
document.getElementById('login-form').addEventListener('submit', function(e) { Auth.handleLogin(e); });
document.getElementById('logout-btn').addEventListener('click', function() { Auth.handleLogout(); });
window.addEventListener('hashchange', function() { App.route(); });
this.checkAuth();
},
checkAuth: function() {
API.get('/me').then(function(data) {
App.setUser(data.user);
}).catch(function() {
App.showLogin();
});
},
setUser: function(user) {
this.currentUser = user;
document.getElementById('nav-username').textContent = user.display_name;
document.getElementById('login-screen').style.display = 'none';
document.getElementById('app').style.display = 'block';
if (user.is_admin) {
document.querySelector('.nav-admin').style.display = '';
}
this.route();
},
showLogin: function() {
this.currentUser = null;
document.getElementById('login-screen').style.display = 'flex';
document.getElementById('app').style.display = 'none';
},
route: function() {
var hash = location.hash.slice(2) || 'dashboard';
var parts = hash.split('/');
var routeName = parts[0];
var params = parts.slice(1);
document.querySelectorAll('.nav-link').forEach(function(link) {
link.classList.toggle('active', link.dataset.route === routeName);
});
var handler = this.routes[routeName];
if (handler && handler.render) {
handler.render(params);
} else {
document.getElementById('content').textContent = 'Seite nicht gefunden';
}
}
};
document.addEventListener('DOMContentLoaded', function() { App.init(); });