This repository has been archived on 2024-08-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
chellaris-sign-up-site/src/routes/Settings.svelte

67 lines
2.1 KiB
Svelte
Raw Normal View History

2023-08-28 07:28:20 +02:00
<script lang="ts">
import { browser } from "$app/environment";
2023-09-13 16:30:24 +02:00
import Button from "$lib/components/Button.svelte";
2023-08-30 04:17:16 +02:00
import AuthTokenStore from "$lib/stores/AuthTokenStore";
2023-09-13 16:30:24 +02:00
import { getModalStore } from "@skeletonlabs/skeleton";
import { fade, slide } from "svelte/transition";
2023-08-28 07:28:20 +02:00
2023-09-13 16:30:24 +02:00
const modalStore = getModalStore();
2023-08-28 07:28:20 +02:00
let showAuthSaved = false;
2023-09-13 16:30:24 +02:00
let showPlaceholder = true;
2023-08-28 07:28:20 +02:00
const saveAuth = () => {
showAuthSaved = true;
2023-09-13 16:30:24 +02:00
showPlaceholder = false;
2023-08-28 07:42:02 +02:00
setTimeout(function() {
showAuthSaved = false;
2023-09-13 16:30:24 +02:00
setTimeout(function() {
showPlaceholder = true;
}, 195);
}, 1000);
2023-08-28 07:28:20 +02:00
document.cookie = "authToken=" + authToken;
2023-08-30 04:17:16 +02:00
$AuthTokenStore = authToken;
2023-08-28 07:28:20 +02:00
}
let authToken: string;
2023-09-12 19:16:23 +02:00
if (browser) {
authToken = document.cookie.split("=")[document.cookie.split("=").length - 1];
$AuthTokenStore = authToken;
2023-08-28 07:28:20 +02:00
}
const handleSubmit = () => {
console.log("submitted ", gameGroupSettings);
2023-09-13 16:30:24 +02:00
document.cookie = "authToken=" + authToken;
modalStore.close();
2023-08-28 07:28:20 +02:00
}
let gameGroupSettings: [] = [];
2023-09-13 16:30:24 +02:00
const formInput = "bg-surface-200-700-token focus:brightness-105 hover:brightness-105 border-token border-surface-400-500-token rounded-token px-3 w-[6rem]"
2023-08-28 07:28:20 +02:00
</script>
2023-09-13 16:30:24 +02:00
<div class="card p-4 w-modal-slim shadow-xl space-y-4 text-center rounded-xl">
<h2>Settings</h2>
<div class="p-4 space-y-4">
<form on:submit|preventDefault={handleSubmit} class="modal-form">
<label for="authTokenInput" class="label my-2 gap-1 grid grid-cols-[20%,30%,30%,10%,10%]">
<span></span>
<span>Auth Token:</span>
<input class={formInput} id="authTokenInput" bind:value={authToken} on:input={saveAuth} type="text">
{#if showAuthSaved}
<span transition:fade={{duration: 200}}>Saved!</span>
{/if}
2023-08-28 07:28:20 +02:00
2023-09-13 16:30:24 +02:00
</label>
2023-08-28 07:46:15 +02:00
<br>
<br>
<!-- <b>Show Game Groups:</b><br>
2023-08-28 07:28:20 +02:00
<input type="checkbox" bind:group={gameGroupSettings} value="b">Group B<br>
2023-08-28 07:46:15 +02:00
<input type="checkbox" bind:group={gameGroupSettings} value="-">Ungrouped<br> -->
2023-08-28 07:28:20 +02:00
2023-09-13 16:30:24 +02:00
<Button text="Save"/>
2023-08-28 07:28:20 +02:00
</form>
</div>
2023-09-13 16:30:24 +02:00
</div>