mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
53 lines
1.3 KiB
Svelte
53 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import Avatar from "@app/Avatar.svelte";
|
|
import type { Seed } from "@app/base/seeds/Seed";
|
|
import type { Config } from "@app/config";
|
|
import { signInWithEthereum } from "@app/siwe";
|
|
import Loading from "@app/Loading.svelte";
|
|
import { Connection } from "@app/session";
|
|
import Button from "@app/Button.svelte";
|
|
|
|
export let seed: Seed;
|
|
export let config: Config;
|
|
export let caption = "Sign in";
|
|
export let tooltip = "";
|
|
export let disabled = false;
|
|
export let address: string | null = null;
|
|
|
|
let connection: Connection = Connection.Disconnected;
|
|
</script>
|
|
|
|
<style>
|
|
.align {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
}
|
|
</style>
|
|
|
|
<Button
|
|
variant="secondary"
|
|
size="small"
|
|
title={tooltip}
|
|
disabled={disabled || connection === Connection.Connecting}
|
|
on:click={async () => {
|
|
connection = Connection.Connecting;
|
|
try {
|
|
await signInWithEthereum(seed, config);
|
|
} catch (e) {
|
|
console.error("Sign in", e);
|
|
connection = Connection.Disconnected;
|
|
}
|
|
}}>
|
|
<span class="align">
|
|
{#if address}
|
|
<Avatar title={address} source={address} inline />
|
|
{/if}
|
|
{#if connection === Connection.Connecting}
|
|
<Loading small />
|
|
{:else}
|
|
{caption}
|
|
{/if}
|
|
</span>
|
|
</Button>
|