|
24 | 24 | let editContents = $state<Record<string, string>>(startInEditMode ? { ...snippet.content } : {}); |
25 | 25 | let deleteModal: HTMLDialogElement; |
26 | 26 |
|
27 | | -
|
28 | 27 | let languagesShowingInMultiple = $derived( |
29 | 28 | dbStore.data.settings.languages.filter((l) => l.showInMultiple) |
30 | 29 | ); |
|
163 | 162 |
|
164 | 163 | <div |
165 | 164 | class={`snippet-card group card border border-base-200 bg-base-100 shadow-xl ${isReorderMode ? 'shake-animation cursor-grab active:cursor-grabbing' : ''} ${isSlim ? 'md:overflow-hidden' : ''}`} |
166 | | - style={isReorderMode ? `animation-delay: -${Math.random() * 0.3}s; animation-duration: ${0.25 + Math.random() * 0.15}s;` : ''} |
| 165 | + style={isReorderMode |
| 166 | + ? `animation-delay: -${Math.random() * 0.3}s; animation-duration: ${0.25 + Math.random() * 0.15}s;` |
| 167 | + : ''} |
167 | 168 | data-id={snippet.id} |
168 | 169 | transition:scale={{ duration: 300, start: 0.9, opacity: 0, easing: backOut }} |
169 | 170 | > |
170 | 171 | <div class={`pointer-events-none card-body p-4 ${isSlim ? 'md:p-2' : ''}`}> |
171 | 172 | <div |
172 | | - class={`flex items-start justify-between ${isReorderMode ? 'opacity-50' : 'pointer-events-auto'} ${isSlim ? 'md:absolute md:top-0 md:left-0 md:right-0 md:z-10 md:transition-all md:duration-200 md:bg-linear-to-b md:from-base-100/95 md:to-transparent md:p-2 md:pb-6 md:pointer-events-none' : ''} ${isSlim && !isEditing ? `md:-translate-y-full md:opacity-0 ${!isReorderMode ? 'md:group-hover:translate-y-0 md:group-hover:opacity-100' : ''}` : ''} ${isSlim && isEditing ? 'md:translate-y-0 md:opacity-100' : ''}`} |
| 173 | + class={`flex items-start justify-between ${isReorderMode ? 'opacity-50' : 'pointer-events-auto'} ${isSlim ? 'md:pointer-events-none md:absolute md:top-0 md:right-0 md:left-0 md:z-10 md:bg-linear-to-b md:from-base-100/95 md:to-transparent md:p-2 md:pb-6 md:transition-all md:duration-200' : ''} ${isSlim && !isEditing ? `md:-translate-y-full md:opacity-0 ${!isReorderMode ? 'md:group-hover:translate-y-0 md:group-hover:opacity-100' : ''}` : ''} ${isSlim && isEditing ? 'md:translate-y-0 md:opacity-100' : ''}`} |
173 | 174 | > |
174 | 175 | <div class="pointer-events-auto flex flex-col gap-1"> |
175 | 176 | <div |
176 | 177 | class="tooltip tooltip-bottom tooltip-right" |
177 | 178 | data-tip={new Date(snippet.updatedAt).toLocaleString()} |
178 | 179 | > |
179 | | - <div class={`${isSlim ? 'md:mt-0' : 'mt-1'} flex w-max cursor-help items-center gap-1 text-xs text-base-content/50`}> |
| 180 | + <div |
| 181 | + class={`${isSlim ? 'md:mt-0' : 'mt-1'} flex w-max cursor-help items-center gap-1 text-xs text-base-content/50`} |
| 182 | + > |
180 | 183 | <Clock class="h-3 w-3" /> |
181 | 184 | Updated {getRelativeTime(snippet.updatedAt)} |
182 | 185 | </div> |
|
214 | 217 | </div> |
215 | 218 | {:else} |
216 | 219 | <button |
217 | | - class="pointer-events-auto absolute right-0 btn btn-circle btn-ghost btn-sm" |
| 220 | + class="btn pointer-events-auto absolute right-0 btn-circle btn-ghost btn-sm" |
218 | 221 | in:fade={{ duration: 150 }} |
219 | 222 | out:fade={{ duration: 150 }} |
220 | 223 | onclick={startEdit} |
|
240 | 243 | in:fade={{ duration: 200, delay: 50 }} |
241 | 244 | out:fade={{ duration: 150 }} |
242 | 245 | > |
243 | | - {#each dbStore.data.settings.languages as lang (lang.id)} |
244 | | - <div> |
245 | | - <label class="label pt-0 pb-1" for="content-{snippet.id}-{lang.id}" |
246 | | - ><span class="label-text text-xs font-bold">{lang.name} Content</span></label |
247 | | - > |
248 | | - <textarea |
249 | | - id="content-{snippet.id}-{lang.id}" |
250 | | - class="textarea-bordered textarea w-full font-mono text-sm leading-relaxed" |
251 | | - rows="3" |
252 | | - bind:value={editContents[lang.id]} |
253 | | - placeholder="Enter {lang.name} snippet..."></textarea> |
254 | | - </div> |
255 | | - {/each} |
| 246 | + {#each dbStore.data.settings.languages as lang (lang.id)} |
| 247 | + <div> |
| 248 | + <label class="label pt-0 pb-1" for="content-{snippet.id}-{lang.id}" |
| 249 | + ><span class="label-text text-xs font-bold">{lang.name} Content</span></label |
| 250 | + > |
| 251 | + <textarea |
| 252 | + id="content-{snippet.id}-{lang.id}" |
| 253 | + class="textarea-bordered textarea w-full font-mono text-sm leading-relaxed" |
| 254 | + rows="3" |
| 255 | + bind:value={editContents[lang.id]} |
| 256 | + placeholder="Enter {lang.name} snippet..."></textarea> |
| 257 | + </div> |
| 258 | + {/each} |
256 | 259 | </div> |
257 | 260 | </div> |
258 | 261 | {:else} |
|
266 | 269 | {@const content = snippet.content[lang.id]} |
267 | 270 | {#if content || !isMultipleMode} |
268 | 271 | <div |
269 | | - class="flex flex-col gap-1 {isMultipleMode && dbStore.data.settings.hideLanguageTitles |
| 272 | + class="flex flex-col gap-1 {isMultipleMode && |
| 273 | + dbStore.data.settings.hideLanguageTitles |
270 | 274 | ? 'tooltip tooltip-top before:z-50 hover:before:delay-1000 hover:after:delay-1000' |
271 | 275 | : ''}" |
272 | | - data-tip={isMultipleMode && dbStore.data.settings.hideLanguageTitles ? lang.name : null} |
| 276 | + data-tip={isMultipleMode && dbStore.data.settings.hideLanguageTitles |
| 277 | + ? lang.name |
| 278 | + : null} |
273 | 279 | > |
274 | 280 | {#if isMultipleMode && !dbStore.data.settings.hideLanguageTitles} |
275 | 281 | <span class="px-1 text-xs font-bold opacity-60">{lang.name}</span> |
|
289 | 295 | > |
290 | 296 | <div |
291 | 297 | class="flex items-center gap-2 rounded-full bg-success px-3 py-1 font-sans font-bold text-success-content shadow-sm" |
292 | | - transition:scale={{ duration: 300, start: 0.8, opacity: 0, easing: backOut }} |
| 298 | + transition:scale={{ |
| 299 | + duration: 300, |
| 300 | + start: 0.8, |
| 301 | + opacity: 0, |
| 302 | + easing: backOut |
| 303 | + }} |
293 | 304 | > |
294 | 305 | <Check class="h-4 w-4" /> Copied |
295 | 306 | </div> |
|
298 | 309 | </button> |
299 | 310 | {:else} |
300 | 311 | <button |
301 | | - class="relative block min-h-12 w-full cursor-default select-none rounded-lg bg-base-200 p-3 text-left font-mono text-sm wrap-break-word whitespace-pre-wrap text-base-content/50 italic transition-colors" |
| 312 | + class="relative block min-h-12 w-full cursor-default rounded-lg bg-base-200 p-3 text-left font-mono text-sm wrap-break-word whitespace-pre-wrap text-base-content/50 italic transition-colors select-none" |
302 | 313 | disabled={true} |
303 | 314 | > |
304 | 315 | Empty snippet |
|
309 | 320 | {/each} |
310 | 321 | {#if isMultipleMode && displayedLanguages.every((lang) => !snippet.content[lang.id])} |
311 | 322 | <button |
312 | | - class="relative block min-h-12 w-full cursor-default select-none rounded-lg bg-base-200 p-3 text-left font-mono text-sm wrap-break-word whitespace-pre-wrap text-base-content/50 italic transition-colors" |
| 323 | + class="relative block min-h-12 w-full cursor-default rounded-lg bg-base-200 p-3 text-left font-mono text-sm wrap-break-word whitespace-pre-wrap text-base-content/50 italic transition-colors select-none" |
313 | 324 | disabled={true} |
314 | 325 | > |
315 | 326 | Empty snippet |
|
0 commit comments