feat: add custom pins
This commit is contained in:
1 parent
8957b192b9
commit
0f363114ba
8 files changed
+181
-1
No files matched your search
@@ -27,9 +27,11 @@
|
|||||||
let showInfo = false
|
let showInfo = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if showInfo}
|
||||||
<Modal title="Community" bind:open={showInfo}>
|
<Modal title="Community" bind:open={showInfo}>
|
||||||
<CommunityCard community_view={community} />
|
<CommunityCard community_view={community} />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="py-4 flex flex-col gap-2 text-sm max-w-full relative">
|
<div class="py-4 flex flex-col gap-2 text-sm max-w-full relative">
|
||||||
<div class="flex flex-row items-center">
|
<div class="flex flex-row items-center">
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,21 @@
|
|||||||
import Application from '../../../../routes/admin/applications/Application.svelte'
|
import Application from '../../../../routes/admin/applications/Application.svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
@@ -35,6 +50,29 @@
|
|||||||
gap-1 h-fit max-h-screen {$$props.class}"
|
gap-1 h-fit max-h-screen {$$props.class}"
|
||||||
style={$$props.style}
|
style={$$props.style}
|
||||||
>
|
>
|
||||||
|
{#if $userSettings.dock.pins?.length ?? 0 > 0}
|
||||||
|
<div class="flex items-center flex-wrap gap-2 pl-1.5">
|
||||||
|
{#each $userSettings.dock.pins as pin}
|
||||||
|
<SidebarButton
|
||||||
|
icon={iconOfLink(pin.url)}
|
||||||
|
on:click={() => goto(pin.url)}
|
||||||
|
color="tertiary"
|
||||||
|
alignment="center"
|
||||||
|
selected={`${$page.url.pathname}${$page.url.search}` == pin.url}
|
||||||
|
on:contextmenu={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
$userSettings.dock.pins = $userSettings.dock.pins.toSpliced(
|
||||||
|
$userSettings.dock.pins.findIndex((p) => pin.url == p.url),
|
||||||
|
1
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
}}
|
||||||
|
size="square-md"
|
||||||
|
></SidebarButton>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
|
{/if}
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
<SidebarButton icon={UserCircle} href="/profile/user">
|
<SidebarButton icon={UserCircle} href="/profile/user">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
|
|||||||
@@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
|
alignment="left"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
{href}
|
{href}
|
||||||
alignment="left"
|
|
||||||
on:click
|
on:click
|
||||||
|
on:contextmenu
|
||||||
class="font-normal {selected
|
class="font-normal {selected
|
||||||
? 'text-primary-900 dark:!text-primary-100'
|
? 'text-primary-900 dark:!text-primary-100'
|
||||||
: 'text-slate-600 dark:text-zinc-400'} {$userSettings.expandSidebar
|
: 'text-slate-600 dark:text-zinc-400'} {$userSettings.expandSidebar
|
||||||
|
|||||||
@@ -547,6 +547,10 @@
|
|||||||
"on": "On",
|
"on": "On",
|
||||||
"off": "Off",
|
"off": "Off",
|
||||||
"adaptive": "Adaptive"
|
"adaptive": "Adaptive"
|
||||||
|
},
|
||||||
|
"pins": {
|
||||||
|
"title": "Pins",
|
||||||
|
"description": "Click a pin to send it to the top of the sidebar. Right click a pinned item to remove it."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { writable } from 'svelte/store'
|
|||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public'
|
||||||
import { locale } from './translations'
|
import { locale } from './translations'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
import type { Link } from './components/ui/navbar/link'
|
||||||
|
|
||||||
console.log('Using the following default settings from the environment:')
|
console.log('Using the following default settings from the environment:')
|
||||||
console.log(env)
|
console.log(env)
|
||||||
@@ -80,6 +81,7 @@ interface Settings {
|
|||||||
dock: {
|
dock: {
|
||||||
noGap: boolean | null
|
noGap: boolean | null
|
||||||
top: boolean | null
|
top: boolean | null
|
||||||
|
pins: Link[]
|
||||||
}
|
}
|
||||||
posts: {
|
posts: {
|
||||||
deduplicateEmbed: boolean
|
deduplicateEmbed: boolean
|
||||||
@@ -146,6 +148,7 @@ export const defaultSettings: Settings = {
|
|||||||
dock: {
|
dock: {
|
||||||
noGap: toBool(env.PUBLIC_DOCK_PANEL) ?? null,
|
noGap: toBool(env.PUBLIC_DOCK_PANEL) ?? null,
|
||||||
top: toBool(env.PUBLIC_DOCK_TOP) ?? null,
|
top: toBool(env.PUBLIC_DOCK_TOP) ?? null,
|
||||||
|
pins: [],
|
||||||
},
|
},
|
||||||
posts: {
|
posts: {
|
||||||
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
|
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
Switch,
|
Switch,
|
||||||
TextInput,
|
TextInput,
|
||||||
toast,
|
toast,
|
||||||
|
Popover,
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
ArrowPath,
|
ArrowPath,
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
|
CheckCircle,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
GlobeAmericas,
|
GlobeAmericas,
|
||||||
@@ -34,6 +36,9 @@
|
|||||||
import Section from './Section.svelte'
|
import Section from './Section.svelte'
|
||||||
import ToggleSetting from './ToggleSetting.svelte'
|
import ToggleSetting from './ToggleSetting.svelte'
|
||||||
import { locales, t } from '$lib/translations'
|
import { locales, t } from '$lib/translations'
|
||||||
|
import { defaultLinks, iconOfLink } from '$lib/components/ui/navbar/link'
|
||||||
|
|
||||||
|
let pin: string = ''
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -88,6 +93,38 @@
|
|||||||
bind:selected={$userSettings.dock.noGap}
|
bind:selected={$userSettings.dock.noGap}
|
||||||
/>
|
/>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting>
|
||||||
|
<span slot="title">{$t('settings.navigation.pins.title')}</span>
|
||||||
|
<span slot="description">
|
||||||
|
{$t('settings.navigation.pins.description')}
|
||||||
|
</span>
|
||||||
|
<div class="flex items-center gap-1 flex-wrap">
|
||||||
|
{#each defaultLinks as pin}
|
||||||
|
<Popover openOnHover placement="bottom">
|
||||||
|
<Button
|
||||||
|
size="square-md"
|
||||||
|
slot="target"
|
||||||
|
on:click={() => {
|
||||||
|
$userSettings.dock.pins = [
|
||||||
|
...($userSettings.dock.pins ?? []),
|
||||||
|
pin,
|
||||||
|
]
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={iconOfLink(pin.url)} mini size="16" />
|
||||||
|
</Button>
|
||||||
|
<Material
|
||||||
|
slot="popover"
|
||||||
|
padding="none"
|
||||||
|
class="px-4 py-2 flex flex-col"
|
||||||
|
>
|
||||||
|
<span class="font-medium text-lg">{pin.label}</span>
|
||||||
|
<code class="!bg-zinc-950 !rounded-md">{pin.url}</code>
|
||||||
|
</Material>
|
||||||
|
</Popover>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</Setting>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section title={$t('settings.app.title')}>
|
<Section title={$t('settings.app.title')}>
|
||||||
|
|||||||
Reference in new issue
Block a user