your personal website on atproto - mirror blento.app
at remove-extra-buttons 95 lines 3.2 kB view raw
1<script lang="ts"> 2 import { user, login } from '$lib/atproto'; 3 import { Button } from '@foxui/core'; 4 import { BlueskyLogin } from '@foxui/social'; 5 import { env } from '$env/dynamic/public'; 6 import type { WebsiteData } from '$lib/types'; 7 import { page } from '$app/state'; 8 import type { ActorIdentifier } from '@atcute/lexicons'; 9 import { loginModalState } from '$lib/atproto/UI/LoginModal.svelte'; 10 import { getHandleOrDid } from '$lib/atproto/methods'; 11 12 let { data }: { data: WebsiteData } = $props(); 13 14 const isOwnPage = $derived(user.isLoggedIn && user.profile?.did === data.did); 15 const isBlento = $derived(!env.PUBLIC_IS_SELFHOSTED && data.handle === 'blento.app'); 16 const isEditPage = $derived(page.url.pathname.endsWith('/edit')); 17 const showLoginOnBlento = $derived( 18 isBlento && !user.isInitializing && !user.isLoggedIn && user.profile?.handle !== data.handle 19 ); 20 const showLoginOnEditPage = $derived(isEditPage && !user.isInitializing && !user.isLoggedIn); 21 const showEditBlentoButton = $derived( 22 isBlento && user.isLoggedIn && user.profile?.handle !== data.handle 23 ); 24 25 function getUserIdentifier(): ActorIdentifier { 26 const id = user.profile ? getHandleOrDid(user.profile) : (data.did as ActorIdentifier); 27 return id; 28 } 29</script> 30 31{#if isOwnPage && !isEditPage} 32 <div class="fixed bottom-6 left-6 z-49 hidden lg:block"> 33 <Button size="lg" href="{page.url}/edit"> 34 <svg 35 xmlns="http://www.w3.org/2000/svg" 36 fill="none" 37 viewBox="0 0 24 24" 38 stroke-width="1.5" 39 stroke="currentColor" 40 class="size-5" 41 > 42 <path 43 stroke-linecap="round" 44 stroke-linejoin="round" 45 d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" 46 /> 47 </svg> 48 Edit Website 49 </Button> 50 </div> 51{:else if showLoginOnEditPage} 52 <div class="fixed bottom-6 left-6 z-49"> 53 <Button size="lg" onclick={() => login(getUserIdentifier())}> 54 <svg 55 xmlns="http://www.w3.org/2000/svg" 56 fill="none" 57 viewBox="0 0 24 24" 58 stroke-width="1.5" 59 stroke="currentColor" 60 class="size-5" 61 > 62 <path 63 stroke-linecap="round" 64 stroke-linejoin="round" 65 d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" 66 /> 67 </svg> 68 Login 69 </Button> 70 </div> 71{:else if showLoginOnBlento} 72 <div class="fixed bottom-6 left-6 z-49"> 73 <Button size="lg" onclick={() => loginModalState.show()}>Login</Button> 74 </div> 75{:else if showEditBlentoButton} 76 <div class="fixed bottom-6 left-6 z-49"> 77 <Button size="lg" href="/{env.PUBLIC_IS_SELFHOSTED ? '' : getUserIdentifier()}/edit"> 78 <svg 79 xmlns="http://www.w3.org/2000/svg" 80 fill="none" 81 viewBox="0 0 24 24" 82 stroke-width="1.5" 83 stroke="currentColor" 84 class="size-5" 85 > 86 <path 87 stroke-linecap="round" 88 stroke-linejoin="round" 89 d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" 90 /> 91 </svg> 92 Edit Your Blento 93 </Button> 94 </div> 95{/if}