Fixes and responsive character sheet.

This commit is contained in:
2026-06-16 11:14:46 +02:00
parent bc1839c5e3
commit a5317d6156
5 changed files with 293 additions and 138 deletions

24
shared/breakpoint.ts Normal file
View File

@@ -0,0 +1,24 @@
import { reactive } from '#shared/reactive';
export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
const breakpoints = [
{ name: 'sm', query: '(min-width: 640px)' },
{ name: 'md', query: '(min-width: 768px)' },
{ name: 'lg', query: '(min-width: 1024px)' },
{ name: 'xl', query: '(min-width: 1280px)' },
{ name: '2xl', query: '(min-width: 1536px)' },
];
export const breakpoint = reactive({ current: 'lg' as Breakpoint });
if (typeof window !== 'undefined') {
const updateBreakpoint = () => {
for (let i = breakpoints.length - 1; i >= 0; i--)
if (window.matchMedia(breakpoints[i]!.query).matches)
{ breakpoint.current = breakpoints[i]!.name as Breakpoint; break; }
};
updateBreakpoint();
breakpoints.forEach(b => window.matchMedia(b.query).addEventListener('change', updateBreakpoint));
}