-
Notifications
You must be signed in to change notification settings - Fork 1
/
IdentifierLink.svelte
44 lines (39 loc) · 1.15 KB
/
IdentifierLink.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!--
Copyright © 2022 The Radicle Design System Contributors
This file is part of radicle-design-system, distributed under the GPLv3
with Radicle Linking Exception. For full terms see the included
LICENSE file.
-->
<script lang="ts">
import { unreachable } from "./lib/unreachable";
import * as format from "./lib/format";
import CommitIcon from "./icons/Commit.svelte";
import EthereumIcon from "./icons/Ethereum.svelte";
export let params:
| { type: "commitHash"; hash: string; onClick: () => void }
| { type: "transactionHash"; hash: string; url: string };
export let showIcon: boolean = false;
</script>
<style>
a,
span {
color: var(--color-foreground-level-6);
}
</style>
<div style="display: flex;">
{#if params.type === "commitHash"}
{#if showIcon}
<CommitIcon />
{/if}
<span class="typo-link" on:click={params.onClick}>
{format.shortCommitHash(params.hash)}
</span>
{:else if params.type === "transactionHash"}
{#if showIcon}
<EthereumIcon />
{/if}
<a class="typo-link" href={params.url}>{format.shortEthTx(params.hash)}</a>
{:else}
{unreachable(params)}
{/if}
</div>