minor tweaks

This commit is contained in:
2023-04-29 10:01:45 -07:00
parent e746963052
commit 913148a75a
5 changed files with 29 additions and 45 deletions

View File

@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { slide } from 'svelte/transition';
let extraClasses;
let extraClasses = "";
export {extraClasses as class};
export let slideDuration = 150;
let animationClass = "";

View File

@ -27,12 +27,10 @@
<div class="flex flex-col h-screen items-center justify-center p-4 space-y-4">
{#await invoke('get_session_status') then status}
{#if status === 'locked'}
<!-- <img src={closedPadlockUrl} alt="A locked padlock" class="w-32" /> -->
{@html vaultDoorSvg}
<h2 class="text-2xl font-bold">Creddy is locked</h2>
<Link target="Unlock" class="w-64">
<Link target="Unlock" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Unlock</button>
</Link>
@ -43,7 +41,7 @@
{:else if status === 'empty'}
{@html vaultDoorSvg}
<h2 class="text-2xl font-bold">No credentials found</h2>
<Link target="EnterCredentials" class="w-64">
<Link target="EnterCredentials" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Enter Credentials</button>
</Link>
{/if}

View File

@ -1,5 +1,6 @@
<script>
import { invoke } from '@tauri-apps/api/tauri';
import { onMount } from 'svelte';
import { appState } from '../lib/state.js';
import { navigate } from '../lib/routing.js';
@ -11,7 +12,14 @@
let errorMsg = null;
let alert;
let passphrase = '';
let loadTime = 0;
async function unlock() {
// The hotkey for navigating here from homepage is Enter, which also
// happens to trigger the form submit event
if (Date.now() - loadTime < 10) {
return;
}
try {
let r = await invoke('unlock', {passphrase});
$appState.credentialStatus = 'unlocked';
@ -37,6 +45,10 @@
}
}
}
onMount(() => {
loadTime = Date.now();
})
</script>
@ -47,6 +59,7 @@
<ErrorAlert bind:this="{alert}">{errorMsg}</ErrorAlert>
{/if}
<!-- svelte-ignore a11y-autofocus -->
<input autofocus name="password" type="password" placeholder="correct horse battery staple" bind:value="{passphrase}" class="input input-bordered" />
<input type="submit" class="btn btn-primary" />