From 08ba7284383cff74971659963c87a2eb4cd3c031 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 6 Jan 2024 05:49:33 -0800 Subject: refactor(tools): input template --- Koifile | 9 ++++- src/lib/Tools/InputTemplate.svelte | 51 +++++++++++++++++++++++++ src/lib/Tools/RandomFollower.svelte | 76 +++++++++++++------------------------ 3 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 src/lib/Tools/InputTemplate.svelte diff --git a/Koifile b/Koifile index 9aa9c1fc..b0dcf17a 100644 --- a/Koifile +++ b/Koifile @@ -1,10 +1,15 @@ #!/usr/bin/env koi if args.len() > 0 { - if args[0] == 'dev' { + let action = args[0] + + if action == 'dev' { bun run dev --host + } else if action == 'vpn' { + piactl disconnect + piactl connect } else { - bun --bun run {args[0]} + bun --bun run {action} } } diff --git a/src/lib/Tools/InputTemplate.svelte b/src/lib/Tools/InputTemplate.svelte new file mode 100644 index 00000000..16b4ec8f --- /dev/null +++ b/src/lib/Tools/InputTemplate.svelte @@ -0,0 +1,51 @@ + + +
+

+ { + if (e.key === 'Enter') { + submission = input; + + onSubmit(); + } + }} + /> + +

+ + {#if submission !== ''} + + {:else} +

+ + {prompt} + {/if} +

diff --git a/src/lib/Tools/RandomFollower.svelte b/src/lib/Tools/RandomFollower.svelte index 7824a424..f47a4441 100644 --- a/src/lib/Tools/RandomFollower.svelte +++ b/src/lib/Tools/RandomFollower.svelte @@ -1,60 +1,36 @@ -
-

- - { - if (e.key === 'Enter') { - submit = input; - randomSeed = Math.random(); - - // eslint-disable-next-line no-undef - umami.track('Random Follower'); - } - }} - /> - -

- - {#if submit !== ''} - {#await followers(submit)} - Loading followers ... 50% - {:then users} - {@const user = users[Math.floor(randomSeed * users.length)]} - -

+ + { + randomSeed = Math.random(); + + // eslint-disable-next-line no-undef + umami.track('Random Follower'); + }} +> + {#await followers(submission)} + Loading followers ... 50% + {:then users} + {@const user = users[Math.floor(randomSeed * users.length)]} - - {user.name} - - {:catch} - - {/await} - {:else}

- Enter a username to search for to continue. - {/if} -

+ + {user.name} + + {:catch} + + {/await} + -- cgit v1.2.3