create-mikstack 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
const notesQuery = z.q(queries.note.mine());
|
|
26
26
|
const notes = $derived(notesQuery.data);
|
|
27
27
|
|
|
28
|
+
const isMac = $derived(navigator.platform.startsWith("Mac") || navigator.platform === "iPhone");
|
|
29
|
+
const isMobile = $derived(/Android|iPhone|iPad|iPod/i.test(navigator.userAgent));
|
|
30
|
+
const modLabel = $derived(isMac ? "⌘" : "Ctrl");
|
|
31
|
+
|
|
32
|
+
function submitOnModEnter(e: KeyboardEvent) {
|
|
33
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
(e.currentTarget as HTMLFormElement).requestSubmit();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
let editingId = $state<string | null>(null);
|
|
29
40
|
|
|
30
41
|
const noteSchema = v.object({
|
|
@@ -107,7 +118,7 @@
|
|
|
107
118
|
|
|
108
119
|
<section>
|
|
109
120
|
<h2>New note</h2>
|
|
110
|
-
<form id={createNoteForm.id} onsubmit={createNoteForm.onsubmit} class="note-form">
|
|
121
|
+
<form id={createNoteForm.id} onsubmit={createNoteForm.onsubmit} onkeydown={submitOnModEnter} class="note-form">
|
|
111
122
|
<FormField for={createNoteForm.fields.title.as("text").id}>
|
|
112
123
|
{#snippet label(attrs)}
|
|
113
124
|
<label {...attrs}>Title</label>
|
|
@@ -141,6 +152,7 @@
|
|
|
141
152
|
<Button type="submit" disabled={createNoteForm.pending}>
|
|
142
153
|
<Plus size={16} weight="bold" />
|
|
143
154
|
{createNoteForm.pending ? "Creating..." : "Create note"}
|
|
155
|
+
{#if !isMobile}<kbd>{modLabel}+Enter</kbd>{/if}
|
|
144
156
|
</Button>
|
|
145
157
|
</form>
|
|
146
158
|
</section>
|
|
@@ -156,7 +168,7 @@
|
|
|
156
168
|
{#each notes as note (note.id)}
|
|
157
169
|
<li class="note-card">
|
|
158
170
|
{#if editingId === note.id}
|
|
159
|
-
<form id={editForm.id} onsubmit={editForm.onsubmit} class="note-form">
|
|
171
|
+
<form id={editForm.id} onsubmit={editForm.onsubmit} onkeydown={submitOnModEnter} class="note-form">
|
|
160
172
|
<FormField for={editForm.fields.title.as("text").id}>
|
|
161
173
|
{#snippet label(attrs)}
|
|
162
174
|
<label {...attrs}>Title</label>
|
|
@@ -179,6 +191,7 @@
|
|
|
179
191
|
oninput={(e) =>
|
|
180
192
|
editForm.fields.content.set((e.target as HTMLTextAreaElement).value)}
|
|
181
193
|
value={editForm.fields.content.value() as string}
|
|
194
|
+
autofocus
|
|
182
195
|
/>
|
|
183
196
|
</FormField>
|
|
184
197
|
|
|
@@ -189,6 +202,7 @@
|
|
|
189
202
|
<div class="actions">
|
|
190
203
|
<Button type="submit" disabled={editForm.pending}>
|
|
191
204
|
{editForm.pending ? "Saving..." : "Save"}
|
|
205
|
+
{#if !isMobile}<kbd>{modLabel}+Enter</kbd>{/if}
|
|
192
206
|
</Button>
|
|
193
207
|
<Button variant="ghost" type="button" onclick={cancelEdit}>
|
|
194
208
|
<X size={16} weight="bold" /> Cancel
|