your personal website on atproto - mirror blento.app
at signup 99 lines 3.3 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/> 64 65<Context {data}> 66 <QRModalProvider /> 67 <div class="@container/wrapper relative w-full"> 68 {#if !getHideProfileSection(data)} 69 <Profile {data} hideBlento={showFloatingButton} /> 70 {/if} 71 72 <div 73 class={[ 74 'mx-auto max-w-lg', 75 !getHideProfileSection(data) && getProfilePosition(data) === 'side' 76 ? '@5xl/wrapper:grid @5xl/wrapper:max-w-7xl @5xl/wrapper:grid-cols-4' 77 : '@5xl/wrapper:max-w-4xl' 78 ]} 79 > 80 <div></div> 81 <div bind:this={container} class="@container/grid relative col-span-3 px-2 py-8 lg:px-8"> 82 {#if data.cards.length === 0 && data.page === 'blento.self'} 83 <EmptyState {data} /> 84 {:else} 85 {#each data.cards.toSorted(sortItems) as item (item.id)} 86 <BaseCard {item}> 87 <Card {item} /> 88 </BaseCard> 89 {/each} 90 <div style="height: {(maxHeight / 8) * 100}cqw;"></div> 91 {/if} 92 </div> 93 </div> 94 95 <MadeWithBlento class="mx-auto block pb-8 text-center @5xl/wrapper:hidden" /> 96 </div> 97 98 <FloatingEditButton {data} /> 99</Context>