Skip to content

Commit

Permalink
feat: add submit form function
Browse files Browse the repository at this point in the history
  • Loading branch information
xnought committed Jan 18, 2024
1 parent a90fb93 commit 25f87ba
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions frontend/src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
let username: string = "";
let password: string = "";
$: formValid = username.length > 0 && password.length > 0;
/**
* Gets run on button "Login" or form submit (pressing enter)
* @todo add login logic with tokens and making a request to the backend
*/
function submitForm() {
if (!formValid) return;
console.log("submitted");
console.table({ username, password });
}
</script>

<form on:submit|preventDefault class="flex gap-4 flex-col">
<form on:submit={submitForm} class="flex gap-5 flex-col">
<div>
<Label for="username">Username</Label>
<Input
id="username"
style="width: 300px;"
bind:value={username}
placeholder="Enter your username..."
/>
Expand All @@ -20,15 +33,13 @@
<Input
type="password"
id="password"
style="width: 300px;"
bind:value={password}
placeholder="Enter your password..."
/>
</div>

<Button
type="submit"
on:click={() => {
console.log("hit submit", password, username);
}}>Login</Button
>
<div>
<Button size="lg" type="submit" disabled={!formValid}>Login</Button>
</div>
</form>

0 comments on commit 25f87ba

Please sign in to comment.