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