💄 Improve add task input
Tim Izzo tim@5ika.ch
Thu, 06 Feb 2025 13:11:21 +0100
6 files changed,
54 insertions(+),
72 deletions(-)
M
README.md
→
README.md
@@ -1,47 +1,8 @@
-# Svelte + TS + Vite - -This template should help get you started developing with Svelte and TypeScript in Vite. - -## Recommended IDE Setup - -[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). - -## Need an official Svelte framework? - -Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more. - -## Technical considerations +# Kōi -**Why use this over SvelteKit?** +## Tâches -- It brings its own routing solution which might not be preferable for some users. -- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app. - -This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project. - -Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate. - -**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?** - -Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information. - -**Why include `.vscode/extensions.json`?** - -Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project. - -**Why enable `allowJs` in the TS template?** - -While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant. - -**Why is HMR not preserving my local component state?** - -HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr). - -If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR. - -```ts -// store.ts -// An extremely simple external store -import { writable } from 'svelte/store' -export default writable(0) -``` +- [x] Améliorer l'input pour l'ajout d'une tâche +- [ ] Permettre d'entrer des tâches récurrentes +- [ ] Ajouter un raccourci clavier pour checker une tâche +- [ ] Essayer une connexion OIDC sur ActivityPods
M
deno.lock
→
deno.lock
@@ -7,7 +7,9 @@ "npm:@inrupt/vocab-common-rdf@^1.0.5": "1.0.5",
"npm:@sveltejs/vite-plugin-svelte@^5.0.3": "5.0.3_svelte@5.17.3__acorn@8.14.0_vite@6.0.7", "npm:@tailwindcss/vite@^4.0.1": "4.0.1_vite@6.0.7_lightningcss@1.29.1", "npm:@tsconfig/svelte@^5.0.4": "5.0.4", + "npm:@types/luxon@3": "3.4.2", "npm:daisyui@^5.0.0-beta.6": "5.0.0-beta.6", + "npm:luxon@^3.5.0": "3.5.0", "npm:svelte-check@^4.1.1": "4.1.3_svelte@5.17.3__acorn@8.14.0_typescript@5.6.3", "npm:svelte@^5.15.0": "5.17.3_acorn@8.14.0", "npm:tailwindcss@^4.0.1": "4.0.1",@@ -365,6 +367,9 @@ "integrity": "sha512-snm5oLckop0K3cTDAiBnZDy6ncx9DJ3mCRDvs42C884MbVYPP74Tiq2hFsSDRTyjK6RyDYDIulPiW23ge+g5Lw==",
"dependencies": [ "@types/node@22.5.4" ] + }, + "@types/luxon@3.4.2": { + "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==" }, "@types/node@18.19.70": { "integrity": "sha512-RE+K0+KZoEpDUbGGctnGdkrLFwi1eYKTlIHNl2Um98mUkGsm1u2Ff6Ltd0e8DktTtC98uy7rSj+hO8t/QuLoVQ==",@@ -607,6 +612,9 @@ },
"locate-character@3.0.0": { "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==" }, + "luxon@3.5.0": { + "integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==" + }, "magic-string@0.30.17": { "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", "dependencies": [@@ -818,7 +826,9 @@ "npm:@inrupt/vocab-common-rdf@^1.0.5",
"npm:@sveltejs/vite-plugin-svelte@^5.0.3", "npm:@tailwindcss/vite@^4.0.1", "npm:@tsconfig/svelte@^5.0.4", + "npm:@types/luxon@3", "npm:daisyui@^5.0.0-beta.6", + "npm:luxon@^3.5.0", "npm:svelte-check@^4.1.1", "npm:svelte@^5.15.0", "npm:tailwindcss@^4.0.1",
M
src/lib/components/NewTask.svelte
→
src/lib/components/NewTask.svelte
@@ -1,20 +1,33 @@
<script lang="ts"> import tasksStore from "../store/tasksStore"; + let value = $state(""); + const onKeyDown = (e: KeyboardEvent) => { - const element = e.target as HTMLInputElement; - const inputValue = element?.value; const enterKeys = ["Enter", "NumpadEnter"]; - if (inputValue && enterKeys.includes(e.code)) { - tasksStore.addTask({ name: inputValue, startTime: new Date() }); - element.value = ""; + if (value && enterKeys.includes(e.code)) { + tasksStore.addTask({ name: value, startTime: new Date() }); + value = ""; + } + }; + + const onClickButton = () => { + if (value) { + tasksStore.addTask({ name: value, startTime: new Date() }); + value = ""; } }; </script> -<input - class="input input-bordered w-full" - type="text" - placeholder="Ajouter une tâche" - onkeydown={onKeyDown} -/> +<div class="join w-full"> + <input + class="input input-bordered w-full join-item" + type="text" + placeholder="Ajouter une tâche" + onkeydown={onKeyDown} + bind:value + /> + <button class="btn btn-neutral btn-soft join-item" onclick={onClickButton} + >+</button + > +</div>
M
src/lib/components/TasksList.svelte
→
src/lib/components/TasksList.svelte
@@ -19,7 +19,7 @@ </script>
<!-- svelte-ignore a11y_no_noninteractive_tabindex --> <details class="collapse" bind:open> - <summary class="font-semibold collapse-title"> + <summary class="font-semibold collapse-title min-h-0 py-2"> {#if open} ◦{:else} •{/if}
M
src/lib/store/tasksStore.ts
→
src/lib/store/tasksStore.ts
@@ -15,7 +15,7 @@ const DEBOUNCE_TIME_SYNC = 2000;
const { set, update, subscribe } = writable<Task[]>([]); -const addTask = (task: Task) => { +const addTask = (task: Omit<Task, "id">) => { const podUrl = get(podInfo).podUrl; update(tasks => [ ...tasks,
M
src/pages/Home.svelte
→
src/pages/Home.svelte
@@ -49,18 +49,16 @@ }
}); </script> -<main class="w-3xl max-w-full mx-auto p-4"> - {#if sessionInfo.isLoggedIn} - <div class="flex justify-between"> - <h1 class="text-2xl mb-4">kōi</h1> - <Profile /> - </div> - <TasksFeed tasks={$tasksStore} /> - <NewTask /> - {:else} - <div class="flex flex-col items-center mt-8 gap-4"> - <span class="loading loading-spinner loading-xl"></span> - <span>Connexion au pod</span> - </div> - {/if} +<main class="w-3xl max-w-full mx-auto p-4 pb-15"> + <div class="flex justify-between"> + <h1 class="text-2xl mb-4">kōi</h1> + <Profile /> + </div> + <TasksFeed tasks={$tasksStore} /> </main> + +<div class="fixed bottom-0 left-0 right-0 p-4"> + <div class="w-3xl max-w-full mx-auto bg-white"> + <NewTask /> + </div> +</div>