From 57cebc7330dce5248e5ddaf5bccf58bcbedf9c14 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Thu, 27 Jun 2024 20:55:03 +0800 Subject: [PATCH] add favicon to shortener card + update shortener card ui --- .../src/lib/components/ShortenerCard.svelte | 188 ++++++++--------- frontend/src/routes/(app)/links/+page.svelte | 33 +-- .../[id]/(components)/ShortenerCard.svelte | 198 +++++++++--------- .../routes/(app)/projects/[id]/+page.svelte | 25 +-- 4 files changed, 218 insertions(+), 226 deletions(-) diff --git a/frontend/src/lib/components/ShortenerCard.svelte b/frontend/src/lib/components/ShortenerCard.svelte index 153f7f2..37760aa 100644 --- a/frontend/src/lib/components/ShortenerCard.svelte +++ b/frontend/src/lib/components/ShortenerCard.svelte @@ -4,8 +4,10 @@ import * as Tooltip from '$lib/components/ui/tooltip' import * as Dialog from '$lib/components/ui/dialog' import * as DropdownMenu from '$lib/components/ui/dropdown-menu' + import * as Avatar from '$lib/components/ui/avatar' import { Badge } from '$lib/components/ui/badge' import { ScrollArea } from '$lib/components/ui/scroll-area' + import { Separator } from '$lib/components/ui/separator' import type { Shortener } from '$lib/db/types' import { BarChart, @@ -43,25 +45,10 @@ return '' } - const showEditModal = async (e: MouseEvent) => { - if (innerWidth < 640) return - - const { href } = e.currentTarget as HTMLAnchorElement - - const result = await preloadData(href) - - if (result.type === 'loaded' && result.status === 200) { - pushState(href, { editLink: result.data }) - } else { - // something bad happened! try navigating - goto(href) - } - } - let editProjectLinkOpen = false let editData: typeof $page.state.editLink - const showEditModalNew = async (code: string) => { + const showEditModal = async (code: string) => { const href = `/links/${code}/edit` const result = await preloadData(href) @@ -91,45 +78,27 @@ goto(href) } } + + const hostDomain = 'https://' + shortener.link.split('/')[2] - + - - -
- {#if shortener.projectName} - {shortener.projectName} - {/if} - - {#if shortener.active} - - Active - {:else} - - Inactive - {/if} - -
-
- -
+ + + + + favicon + + + +
+ class="whitespace-nowrap max-w-[250px] overflow-x-clip overflow-ellipsis"> {shortener.link}
@@ -137,6 +106,65 @@

{shortener.link}

+ + +
+ + + + + + + + + showEditModal(shortener.code)}> + + Edit + + + openDeleteDialog(shortener.code)} + class="flex gap-2 items-center text-destructive data-[highlighted]:bg-destructive"> + + Delete + + + + +
+ + +
+
+ + + + + {#if shortener.ios} @@ -159,52 +187,24 @@ {/if}
- - - -
-
- - - - +
+ {#if shortener.projectName} + {shortener.projectName} + {/if} + + {#if shortener.active} + + Active + {:else} + + Inactive + {/if} +
- - - - - - - - showEditModalNew(shortener.code)}> - - Edit - - - openDeleteDialog(shortener.code)} - class="text-destructive data-[highlighted]:bg-destructive flex items-center gap-2"> - - Delete - - - -
diff --git a/frontend/src/routes/(app)/links/+page.svelte b/frontend/src/routes/(app)/links/+page.svelte index d53fe2e..77a162e 100644 --- a/frontend/src/routes/(app)/links/+page.svelte +++ b/frontend/src/routes/(app)/links/+page.svelte @@ -80,7 +80,7 @@
+ class="flex flex-wrap-reverse gap-4 justify-start items-center p-4"> @@ -124,10 +124,10 @@ class="justify-between"> {selectedProject} + class="ml-2 w-4 h-4 opacity-50 shrink-0" /> - + No project found. @@ -186,7 +186,7 @@ -
+
-