Add the V2 web app: design system, shell, study flows, AI, settings, sharing

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-11 08:53:01 -07:00
parent eae109c166
commit 74a98ac1f1
52 changed files with 11976 additions and 1 deletions

BIN
web/public/icon-180.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
web/public/icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
web/public/icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

8
web/public/icon.svg Normal file
View file

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect width="64" height="64" rx="14" fill="#1B1A17"/>
<rect x="14" y="17" width="30" height="36" rx="4" fill="#FBFAF7" transform="rotate(-7 29 35)"/>
<rect x="21" y="13" width="30" height="36" rx="4" fill="#FFE36E"/>
<rect x="27" y="23" width="18" height="3.4" rx="1.7" fill="#1B1A17"/>
<rect x="27" y="30.5" width="13" height="3.4" rx="1.7" fill="#1B1A17" opacity=".55"/>
<rect x="27" y="38" width="15.5" height="3.4" rx="1.7" fill="#1B1A17" opacity=".55"/>
</svg>

After

Width:  |  Height:  |  Size: 539 B

View file

@ -0,0 +1,15 @@
{
"name": "Study Desk",
"short_name": "Study Desk",
"description": "Quizzes, spaced-repetition flashcards and study materials.",
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#FBFAF7",
"theme_color": "#1B1A17",
"icons": [
{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" },
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any maskable" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
]
}

2
web/public/robots.txt Normal file
View file

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

50
web/public/sw.js Normal file
View file

@ -0,0 +1,50 @@
/* Study Desk service worker: makes the app installable and keeps the shell available offline.
* API calls are never cached, so study data is always live. */
const CACHE = 'studydesk-shell-v1';
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(CACHE).then((c) => c.addAll(['/', '/icon.svg', '/manifest.webmanifest'])).then(() => self.skipWaiting()));
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches
.keys()
.then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
.then(() => self.clients.claim()),
);
});
self.addEventListener('fetch', (event) => {
const req = event.request;
if (req.method !== 'GET') return;
const url = new URL(req.url);
if (url.origin !== self.location.origin || url.pathname.startsWith('/api/') || url.pathname.startsWith('/media/')) return;
// Hashed build assets never change: serve from cache, fill on first use.
if (url.pathname.startsWith('/assets/')) {
event.respondWith(
caches.match(req).then(
(hit) =>
hit ||
fetch(req).then((res) => {
if (res.ok) caches.open(CACHE).then((c) => c.put(req, res.clone()));
return res.clone();
}),
),
);
return;
}
// Pages: always try the network so updates arrive, fall back to the cached shell offline.
if (req.mode === 'navigate') {
event.respondWith(
fetch(req)
.then((res) => {
if (res.ok) caches.open(CACHE).then((c) => c.put('/', res.clone()));
return res.clone();
})
.catch(() => caches.match('/').then((hit) => hit || new Response('Study Desk is offline.', { status: 503, headers: { 'Content-Type': 'text/plain' } }))),
);
}
});

10
web/public/theme.js Normal file
View file

@ -0,0 +1,10 @@
// Applies the saved theme before first paint (kept as a file so the CSP can stay script-src 'self').
(function () {
try {
var saved = localStorage.getItem('sd.theme') || 'system';
var dark = saved === 'dark' || (saved === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
document.documentElement.dataset.theme = dark ? 'dark' : 'light';
} catch (e) {
document.documentElement.dataset.theme = 'light';
}
})();