Merge pull request #300 from Xyphyn/dev

feat: redesign navigation
This commit is contained in:
Xylight authored and GitHub committed 2024-04-18 18:00:55 -07:00
commit c0ae38dd41
27 files changed
+488 -218

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "1.28.5",
"version": "1.29.0",
"private": true,
"scripts": {
"dev": "vite dev",
+2 -1
View File
@@ -16,6 +16,7 @@ import { get, writable } from 'svelte/store'
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
import type { ResumableItem } from './lemmy/item'
const getDefaultProfile = (): Profile => ({
id: -1,
@@ -42,7 +43,7 @@ export interface Profile {
user?: PersonData
username?: string
avatar?: string
favorites?: number[]
favorites?: ResumableItem[]
color?: string
}
@@ -16,6 +16,7 @@
import { vote as voteItem } from '$lib/lemmy/contentview'
import { shouldShowVoteColor } from '../post/PostVote.svelte'
import { fly } from 'svelte/transition'
import { backOut } from 'svelte/easing'
export let vote: number = 0
export let upvotes: number
@@ -48,8 +49,8 @@
{#key upvotes}
<span
style="grid-column: 1; grid-row: 1;"
in:fly={{ duration: 200, y: -6 }}
out:fly={{ duration: 200, y: 6 }}
in:fly={{ duration: 400, y: -10, easing: backOut }}
out:fly={{ duration: 400, y: 10, easing: backOut }}
>
<FormattedNumber number={upvotes} />
</span>
@@ -69,8 +70,8 @@
{#key downvotes}
<span
style="grid-column: 1; grid-row: 1;"
in:fly={{ duration: 200, y: -6 }}
out:fly={{ duration: 200, y: 6 }}
in:fly={{ duration: 400, y: -10, easing: backOut }}
out:fly={{ duration: 400, y: 10, easing: backOut }}
>
<FormattedNumber number={downvotes} />
</span>
@@ -17,6 +17,7 @@
import { profile } from '$lib/auth.js'
import { Button } from 'mono-svelte'
import { afterNavigate } from '$app/navigation'
import { backOut } from 'svelte/easing'
export let nodes: CommentNodeI[]
export let isParent: boolean
@@ -106,7 +107,7 @@
</script>
<ul
in:fly={{ opacity: 0, y: -4 }}
in:fly={{ opacity: 0, y: -4, duration: 400, easing: backOut }}
class={isParent
? 'divide-y dark:divide-zinc-800 divide-slate-100'
: 'pl-3.5 border-l border-slate-200 dark:border-zinc-800 my-1'}
+9 -2
View File
@@ -29,6 +29,13 @@
export let view = $userSettings.view
$: type = mediaType(post.post.url, view)
$: hideTitle =
$userSettings.posts.deduplicateEmbed &&
post.post.embed_title == post.post.name
$: hideBody =
$userSettings.posts.deduplicateEmbed &&
post.post.embed_description == post.post.body
</script>
<Material
@@ -62,7 +69,7 @@
? 'Subscribed'
: 'NotSubscribed'}
id={post.post.id}
title={post.post.name}
title={hideTitle ? undefined : post.post.name}
read={post.read}
style="grid-area: meta;"
>
@@ -77,7 +84,7 @@
{#if view == 'list' || view == 'compact'}
<PostMediaCompact {view} bind:post={post.post} style="grid-area: media;" />
{/if}
{#if post.post.body && !post.post.nsfw && view != 'compact'}
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody}
<PostBody body={post.post.body} {view} style="grid-area: body" />
{/if}
{#if actions}
@@ -43,7 +43,9 @@
</script>
<div
class="grid w-full meta {community ? 'grid-rows-2' : 'grid-rows-1'} text-xs"
class="grid w-full meta {community
? 'grid-rows-2'
: 'grid-rows-1'} text-xs min-w-0 max-w-full"
style={$$props.style ?? ''}
>
{#if community}
@@ -148,7 +150,7 @@
{#if title && id}
<a
href="/post/{getInstance()}/{id}"
class="font-medium text-base"
class="font-medium text-base w-full"
class:text-slate-600={$userSettings.markReadPosts && read}
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
style="grid-area: title;"
@@ -28,6 +28,7 @@
import { Button, Popover, buttonColor, toast } from 'mono-svelte'
import { site } from '$lib/lemmy.js'
import { fly } from 'svelte/transition'
import { backOut } from 'svelte/easing'
export let post: Post
export let vote: number = 0
@@ -69,8 +70,8 @@
{#key upvotes}
<span
style="grid-column: 1; grid-row: 1;"
in:fly={{ duration: 200, y: -6 }}
out:fly={{ duration: 200, y: 6 }}
in:fly={{ duration: 400, y: -10, easing: backOut }}
out:fly={{ duration: 400, y: 10, easing: backOut }}
>
<FormattedNumber number={upvotes} />
</span>
@@ -91,8 +92,8 @@
{#key downvotes}
<span
style="grid-column: 1; grid-row: 1;"
in:fly={{ duration: 200, y: -6 }}
out:fly={{ duration: 200, y: 6 }}
in:fly={{ duration: 400, y: -10, easing: backOut }}
out:fly={{ duration: 400, y: 10, easing: backOut }}
>
<FormattedNumber number={downvotes} />
</span>
@@ -0,0 +1,21 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { TextInput } from 'mono-svelte'
let query: string = ''
let loading = false
function search() {
loading = true
goto(`/search?q=${query}`).then(() => (loading = false))
}
</script>
<form on:submit|preventDefault={search} class="w-full h-full {$$props.class}">
<TextInput
bind:value={query}
class="w-full h-full {$$props.class}"
placeholder="Search"
/>
</form>
<slot {search} {loading} />
+5 -1
View File
@@ -112,10 +112,14 @@
@apply m-0 leading-[1.5] !important;
}
.markdown :global(li > *) {
.markdown :global(li > p) {
@apply m-0 leading-[1.5] !important;
}
.markdown :global(li > p) {
@apply contents !important;
}
.markdown :global(blockquote) {
@apply leading-[1px] border-l-2 border-slate-400 dark:border-zinc-600 pl-2 my-1 h-max;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<aside
class="sticky top-16 left-0 break-words flex flex-shrink
flex-col gap-4 p-6 max-w-full w-full h-full
class="sticky top-0 left-0 break-words flex flex-shrink
flex-col gap-4 px-6 pt-4 max-w-full w-full h-full
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {$$props.class}"
>
<slot />
+60 -13
View File
@@ -6,38 +6,85 @@
export let route: { id: string | null } | undefined = undefined
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : ''
const calculatePadding = (
panel: boolean,
top: boolean,
content: boolean
): string => {
if (panel) {
if (top) return '!pt-22'
else return '!pb-22'
} else {
if (!content) return ''
if (top) return '!pt-24'
else return '!pb-24'
}
return 'hi this is easter egg, my code broke'
}
$: contentPadding = calculatePadding(
$userSettings.dock.noGap,
$userSettings.dock.top,
true
)
$: sidePadding = calculatePadding(
$userSettings.dock.noGap,
$userSettings.dock.top,
false
)
</script>
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
<slot />
<slot
name="navbar"
class="sticky top-0 border-b border-slate-200 dark:border-zinc-900
bg-slate-50 dark:bg-zinc-950 transition-colors duration-500"
style="grid-area: navbar"
{title}
/>
<div
class="content md:divide-x divide-slate-200 dark:divide-zinc-900 {$userSettings.newWidth
class="content md:divide-x divide-slate-200 dark:divide-zinc-900 min-h-screen {$userSettings.newWidth
? 'limit-width'
: ''}"
>
<slot
name="sidebar"
class="hidden md:flex sticky top-16 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950"
class="hidden md:flex sticky top-0 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950
{sidePadding}"
style="grid-area: sidebar; width: 100% !important;"
/>
<slot
name="main"
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm"
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm
{contentPadding}"
style="grid-area: main"
/>
<slot
name="suffix"
class="max-xl:hidden w-full sticky top-16 left-0 h-full max-h-[calc(100svh-4rem)] bg-slate-50 dark:bg-zinc-950"
class="max-xl:hidden w-full sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950
{sidePadding}"
style="grid-area: suffix;"
/>
</div>
<div
class="
{$userSettings.dock.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
{$userSettings.dock.top ? 'top-0' : 'bottom-0'}
w-full fixed z-50 pointer-events-none"
style="grid-area: navbar;"
>
<slot
name="navbar"
class="
{$userSettings.dock.noGap
? $userSettings.dock.top
? 'border-b shadow-none'
: 'border-t'
: 'border rounded-full'}
border-slate-200 dark:border-zinc-800 shadow-2xl
backdrop-blur-xl dark:backdrop-brightness-[25%] bg-[#ffffff]/75 dark:bg-transparent transition-colors duration-500
pointer-events-auto"
style="grid-area: navbar"
{title}
/>
</div>
</div>
<style>
@@ -46,8 +93,8 @@
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
grid-template-areas:
'navbar'
'content';
'content'
'navbar';
}
.content {
+15 -5
View File
@@ -1,23 +1,33 @@
<script lang="ts">
import { page } from '$app/stores'
import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
export let label: string
export let icon: IconSource | undefined = undefined
export let href: string | undefined = undefined
$: isSelected = href != undefined && $page.url.pathname == href
</script>
<Button
color="tertiary"
{...$$restProps}
class="px-3 py-1.5 max-md:py-0 max-md:px-0 max-md:h-8 max-md:w-8 {$$props.class ??
''}"
on:click
class="rounded-full w-10 h-10 flex-shrink-0 {isSelected
? 'bg-slate-200 dark:bg-zinc-900 text-primary-900 dark:!text-primary-100'
: ''} {$$props.class ?? ''}"
size="custom"
{href}
rounding="pill"
title={label}
style="transition-property: background-color, filter;"
>
{#if icon}
<Icon src={icon} mini size="16" />
<Icon src={icon} solid={isSelected} size="18" />
{:else}
<slot name="icon" />
<slot {isSelected} name="icon" />
{/if}
<span class="max-md:hidden">{label}</span>
<!-- <span class="max-md:hidden">{label}</span> -->
<slot />
</Button>
+134 -67
View File
@@ -7,77 +7,156 @@
isAdmin,
} from '$lib/components/lemmy/moderation/moderation.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Logo from '$lib/components/ui/Logo.svelte'
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
import { site } from '$lib/lemmy.js'
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import {
GlobeAlt,
Home,
Icon,
MagnifyingGlass,
Newspaper,
PencilSquare,
Plus,
ServerStack,
XMark,
} from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
import Profile from './Profile.svelte'
import NavButton from './NavButton.svelte'
import { scale } from 'svelte/transition'
import { expoOut, backOut } from 'svelte/easing'
import { flip } from 'svelte/animate'
import SearchBar from '$lib/components/lemmy/util/SearchBar.svelte'
export let title: string | undefined = ''
let searching = false
</script>
<nav
class="flex flex-row gap-2 items-center
backdrop-blur-lg w-full mx-auto px-4 py-2 z-50 box-border h-16
class="flex flex-row gap-2 items-center w-full mx-auto z-50 box-border h-16
duration-150
{$$props.class}
"
style={$$props.style}
>
<div class="flex flex-row gap-2 items-center mr-auto">
<a
href="/"
class="flex flex-row items-center gap-2 logo group"
title="Home"
{#if searching}
<div
class="w-full h-full absolute z-20 p-2 flex items-center gap-2 bg-white dark:bg-zinc-950
rounded-full"
transition:scale={{
start: 0.96,
duration: 250,
easing: backOut,
}}
>
{#if LINKED_INSTANCE_URL}
{#if $site}
<Avatar
url={$site.site_view.site.icon}
alt={$site.site_view.site.name}
width={32}
res={64}
circle={false}
class="rounded-md"
/>
<div class="flex flex-row items-center gap-2 max-[500px]:hidden">
<span class="opacity-30 text-xl">/</span>
{$site.site_view.site.name}
<Button
size="custom"
rounding="pill"
class="w-11 h-11 flex-shrink-0"
on:click={() => (searching = false)}
>
<Icon src={XMark} size="18" mini />
</Button>
<SearchBar let:search let:loading class="!rounded-full z-20">
<Button
size="custom"
rounding="pill"
class="w-11 h-11 flex-shrink-0"
on:click={search}
color="primary"
type="submit"
{loading}
>
<Icon src={MagnifyingGlass} size="18" mini slot="prefix" />
</Button>
</SearchBar>
</div>
{/if}
<div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
<Profile
placement="top"
itemsClass="h-8 md:h-8 z-10"
targetClass="z-10 h-10"
containerClass="!max-h-[28rem] z-10"
buttonClass=""
/>
{#if $profile}
<div
class="px-2 border-r border-l border-slate-200 dark:border-zinc-900
flex flex-row items-center gap-2 [&>*]:flex-shrink-0 overflow-x-auto overflow-y-hidden
md:max-w-64 sm:max-w-48 max-w-36 w-full max-[424px]:hidden"
>
{#each $profile.favorites ?? [] as favorite (favorite.id)}
<div
class="h-10 w-10 flex"
transition:scale={{
start: 0.7,
easing: backOut,
duration: 400,
delay: 0,
}}
animate:flip={{
easing: backOut,
duration: 400,
delay: 0,
}}
>
<NavButton
class="w-full h-full bg-slate-100 dark:bg-zinc-900 relative"
title={favorite.name}
href={favorite.url.toString()}
label={favorite.name}
>
{#if favorite.type == 'post'}
<div
class="relative w-full h-full grid place-items-center overflow-visible"
>
{#if favorite.subdivision}
<Avatar
alt={favorite.subdivision.name}
url={favorite.subdivision.avatar}
width={32}
res={64}
class=""
/>
<Icon
src={PencilSquare}
mini
size="20"
class="absolute -bottom-1 -right-1 rounded-full bg-slate-100 dark:bg-zinc-900 p-0.5"
/>
{/if}
</div>
{:else}
<Avatar
alt={favorite.name}
url={favorite.avatar}
res={64}
width={32}
class="w-full"
/>
<Icon
src={Newspaper}
mini
size="20"
class="absolute -bottom-1 -right-1 rounded-full bg-slate-100 dark:bg-zinc-900 p-0.5"
/>
{/if}
</NavButton>
</div>
{:else}
<Spinner width={32} />
{/each}
</div>
{/if}
<div class="ml-auto" />
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
{/if}
{:else}
<Logo width={40} />
<div class="flex flex-row items-center gap-2 max-[1000px]:hidden">
<span class="opacity-30 text-xl">/</span>
<span class="text-sm font-bold grid place-items-start">
{#key title || $instance}
<span
in:fly={{ y: -12 }}
out:fly={{ y: 12 }}
style="grid-row: 1; grid-column: 1; max-width: 24ch;"
class="overflow-hidden break-words overflow-ellipsis whitespace-nowrap"
>
{title || $instance}
</span>
{/key}
</span>
</div>
{/if}
</a>
</div>
<div class="flex flex-row gap-2 py-2 px-2 items-center">
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
</NavButton>
{/if}
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
{#if $profile?.user && isAdmin($profile.user)}
<NavButton
href="/admin"
@@ -92,19 +171,13 @@
{/if}
</NavButton>
{/if}
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
{/if}
<ShieldIcon slot="icon" filled width={15} />
</NavButton>
{/if}
<NavButton href="/search" label="Search" icon={MagnifyingGlass} />
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
<Menu placement="bottom-end" targetClass="h-8">
<NavButton
on:click={() => (searching = true)}
label="Search"
icon={MagnifyingGlass}
/>
<NavButton href="/" label="Home" icon={Home} />
<Menu placement="top">
<NavButton
class="relative"
color="primary"
@@ -138,11 +211,5 @@
</span>
{/if}
</Menu>
<Profile
placement="bottom-end"
itemsClass="h-8 md:h-8 z-10"
targetClass="z-10 h-8"
containerClass="!max-h-[28rem] z-10"
/>
</div>
</nav>
+6 -4
View File
@@ -34,17 +34,19 @@
<Menu {...$$restProps}>
<button
class="w-8 h-8 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
class="w-10 h-10 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
transition-all bg-slate-50 dark:bg-zinc-900 relative
hover:dark:brightness-125 hover:brightness-95"
hover:dark:brightness-125 hover:brightness {$$props.buttonClass}"
aria-label="Profile"
slot="target"
>
{#if $profile?.user}
<div class="w-8 h-8 aspect-square object-cover rounded-full">
<div
class="w-10 h-10 aspect-square object-cover rounded-full grid place-items-center"
>
<Avatar
url={$profile.user.local_user_view.person.avatar}
width={32}
width={38}
alt={$profile.user.local_user_view.person.name}
/>
</div>
@@ -43,7 +43,7 @@
{index}
{guest}
selected={$profile?.id == prof.id}
slot="prefix"
slot="icon"
/>
<span
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}"
+27 -55
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import {
ArrowLeftOnRectangle,
Bookmark,
ChevronDoubleRight,
Cog6Tooth,
GlobeAlt,
@@ -10,6 +11,7 @@
Inbox,
MagnifyingGlass,
ServerStack,
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { profile, profileData } from '$lib/auth.js'
@@ -23,59 +25,29 @@
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
import Expandable from '$lib/components/ui/Expandable.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte'
export let route = ''
</script>
<nav
class="flex flex-col pl-4 pr-4 py-4 overflow-auto
gap-1 max-h-[calc(100svh-4rem)] {$$props.class}"
class="flex flex-col p-4 overflow-auto
gap-1 h-screen {$$props.class}"
style={$$props.style}
>
<Button
on:click={() =>
($userSettings.expandSidebar = !$userSettings.expandSidebar)}
size="square-md"
class="flex-shrink-0 lg:hidden"
>
<Icon src={ChevronDoubleRight} size="16" mini />
</Button>
<SidebarButton href="/" selected={route == '/'}>
<Icon src={Home} solid={route == '/'} size="20" title="Frontpage" />
<span slot="label">Frontpage</span>
</SidebarButton>
<SidebarButton href="/settings" selected={route == '/settings'}>
<Icon
src={Cog6Tooth}
solid={route == '/settings'}
size="20"
title="Settings"
/>
<span slot="label">Settings</span>
</SidebarButton>
<SidebarButton href="/search" selected={route == '/search'}>
<Icon solid={route == '/search'} src={MagnifyingGlass} size="20" />
<span slot="label">Search</span>
</SidebarButton>
<SidebarButton href="/communities" selected={route == '/communities'}>
<Icon solid={route == '/communities'} src={GlobeAlt} size="20" />
<span slot="label">Communities</span>
</SidebarButton>
{#if $profile?.jwt}
<SidebarButton href="/inbox" selected={route == '/inbox'}>
<Icon solid={route == '/inbox'} src={Inbox} size="20" />
<span slot="label" class="inline-flex items-center flex-1">
<span class="flex-shrink-0 flex-1">Inbox</span>
{#if ($profile?.user?.notifications.inbox ?? 0) > 0}
<Badge
color="red-subtle"
class="w-5 h-5 !p-0 grid place-items-center"
>
{$profile?.user?.notifications.inbox}
</Badge>
{/if}
</span>
{#if $profile}
<SidebarButton icon={UserCircle} href="/profile/user">
Profile
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
Inbox
{#if $profile?.user?.notifications.inbox}
<Badge
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
color="red-subtle"
>
{$profile?.user?.notifications.inbox}
</Badge>
{/if}
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">Saved</SidebarButton>
{/if}
{#if $profileData.profiles.length >= 1}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
@@ -93,8 +65,7 @@
}}
guest
/>
<SidebarButton href="/accounts" selected={route == '/accounts'}>
<Icon src={UserGroup} mini={route == '/accounts'} size="20" />
<SidebarButton href="/accounts" icon={UserGroup}>
<span slot="label">Accounts</span>
</SidebarButton>
{/if}
@@ -122,17 +93,18 @@
<CommunityList items={$profile.user.follows.map((i) => i.community)} />
</Expandable>
{:else}
<SidebarButton href="/login" title="Log In">
<Icon mini src={ArrowLeftOnRectangle} size="20" />
<SidebarButton href="/login" title="Log In" icon={ArrowLeftOnRectangle}>
<span slot="label">Log In</span>
</SidebarButton>
<SidebarButton href="/signup" title="Sign Up">
<Icon mini src={Identification} size="20" />
<SidebarButton href="/signup" title="Sign Up" icon={Identification}>
<span slot="label">Sign Up</span>
</SidebarButton>
{#if LINKED_INSTANCE_URL === undefined}
<SidebarButton href="/accounts" title="Change Instance">
<Icon mini src={ServerStack} size="20" />
<SidebarButton
href="/accounts"
title="Change Instance"
icon={ServerStack}
>
<span slot="label">Change Instance</span>
</SidebarButton>
{/if}
@@ -1,12 +1,22 @@
<script lang="ts">
import { page } from '$app/stores'
import { userSettings } from '$lib/settings.js'
import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
export let selected: boolean = false
export let href: string | undefined = undefined
export let icon: IconSource | undefined = undefined
export let selected = false
$: {
if (href != undefined) {
selected = $page.url.pathname == href
}
}
</script>
<Button
{...$$restProps}
{href}
color="tertiary"
alignment="left"
on:click
@@ -16,7 +26,11 @@
? ''
: 'max-lg:!p-1 [&>*]:max-lg:!justify-center'} {$$props.class}"
>
<slot name="prefix" slot="prefix" />
<slot {selected} name="icon" slot="prefix">
{#if icon}
<Icon src={icon} solid={selected} size="20" />
{/if}
</slot>
<slot />
<div class={$userSettings.expandSidebar ? 'contents' : 'max-lg:hidden'}>
<slot name="label" />
@@ -6,6 +6,6 @@
}
</script>
<span>
<span class={$$props.class ?? ''}>
{Intl.NumberFormat(locale, options).format(number)}
</span>
+29
View File
@@ -1,3 +1,4 @@
import { profile } from '$lib/auth'
import type {
CommentReportView,
CommentView,
@@ -10,6 +11,7 @@ import type {
PrivateMessageReportView,
PrivateMessageView,
} from 'lemmy-js-client'
import { get } from 'svelte/store'
export type Result =
| PostView
@@ -66,3 +68,30 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
export const isPrivateMessageReport = (
item: Result
): item is PrivateMessageReportView => 'private_message_report' in item
export interface ResumableItem {
url: URL
id: number
name: string
avatar?: string
type: 'community' | 'post'
subdivision?: {
avatar?: string
name: string
}
}
export function addResumable(item: ResumableItem) {
const p = get(profile)
if (!p) return
let favs = p.favorites ?? []
if (favs.map((fav) => fav.url.toString()).includes(item.url.toString()))
return
if (favs.length >= 5) favs.pop()
favs.unshift(item)
profile.update(() => ({
...p,
favorites: favs
}))
}
+14
View File
@@ -81,6 +81,13 @@ interface Settings {
clickToView: boolean
youtube: 'youtube' | 'invidious' | 'piped'
}
dock: {
noGap: boolean
top: boolean
}
posts: {
deduplicateEmbed: boolean
}
}
export const defaultSettings: Settings = {
@@ -135,6 +142,13 @@ export const defaultSettings: Settings = {
embeds: {
clickToView: true,
youtube: 'youtube',
},
dock: {
noGap: false,
top: false
},
posts: {
deduplicateEmbed: true
}
}
+13 -11
View File
@@ -11,6 +11,7 @@
import {
colors,
colorsToVars,
defaultColors,
inDarkLegacyTheme,
legacyTheme,
} from '$lib/ui/colors.js'
@@ -73,8 +74,8 @@
<meta
name="theme-color"
content={darklegacyTheme
? $colors?.zinc?.[950] ?? '#09090b'
: $colors?.slate?.[50] ?? '#f8fafc'}
? $colors?.zinc?.[925] ?? defaultColors.zinc[925]
: $colors?.slate?.[25] ?? defaultColors.slate[25]}
/>
{#if $site}
<title>{$site.site_view.site.name}</title>
@@ -108,14 +109,6 @@
<ExpandableImage />
<ModalContainer />
<Navbar
slot="navbar"
let:style={s}
let:class={c}
class={c}
style={s}
{title}
/>
<Sidebar
route={$page.route.id ?? ''}
slot="sidebar"
@@ -128,13 +121,21 @@
slot="main"
let:style={s}
let:class={c}
class="p-3 sm:p-6 min-w-0 w-full flex flex-col min-h-full relative {c}"
class="p-4 sm:p-6 min-w-0 w-full flex flex-col min-h-full relative {c}"
style={s}
class:max-w-6xl={$userSettings.newWidth}
id="main"
>
<slot />
</main>
<Navbar
slot="navbar"
let:style={s}
let:class={c}
class={c}
style={s}
{title}
/>
<div slot="suffix" let:class={c} let:style={s} class={c} style={s}>
{#if $page.data.slots?.sidebar?.component}
<svelte:component
@@ -148,6 +149,7 @@
taglines={$site.taglines}
admins={$site.admins}
version={$site.version}
class="pt-4"
/>
{:else}
<div class="h-64 w-full grid place-items-center">
+6 -4
View File
@@ -14,6 +14,7 @@
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
import { feature } from '$lib/version.js'
import { userSettings } from '$lib/settings.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
export let data
@@ -91,10 +92,11 @@
>
<span class="flex flex-row items-center gap-1">
<Icon src={ChartBar} size="16" mini />
<span class="font-medium text-black dark:text-white">
{$site?.site_view.counts.users_active_day}
</span>
<span class="font-normal">Active users</span>
<FormattedNumber
number={$site?.site_view.counts.users_active_day ?? 0}
class="text-black dark:text-white font-medium"
/>
<span class="font-normal">active users</span>
</span>
</Pageination>
</div>
+21 -12
View File
@@ -22,6 +22,7 @@
import { Button, TextInput } from 'mono-svelte'
import {
ArrowLeftOnRectangle,
ArrowRightOnRectangle,
ArrowUturnLeft,
BugAnt,
Check,
@@ -251,14 +252,22 @@
<Button size="square-md" slot="target">
<Icon src={EllipsisHorizontal} mini size="16" slot="prefix" />
</Button>
<MenuButton on:click={() => moveProfile(profile.id, true)}>
<Icon src={ChevronUp} size="16" mini slot="prefix" />
Move Up
</MenuButton>
<MenuButton on:click={() => moveProfile(profile.id, false)}>
<Icon src={ChevronDown} size="16" mini slot="prefix" />
Move Down
</MenuButton>
<div class="px-4 py-2 flex items-center gap-2">
<Button
size="square-md"
color="secondary"
on:click={() => moveProfile(profile.id, true)}
>
<Icon src={ChevronUp} size="16" mini slot="prefix" />
</Button>
<Button
size="square-md"
color="secondary"
on:click={() => moveProfile(profile.id, false)}
>
<Icon src={ChevronDown} size="16" mini slot="prefix" />
</Button>
</div>
<MenuButton
disabled={!profile.color}
on:click={() => (profile.color = undefined)}
@@ -278,8 +287,8 @@
</MenuButton>
{/if}
<MenuButton on:click={() => action(profile)} color="danger-subtle">
<Icon slot="prefix" src={Trash} size="16" mini />
Delete
<Icon slot="prefix" src={ArrowRightOnRectangle} size="16" mini />
Log Out
</MenuButton>
</Menu>
</div>
@@ -324,8 +333,8 @@
</Button>
</div>
<Button href="/login" size="lg">
<Icon slot="prefix" src={Plus} size="16" mini />
Add more
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
Log In
</Button>
</div>
{/if}
+13
View File
@@ -21,6 +21,7 @@
} from 'svelte-hero-icons'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { profile } from '$lib/auth'
import { addResumable } from '$lib/lemmy/item.js'
export let data
@@ -34,6 +35,18 @@
)
})
afterNavigate(() => {
if ($profile) {
addResumable({
avatar: data.community.community_view.community.icon,
id: data.community.community_view.community.id,
url: $page.url,
name: data.community.community_view.community.title,
type: 'community',
})
}
})
onDestroy(() => {
if (browser) {
if ($navigating?.to?.route?.id == '/create/post') return
@@ -46,9 +46,14 @@
import { feature } from '$lib/version.js'
import { publishedToDate } from '$lib/components/util/date.js'
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import { mediaType } from '$lib/components/lemmy/post/helpers.js'
import {
bestImageURL,
mediaType,
optimizeImageURL,
} from '$lib/components/lemmy/post/helpers.js'
import Post from '$lib/components/lemmy/post/Post.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import { addResumable } from '$lib/lemmy/item.js'
export let data
@@ -80,6 +85,21 @@
duration: 9999 * 1000,
})
}
if ($profile) {
addResumable({
avatar: post.post_view.post.thumbnail_url
? optimizeImageURL(post.post_view.post.thumbnail_url, 64)
: undefined,
id: post.post_view.post.id,
url: $page.url,
name: post.post_view.post.name,
type: 'post',
subdivision: {
name: post.post_view.community.name,
avatar: post.post_view.community.icon,
},
})
}
})
const fetchOnHome = async (jwt: string) => {
+52 -24
View File
@@ -47,9 +47,39 @@
</h1>
<div class="flex flex-col gap-4" style="scroll-behavior: smooth;">
<Section title="Navigation">
<div>
<Button
color="ghost"
on:click={() => {
$userSettings.dock.noGap = true
$userSettings.dock.top = true
}}
disabled={$userSettings.dock.noGap && $userSettings.dock.top}
>
Legacy Navigation Style
</Button>
</div>
<Setting>
<span slot="title">Dock alignment</span>
<span slot="description">Where the dock should be put</span>
<MultiSelect
options={[true, false]}
optionNames={['Top', 'Bottom']}
bind:selected={$userSettings.dock.top}
/>
</Setting>
<ToggleSetting
bind:checked={$userSettings.dock.noGap}
title="Panel mode"
description="Extend the dock to screen edges, similar to a panel."
/>
</Section>
<Section title="Photon">
<Setting>
<span slot="title">Theming</span>
<span slot="description">Customize Photon's colors.</span>
<Button href="/theme">
Go to themes <Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
@@ -126,12 +156,17 @@
/>
<ToggleSetting
bind:checked={$userSettings.expandImages}
title="Expand Images"
title="Expand images"
description="Clicking on a post's image brings you to an expanded view rather than
sending you to the post page."
/>
<ToggleSetting
bind:checked={$userSettings.posts.deduplicateEmbed}
title="Hide duplicate titles/bodies"
description="Hides the post title and body if they're the same as the embed."
/>
<Setting>
<span slot="title">Thumbnail Alignment</span>
<span slot="title">Thumbnail alignment</span>
<span slot="description">
Where thumbnails should be on the post in list/compact view.
</span>
@@ -141,19 +176,12 @@
bind:selected={$userSettings.leftAlign}
/>
</Setting>
{#if LINKED_INSTANCE_URL}
<ToggleSetting
title={'Remove "Powered by Photon"'}
description="Remove the massive 120x16 div in the top left corner."
bind:checked={$userSettings.hidePhoton}
/>
{/if}
</Section>
<Section title="Embeds">
<ToggleSetting
title="Click to view"
description="Before loading embeds, click. (It is recommended to leave this on, to not load a video you don't want to load.)"
description="Don't load an embed until you click it. (It is recommended to leave this on, to not load a video you don't want to load.)"
bind:checked={$userSettings.embeds.clickToView}
/>
<Setting>
@@ -167,6 +195,15 @@
<option value="piped">Piped</option>
</Select>
</Setting>
<Setting>
<span slot="title">Font</span>
<span slot="description">What font Photon should use.</span>
<MultiSelect
options={['inter', 'system', 'browser']}
optionNames={['Inter', 'System UI', 'Browser Font']}
bind:selected={$userSettings.font}
/>
</Setting>
</Section>
<Section title="Lemmy">
@@ -185,11 +222,6 @@
title="'Crossposted from' when crossposting"
description="If enabled, crossposts will include a link to the original post."
/>
<ToggleSetting
bind:checked={$userSettings.nsfwBlur}
title="NSFW blur"
description="Blur images and remove post bodies of NSFW content."
/>
<Setting>
<span slot="title">Hide Submissions</span>
<span slot="description">
@@ -212,15 +244,11 @@
</Checkbox>
</div>
</Setting>
<Setting>
<span slot="title">Font</span>
<span slot="description">What font Photon should use.</span>
<MultiSelect
options={['inter', 'system', 'browser']}
optionNames={['Inter', 'System UI', 'Browser Font']}
bind:selected={$userSettings.font}
/>
</Setting>
<ToggleSetting
bind:checked={$userSettings.nsfwBlur}
title="NSFW blur"
description="Blur images and remove post bodies of content tagged NSFW."
/>
<Setting>
<span slot="title">Show instances</span>
<span slot="description">Show items' instances.</span>
+3
View File
@@ -18,6 +18,9 @@ export default {
animation: {
'pop-in': 'pop-in 0.25s ease-out forwards',
},
spacing: {
'22': '88px'
},
keyframes: {
'pop-in': {
'0%, 100%': { transform: 'translateX(8px)', opacity: 0 },