your personal website on atproto - mirror blento.app
at theme-colors 101 lines 3.4 kB view raw
1<script lang="ts"> 2 import Card from '../cards/Card/Card.svelte'; 3 import Profile from './Profile.svelte'; 4 import { 5 getDescription, 6 getHideProfileSection, 7 getProfilePosition, 8 getName, 9 sortItems 10 } from '../helper'; 11 import { innerWidth } from 'svelte/reactivity/window'; 12 import { setDidContext, setHandleContext, setIsMobile } from './context'; 13 import BaseCard from '../cards/BaseCard/BaseCard.svelte'; 14 import type { WebsiteData } from '$lib/types'; 15 import Context from './Context.svelte'; 16 import MadeWithBlento from './MadeWithBlento.svelte'; 17 import Head from './Head.svelte'; 18 import type { Did, Handle } from '@atcute/lexicons'; 19 import QRModalProvider from '$lib/components/qr/QRModalProvider.svelte'; 20 import EmptyState from './EmptyState.svelte'; 21 import FloatingEditButton from './FloatingEditButton.svelte'; 22 import { user } from '$lib/atproto'; 23 import { env } from '$env/dynamic/public'; 24 import { page } from '$app/state'; 25 26 let { data }: { data: WebsiteData } = $props(); 27 28 // Check if floating edit button will be visible (to hide MadeWithBlento) 29 const isOwnPage = $derived(user.isLoggedIn && user.profile?.did === data.did); 30 const isBlento = $derived(!env.PUBLIC_IS_SELFHOSTED && data.handle === 'blento.app'); 31 const isEditPage = $derived(page.url.pathname.endsWith('/edit')); 32 const showLoginOnEditPage = $derived(isEditPage && !user.isInitializing && !user.isLoggedIn); 33 const showFloatingButton = $derived( 34 (isOwnPage && !isEditPage) || 35 showLoginOnEditPage || 36 (isBlento && !user.isInitializing && !user.isLoggedIn) || 37 (isBlento && user.isLoggedIn && user.profile?.handle !== data.handle) 38 ); 39 40 let isMobile = $derived((innerWidth.current ?? 1000) < 1024); 41 setIsMobile(() => isMobile); 42 43 // svelte-ignore state_referenced_locally 44 setDidContext(data.did as Did); 45 // svelte-ignore state_referenced_locally 46 setHandleContext(data.handle as Handle); 47 48 let maxHeight = $derived( 49 data.cards.reduce( 50 (max, item) => Math.max(max, isMobile ? item.mobileY + item.mobileH : item.y + item.h), 51 0 52 ) 53 ); 54 55 let container: HTMLDivElement | undefined = $state(); 56</script> 57 58<Head 59 favicon={data.profile.avatar ?? null} 60 title={getName(data)} 61 image={'/' + data.handle + '/og.png'} 62 description={getDescription(data)} 63 accentColor={data.publication?.preferences?.accentColor} 64 baseColor={data.publication?.preferences?.baseColor} 65/> 66 67<Context {data}> 68 <QRModalProvider /> 69 <div class="@container/wrapper relative w-full"> 70 {#if !getHideProfileSection(data)} 71 <Profile {data} hideBlento={showFloatingButton} /> 72 {/if} 73 74 <div 75 class={[ 76 'mx-auto max-w-lg', 77 !getHideProfileSection(data) && getProfilePosition(data) === 'side' 78 ? '@5xl/wrapper:grid @5xl/wrapper:max-w-7xl @5xl/wrapper:grid-cols-4' 79 : '@5xl/wrapper:max-w-4xl' 80 ]} 81 > 82 <div></div> 83 <div bind:this={container} class="@container/grid relative col-span-3 px-2 py-8 lg:px-8"> 84 {#if data.cards.length === 0 && data.page === 'blento.self'} 85 <EmptyState {data} /> 86 {:else} 87 {#each data.cards.toSorted(sortItems) as item (item.id)} 88 <BaseCard {item}> 89 <Card {item} /> 90 </BaseCard> 91 {/each} 92 <div style="height: {(maxHeight / 8) * 100}cqw;"></div> 93 {/if} 94 </div> 95 </div> 96 97 <MadeWithBlento class="mx-auto block pb-8 text-center @5xl/wrapper:hidden" /> 98 </div> 99 100 <FloatingEditButton {data} /> 101</Context>