Add user database migration, core reusable components, and layout structure

This commit is contained in:
2026-05-16 18:54:23 -04:00
parent c7df396a83
commit e132c7a580
33 changed files with 2348 additions and 398 deletions
+33
View File
@@ -0,0 +1,33 @@
class Router {
#routes = [];
on(pattern, handler) {
const regex = new RegExp(
'^' + pattern.replace(/:([^/]+)/g, '(?<$1>[^/]+)') + '$'
);
this.#routes.push({ regex, handler });
return this;
}
navigate(path) {
location.hash = '#' + path;
}
start() {
const dispatch = () => {
const path = decodeURIComponent(location.hash.slice(1)) || '/';
for (const { regex, handler } of this.#routes) {
const m = path.match(regex);
if (m) { handler(m.groups || {}); return; }
}
};
window.addEventListener('hashchange', dispatch);
dispatch();
}
get current() {
return decodeURIComponent(location.hash.slice(1)) || '/';
}
}
export const router = new Router();