your personal website on atproto - mirror blento.app
at improve-saving 81 lines 2.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 22 let { data }: { data: WebsiteData } = $props(); 23 24 let isMobile = $derived((innerWidth.current ?? 1000) < 1024); 25 setIsMobile(() => isMobile); 26 27 // svelte-ignore state_referenced_locally 28 setDidContext(data.did as Did); 29 // svelte-ignore state_referenced_locally 30 setHandleContext(data.handle as Handle); 31 32 let maxHeight = $derived( 33 data.cards.reduce( 34 (max, item) => Math.max(max, isMobile ? item.mobileY + item.mobileH : item.y + item.h), 35 0 36 ) 37 ); 38 39 let container: HTMLDivElement | undefined = $state(); 40</script> 41 42<Head 43 favicon={data.profile.avatar ?? null} 44 title={getName(data)} 45 image={'/' + data.handle + '/og.png'} 46 description={getDescription(data)} 47/> 48 49<Context {data}> 50 <QRModalProvider /> 51 <div class="@container/wrapper relative w-full"> 52 {#if !getHideProfileSection(data)} 53 <Profile {data} showEditButton={true} /> 54 {/if} 55 56 <div 57 class={[ 58 'mx-auto max-w-lg', 59 !getHideProfileSection(data) && getProfilePosition(data) === 'side' 60 ? '@5xl/wrapper:grid @5xl/wrapper:max-w-7xl @5xl/wrapper:grid-cols-4' 61 : '@5xl/wrapper:max-w-4xl' 62 ]} 63 > 64 <div></div> 65 <div bind:this={container} class="@container/grid relative col-span-3 px-2 py-8 lg:px-8"> 66 {#if data.cards.length === 0} 67 <EmptyState {data} /> 68 {:else} 69 {#each data.cards.toSorted(sortItems) as item (item.id)} 70 <BaseCard {item}> 71 <Card {item} /> 72 </BaseCard> 73 {/each} 74 <div style="height: {(maxHeight / 8) * 100}cqw;"></div> 75 {/if} 76 </div> 77 </div> 78 79 <MadeWithBlento class="mx-auto block pb-8 text-center @5xl/wrapper:hidden" /> 80 </div> 81</Context>