Add change view button

This commit is contained in:
2025-03-07 14:21:58 +01:00
parent d7da674267
commit 02526f340a
3 changed files with 43 additions and 8 deletions

View File

@@ -66,7 +66,8 @@
</script> </script>
<svelte:window onresize={resize} /> <svelte:window onresize={resize} />
<div class="flex h-screen items-center justify-center"> <div class="flex h-screen items-center justify-center w-screen">
<div class="w-20 mr-auto"></div>
<div class="relative"> <div class="relative">
<img <img
src="/background_image?342038402" src="/background_image?342038402"

View File

@@ -0,0 +1,10 @@
<script lang="ts">
type Props = {
open: boolean;
onClose: () => void;
};
</script>
<dialog>
<div></div>
</dialog>

View File

@@ -1,5 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { TrackerData } from "$lib/utils/types"; import type { TrackerData } from "$lib/utils/types";
import { onMount } from "svelte";
import Modal from "./Modal.svelte";
type Props = { type Props = {
selected: number; selected: number;
@@ -17,6 +19,8 @@
height = $bindable(), height = $bindable(),
}: Props = $props(); }: Props = $props();
let arena_state: "full_arena" | "scene_only" = $state("scene_only");
const onchange = () => { const onchange = () => {
const x_send = trackers[selected].x / width; const x_send = trackers[selected].x / width;
const y_send = trackers[selected].y / height; const y_send = trackers[selected].y / height;
@@ -30,17 +34,39 @@
); );
}; };
let z_viz = $derived((trackers[selected].z).toFixed(2)) type arenaResponse = {
mode: "full_arena" | "scene_only";
};
const buttonAction = async () => {
await fetch("/mode")
.then((res) => res.json())
.then((data: arenaResponse) => {
arena_state = data.mode;
});
await fetch("/mode", {
method: "POST",
body: JSON.stringify({
mode: arena_state === "full_arena" ? "scene_only" : "full_arena",
}),
});
};
let z_viz = $derived(trackers[selected].z.toFixed(2));
</script> </script>
<div class="slider-container"> <Modal />
<div class="slider-container ml-auto">
<button class="bg-red-400 rounded-md p-2 mb-24"
onclick={buttonAction}>Change mode</button>
<input <input
type="range" type="range"
id="z" id="z"
min="0" min="0"
max="4" max="4"
step="0.01" step="0.01"
oninput="{onchange}" oninput={onchange}
bind:value={trackers[selected].z} bind:value={trackers[selected].z}
/> />
<output for="z">{z_viz} m</output> <output for="z">{z_viz} m</output>
@@ -57,12 +83,11 @@
writing-mode: vertical-lr; writing-mode: vertical-lr;
direction: rtl; direction: rtl;
appearance: none; appearance: none;
width: 75px; width: 120px;
height: 50%; height: 50%;
vertical-align: bottom; vertical-align: bottom;
} }
/* WebKit Browsers (Chrome, Safari, Edge) */ /* WebKit Browsers (Chrome, Safari, Edge) */
input::-webkit-slider-thumb { input::-webkit-slider-thumb {
-webkit-appearance: none; -webkit-appearance: none;
@@ -80,5 +105,4 @@
width: 6px; width: 6px;
border-radius: 3px; border-radius: 3px;
} }
</style> </style>