your personal website on atproto - mirror
blento.app
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
11 let { data }: { data: WebsiteData } = $props();
12
13 const isOwnPage = $derived(user.isLoggedIn && user.profile?.did === data.did);
14 const isBlento = $derived(!env.PUBLIC_IS_SELFHOSTED && data.handle === 'blento.app');
15 const isEditPage = $derived(page.url.pathname.endsWith('/edit'));
16 const showLoginOnBlento = $derived(
17 isBlento && !user.isInitializing && !user.isLoggedIn && user.profile?.handle !== data.handle
18 );
19 const showLoginOnEditPage = $derived(isEditPage && !user.isInitializing && !user.isLoggedIn);
20 const showEditBlentoButton = $derived(
21 isBlento && user.isLoggedIn && user.profile?.handle !== data.handle
22 );
23</script>
24
25{#if isOwnPage && !isEditPage}
26 <div class="fixed bottom-6 left-6 z-49 hidden lg:block">
27 <Button size="lg" href="{page.url}/edit">
28 <svg
29 xmlns="http://www.w3.org/2000/svg"
30 fill="none"
31 viewBox="0 0 24 24"
32 stroke-width="1.5"
33 stroke="currentColor"
34 class="size-5"
35 >
36 <path
37 stroke-linecap="round"
38 stroke-linejoin="round"
39 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"
40 />
41 </svg>
42 Edit Website
43 </Button>
44 </div>
45{:else if showLoginOnEditPage}
46 <div class="fixed bottom-6 left-6 z-49">
47 <Button size="lg" onclick={() => login(data.handle as ActorIdentifier)}>
48 <svg
49 xmlns="http://www.w3.org/2000/svg"
50 fill="none"
51 viewBox="0 0 24 24"
52 stroke-width="1.5"
53 stroke="currentColor"
54 class="size-5"
55 >
56 <path
57 stroke-linecap="round"
58 stroke-linejoin="round"
59 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"
60 />
61 </svg>
62 Login
63 </Button>
64 </div>
65{:else if showLoginOnBlento}
66 <div class="fixed bottom-6 left-6 z-49">
67 <Button size="lg" onclick={() => loginModalState.show()}>Login</Button>
68 </div>
69{:else if showEditBlentoButton}
70 <div class="fixed bottom-6 left-6 z-49">
71 <Button size="lg" href="/{env.PUBLIC_IS_SELFHOSTED ? '' : user.profile?.handle}/edit">
72 <svg
73 xmlns="http://www.w3.org/2000/svg"
74 fill="none"
75 viewBox="0 0 24 24"
76 stroke-width="1.5"
77 stroke="currentColor"
78 class="size-5"
79 >
80 <path
81 stroke-linecap="round"
82 stroke-linejoin="round"
83 d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25"
84 />
85 </svg>
86 Edit Your Blento
87 </Button>
88 </div>
89{/if}