chore: finalize migration to svelte 5
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Tomáš Mládek 2025-09-27 13:32:16 +02:00
parent 90fe1be9ae
commit d19d369825
6 changed files with 23 additions and 35 deletions

View file

@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
import _ from 'lodash'; import _ from 'lodash';
import { createEventDispatcher, onMount } from 'svelte'; import { onMount } from 'svelte';
const dispatch = createEventDispatcher();
const START_COUNT = 27; const START_COUNT = 27;
const MAX_COUNT = 33; const MAX_COUNT = 33;
@ -19,9 +18,16 @@
interface Props { interface Props {
transparent?: boolean; transparent?: boolean;
subdued?: boolean; subdued?: boolean;
onchange?: (detail: {
horizontalCount: number;
verticalCount: number;
blockSize: number;
horizontalMargin: number;
verticalMargin: number;
}) => void;
} }
let { transparent = false, subdued = false }: Props = $props(); let { transparent = false, subdued = false, onchange }: Props = $props();
function updateCounts() { function updateCounts() {
const gridWidth = window.innerWidth - MARGIN_SIZE; const gridWidth = window.innerWidth - MARGIN_SIZE;
@ -56,7 +62,7 @@
horizontalMargin = (window.innerWidth - blockSize * horizontalCount) / 2; horizontalMargin = (window.innerWidth - blockSize * horizontalCount) / 2;
verticalMargin = (window.innerHeight - blockSize * verticalCount) / 2; verticalMargin = (window.innerHeight - blockSize * verticalCount) / 2;
cornerBlocks = shorterCount > 8 ? 3 : Math.max(1, Math.floor(shorterCount / 4)); cornerBlocks = shorterCount > 8 ? 3 : Math.max(1, Math.floor(shorterCount / 4));
dispatch('change', { onchange?.({
horizontalCount, horizontalCount,
verticalCount, verticalCount,
blockSize, blockSize,

View file

@ -5,14 +5,13 @@
import ColorGradient from '$lib/ColorGradient.svelte'; import ColorGradient from '$lib/ColorGradient.svelte';
import BrightnessGradient from '$lib/BrightnessGradient.svelte'; import BrightnessGradient from '$lib/BrightnessGradient.svelte';
import Clock from '$lib/Clock.svelte'; import Clock from '$lib/Clock.svelte';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher<{ focus: void }>();
interface Props { interface Props {
bg?: boolean; bg?: boolean;
onfocus?: () => void;
} }
let { bg = false }: Props = $props(); let { bg = false, onfocus }: Props = $props();
let sizes = $state({ let sizes = $state({
blockSize: 64, blockSize: 64,
@ -44,9 +43,9 @@
--column-width: {columnWidth}; --column-width: {columnWidth};
--column-height: {columnHeight}; --column-height: {columnHeight};
--left-column: {leftColumn};" --left-column: {leftColumn};"
ondblclick={() => dispatch('focus') && document.body.requestFullscreen()} ondblclick={() => onfocus?.() && document.body.requestFullscreen()}
> >
<BackgroundGrid on:change={(ev) => (sizes = ev.detail)} subdued={bg} /> <BackgroundGrid onchange={(detail) => (sizes = detail)} subdued={bg} />
<div class="axes"> <div class="axes">
<Axes /> <Axes />

View file

@ -10,7 +10,7 @@
let { children }: Props = $props(); let { children }: Props = $props();
</script> </script>
<TestCard bg on:focus={() => goto('/card')} /> <TestCard bg onfocus={() => goto('/card')} />
<main class:sub={!page.data.root}> <main class:sub={!page.data.root}>
<a href=".." class="button button-back"><i class="ti ti-arrow-back"></i>{m.common_back()}</a> <a href=".." class="button button-back"><i class="ti ti-arrow-back"></i>{m.common_back()}</a>
{@render children?.()} {@render children?.()}

View file

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy';
import { version } from '../../../package.json'; import { version } from '../../../package.json';
import type { Snapshot } from '@sveltejs/kit'; import type { Snapshot } from '@sveltejs/kit';
import { fade } from 'svelte/transition'; import { fade } from 'svelte/transition';
@ -139,7 +137,7 @@
); );
}); });
} }
run(() => { $effect(() => {
doSearch(search); doSearch(search);
}); });
@ -337,17 +335,6 @@
opacity: 0.8; opacity: 0.8;
} }
& a {
text-align: center;
text-decoration: none;
white-space: nowrap;
&.disabled {
pointer-events: none;
opacity: 0.5;
}
}
& .ti { & .ti {
display: block; display: block;
font-size: 3rem; font-size: 3rem;

View file

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy';
import { onDestroy, onMount } from 'svelte'; import { onDestroy, onMount } from 'svelte';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import debug from 'debug'; import debug from 'debug';
@ -20,10 +18,10 @@
let snapshot: string | undefined = $state(); let snapshot: string | undefined = $state();
let flipped = $state(false); let flipped = $state(false);
run(() => { $effect(() => {
dbg('devices %O', devices); dbg('devices %O', devices);
}); });
run(() => { $effect(() => {
dbg('currentDevice %s', currentDevice); dbg('currentDevice %s', currentDevice);
}); });
@ -54,7 +52,7 @@
} }
} }
run(() => { $effect(() => {
if (currentDevice) { if (currentDevice) {
navigator.mediaDevices navigator.mediaDevices
.getUserMedia({ .getUserMedia({

View file

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import debug from 'debug'; import debug from 'debug';
@ -60,20 +58,20 @@
requestAnimationFrame(update); requestAnimationFrame(update);
} }
run(() => { $effect(() => {
if (currentGamepad) { if (currentGamepad) {
update(); update();
} }
}); });
run(() => { $effect(() => {
dbg('Gamepads %O', gamepads); dbg('Gamepads %O', gamepads);
}); });
run(() => { $effect(() => {
dbg('Current gamepad %s', currentGamepad); dbg('Current gamepad %s', currentGamepad);
}); });
run(() => { $effect(() => {
currentGamepad?.vibrationActuator?.playEffect('dual-rumble', { currentGamepad?.vibrationActuator?.playEffect('dual-rumble', {
duration: 1000 duration: 1000
}); });