Skip to content

Instantly share code, notes, and snippets.

@skflowne
Last active August 4, 2020 23:02
Show Gist options
  • Save skflowne/75b20927869723bacc639700a2251f63 to your computer and use it in GitHub Desktop.
Save skflowne/75b20927869723bacc639700a2251f63 to your computer and use it in GitHub Desktop.
<script lang="ts">
import { onMount } from "svelte"
import Tailwind from "./Tailwind.svelte"
import FileList from "./components/file-search/FileList.svelte"
import FileSearch from "./components/file-search/FileSearch.svelte"
import files from "./store/files"
let searching = false
const handleKeyUp = (e: KeyboardEvent) => {
if (e.key === "t" || e.key === "T") {
searching = true
}
if (e.key === "Escape") {
searching = false
}
}
onMount(() => {
document.addEventListener("keyup", handleKeyUp)
return () => {
document.removeEventListener("keyup", handleKeyUp)
}
})
</script>
<Tailwind />
<main>
{#if searching}
<FileSearch />
{/if}
<FileList files={$files} />
</main>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment