Add URL content type support and enhance snippet functionality:

- Introduced 'url' as a new content type in the application.
- Updated database queries to include copy count for snippets.
- Enhanced UI components to display copy count and handle URL snippets.
This commit is contained in:
Bogdan
2026-06-17 11:34:39 +03:00
parent b5a0dbc473
commit 69b57f8aa1
14 changed files with 256 additions and 51 deletions
+11 -3
View File
@@ -7,7 +7,7 @@
import CenterPanel from '$lib/components/layout/CenterPanel.svelte';
import RightPanel from '$lib/components/layout/RightPanel.svelte';
import SettingsModal from '$lib/components/SettingsModal.svelte';
import type { CreateSnippetInput, UpdateSnippetInput, TimePeriod } from '$lib/types';
import type { CreateSnippetInput, UpdateSnippetInput, TimePeriod, ContentType } from '$lib/types';
let mode = $state<'idle' | 'creating' | 'editing'>('idle');
let formDirty = $state(false);
@@ -118,8 +118,9 @@
<div class="app-layout">
<LeftPanel
tags={store.tags}
tags={store.visibleTags}
activeFilter={store.tagFilter}
contentTypeFilter={store.contentTypeFilter}
timePeriodFilter={store.timePeriodFilter}
onFilterChange={(tag) => {
if (formDirty && !confirm('You have unsaved changes. Discard them?')) return;
@@ -127,6 +128,12 @@
store.select(null);
mode = 'idle';
}}
onContentTypeChange={(ct: ContentType | null) => {
if (formDirty && !confirm('You have unsaved changes. Discard them?')) return;
store.setContentTypeFilter(ct);
store.select(null);
mode = 'idle';
}}
onTimePeriodChange={(period: TimePeriod | null) => {
if (formDirty && !confirm('You have unsaved changes. Discard them?')) return;
store.setTimePeriodFilter(period);
@@ -142,6 +149,7 @@
loading={store.loading}
searchQuery={store.searchQuery}
tagFilter={store.tagFilter}
contentTypeFilter={store.contentTypeFilter}
timePeriodFilter={store.timePeriodFilter}
onSelect={handleSelectSnippet}
onSearch={(q) => {
@@ -170,7 +178,7 @@
<style>
.app-layout {
display: grid;
grid-template-columns: 220px 1fr 360px;
grid-template-columns: 270px 1fr 360px;
grid-template-rows: 100vh;
height: 100vh;
overflow: hidden;
+1 -1
View File
@@ -97,7 +97,7 @@
<div class="field">
<label for="type-buttons">Type</label>
<div class="type-buttons" id="type-buttons" role="group">
{#each (['code', 'cli', 'text'] as ContentType[]) as t (t)}
{#each (['code', 'cli', 'text', 'url'] as ContentType[]) as t (t)}
<button
class="type-btn"
class:active={contentType === t}