feat: change navbar when PUBLIC_INSTANCE_URL is set

This commit is contained in:
Xyphyn committed 2023-07-31 15:42:15 -07:00
1 parent 783ecbcb5f
commit 6a5b01b1a8
5 files changed
+54 -14

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "0.4.15",
"version": "0.4.16",
"private": true,
"scripts": {
"dev": "vite dev",
+2 -4
View File
@@ -1,14 +1,12 @@
<script lang="ts">
export let href: string
export let highlight: boolean
export let highlight: boolean = false
</script>
<a
{href}
class="inline-flex flex-row gap-2 {highlight
? 'text-sky-500'
: ''} hover:underline"
class="{highlight ? 'text-sky-500' : ''} hover:underline"
{...$$restProps}
>
<slot name="icon" />
+43 -8
View File
@@ -8,7 +8,13 @@
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
import Menu from '$lib/components/ui/menu/Menu.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import { authData, instance, user } from '$lib/lemmy.js'
import {
LINKED_INSTANCE_URL,
authData,
instance,
site,
user,
} from '$lib/lemmy.js'
import {
ArrowLeftOnRectangle,
ArrowRightOnRectangle,
@@ -39,13 +45,42 @@
>
<div class="flex flex-row gap-2 items-center mr-auto">
<a href="/" class="flex flex-row items-center gap-2">
<Logo width={40} />
<div class="flex flex-row items-center gap-2 max-[500px]:hidden">
<span class="opacity-30 text-xl">/</span>
<span class="text-sm font-bold">
{$instance}
</span>
</div>
{#if LINKED_INSTANCE_URL}
{#if $site}
<Avatar
url={$site.site_view.site.icon}
alt={$site.site_view.site.name}
width={32}
/>
<div class="flex flex-row items-center gap-2 max-[500px]:hidden">
<span class="opacity-30 text-xl">/</span>
<div class="text-sm font-bold inline-flex flex-col">
<span>{$site.site_view.site.name}</span>
<span
class="font-normal text-xs flex items-center gap-1 text-slate-600 dark:text-zinc-400"
>
Powered by <Link
href="https://photon.xylight.dev"
highlight={false}
class="font-bold flex items-center gap-0.5 hover:underline"
>
<Logo width={12} /> Photon
</Link>
</span>
</div>
</div>
{:else}
<Spinner width={32} />
{/if}
{:else}
<Logo width={40} />
<div class="flex flex-row items-center gap-2 max-[500px]:hidden">
<span class="opacity-30 text-xl">/</span>
<span class="text-sm font-bold">
{$instance}
</span>
</div>
{/if}
</a>
</div>
<div class="flex flex-row gap-2 py-2 px-2">
+7
View File
@@ -39,6 +39,13 @@ export const authData = writable<AuthData | undefined>()
export const user = writable<(MyUserInfo & UserData) | undefined | null>(
undefined
)
export const site = writable<GetSiteResponse | undefined>(undefined)
if (LINKED_INSTANCE_URL) {
getClient(LINKED_INSTANCE_URL)
.getSite({})
.then((s) => site.set(s))
}
setInterval(async () => {
// check for unread messages
+1 -1
View File
@@ -3,7 +3,7 @@
// @ts-ignore
import { build, files } from '$service-worker'
const version = '0.4.15'
const version = '0.4.16'
const timestamp = new Date().toLocaleString('en')
const worker = self as unknown as ServiceWorkerGlobalScope
const FILES = `cache${timestamp}`