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

79 lines
1.8 KiB
Svelte
Raw Normal View History

2023-08-28 07:28:20 +02:00
<script lang="ts">
import { browser } from "$app/environment";
import Modal from "$lib/components/Modal.svelte";
2023-08-30 04:17:16 +02:00
import AuthTokenStore from "$lib/stores/AuthTokenStore";
2023-08-28 07:42:02 +02:00
import { fade } from "svelte/transition";
2023-08-28 07:28:20 +02:00
export let showSettings: boolean;
let showAuthSaved = false;
const saveAuth = () => {
showAuthSaved = true;
2023-08-28 07:42:02 +02:00
setTimeout(function() {
showAuthSaved = false;
}, 2000);
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;
$: {
if (browser) {
authToken = document.cookie.split("=")[document.cookie.split("=").length - 1];
2023-08-30 04:17:16 +02:00
$AuthTokenStore = authToken;
2023-08-28 07:28:20 +02:00
}
}
const toggleSettings = () => {
showSettings = !showSettings;
}
const handleSubmit = () => {
console.log("submitted ", gameGroupSettings);
showSettings = false;
}
let gameGroupSettings: [] = [];
</script>
<Modal showModal={showSettings} on:click={toggleSettings}>
<h3>Settings</h3>
<div class="settings-modal">
<form on:submit|preventDefault={handleSubmit}>
<label for="authTokenInput">Auth Token:</label>
<input id="authTokenInput" bind:value={authToken} on:input={saveAuth} type="text">
{#if showAuthSaved}
2023-08-28 07:46:15 +02:00
<label for="authTokenInput" in:fade={{duration: 200}} out:fade={{duration: 200}}>Saved!</label>
2023-08-28 07:28:20 +02:00
{/if}
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
<div class="settings-modal-save">
<button>Save</button>
</div>
</form>
</div>
</Modal>
<style>
.settings-modal {
text-align: left;
}
.settings-modal input {
margin-left: 1rem;
}
.settings-modal-save {
text-align: center;
}
</style>