From 0f363114ba27daeca5d2974e20b5a4b741ea7afa Mon Sep 17 00:00:00 2001 From: Xylight Date: Mon, 24 Jun 2024 11:18:43 -0700 Subject: [PATCH] feat: add custom pins --- bun.lockb | Bin 297337 -> 297337 bytes .../lemmy/community/CommunityItem.svelte | 8 +- src/lib/components/ui/navbar/link.ts | 95 ++++++++++++++++++ src/lib/components/ui/sidebar/Sidebar.svelte | 38 +++++++ .../ui/sidebar/SidebarButton.svelte | 3 +- src/lib/i18n/en.json | 4 + src/lib/settings.ts | 3 + src/routes/settings/+page.svelte | 37 +++++++ 8 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 src/lib/components/ui/navbar/link.ts diff --git a/bun.lockb b/bun.lockb index e1a08f6f5fc7207259107246961ec1ab40d49622..822582094498e86edc2b5a51af017ea570c9d34f 100755 GIT binary patch delta 256 zcmV+b0ssE_k`non5|Az+aumMfMFD_UU4NWvY3_{?0Rj0?i)MF)(nzOZS8Pudu}-?V z0S}WgE+><4#|e`;x{s5@fGCr2E(nA8y0`ec0p%A!26*piFbHRDRuMFDP;DZ)Mmn%e ze^<$X9Mx4+&nR^$nKAu(G>C;&ummSjq$UtA7 zz0d=$K3XyOErQ`2%jl3L{t(9!{1;xeDp__5H-h~NQv_x9NPTuC@Pjbu$NL`tbMaWz zC~F@#f-uG~>PUwr)B(38)B<8C2mxL(G%hhNFo%!)0=JL+1E^a8HMcle1PlQIIk!bw G1T-*(Yi|bt delta 256 zcmV+b0ssE_k`non5|Az++T<4#|e`;x{s3tgea46E(nA8y0`ec0p%A!^JR}V+J^a_!wpHM3t{b0<{mDG zO%a4u@|b)ejY17+*__kX73XKul z$%UPpPw5a0c|_p1sq){ffJZc3KYD#~^8zh{42_$yr=SI}rNwnkGG??3Wvm - - - +{#if showInfo} + + + +{/if}
diff --git a/src/lib/components/ui/navbar/link.ts b/src/lib/components/ui/navbar/link.ts new file mode 100644 index 00000000..506861a7 --- /dev/null +++ b/src/lib/components/ui/navbar/link.ts @@ -0,0 +1,95 @@ +import { t } from '$lib/translations' +import { + UserCircle, + type IconSource, + Home, + ChartBar, + Cog6Tooth, + Newspaper, + GlobeAmericas, + GlobeAlt, + MagnifyingGlass, + ShieldCheck, + ServerStack, + PencilSquare, +} from 'svelte-hero-icons' +import { get } from 'svelte/store' + +export interface Link { + url: string + label?: string +} + +export const defaultLinks: Link[] = [ + { + url: '/profile', + label: get(t)('profile.profile'), + }, + { + url: '/', + label: t.get('nav.home'), + }, + { + url: '/?type=All', + label: t.get('filter.location.all'), + }, + { + url: '/?type=Local', + label: t.get('filter.location.local'), + }, + { + url: '/?type=Subscribed', + label: t.get('filter.location.subscribed'), + }, + { + url: '/communities', + label: t.get('nav.communities'), + }, + { + url: '/search', + label: t.get('nav.search'), + }, + { + url: '/moderation', + label: t.get('moderation.label'), + }, + { + url: '/admin', + label: t.get('admin.label'), + }, + { + url: '/settings', + label: t.get('nav.menu.settings'), + }, + { + url: '/create/post', + label: t.get('form.post.create'), + }, +] + +export const iconOfLink = (url: string): IconSource => { + switch (url) { + case '/profile': + return UserCircle + case '/': + return Home + case '/?type=All': + return ChartBar + case '/?type=Subscribed': + return Newspaper + case '/?type=Local': + return GlobeAmericas + case '/communities': + return GlobeAlt + case '/search': + return MagnifyingGlass + case '/moderation': + return ShieldCheck + case '/admin': + return ServerStack + case '/settings': + return Cog6Tooth + case '/create/post': + return PencilSquare + } +} diff --git a/src/lib/components/ui/sidebar/Sidebar.svelte b/src/lib/components/ui/sidebar/Sidebar.svelte index 066d9d3d..d33decd3 100644 --- a/src/lib/components/ui/sidebar/Sidebar.svelte +++ b/src/lib/components/ui/sidebar/Sidebar.svelte @@ -28,6 +28,21 @@ import Application from '../../../../routes/admin/applications/Application.svelte' import { t } from '$lib/translations' import ItemList from '$lib/components/lemmy/generic/ItemList.svelte' + import { iconOfLink } from '../navbar/link' + import { goto } from '$app/navigation' + import { page } from '$app/stores' + + function pinsEvent(node: HTMLElement) { + node.oncontextmenu = (e) => { + e.preventDefault() + console.log('test') + // $userSettings.dock.pins = $userSettings.dock.pins.splice( + // $userSettings.dock.pins.findIndex((p) => pin.url == p.url), + // 1 + // ) + return false + } + }
+