-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from rainlanguage/2024-02-06-gui-shortened-ha…
…shes feat(tauri/ui): shorten hashes in list views
- Loading branch information
Showing
7 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts"> | ||
import { toasts } from "$lib/stores/toasts"; | ||
import { Tooltip } from 'flowbite-svelte'; | ||
import { WalletOutline, FingerprintOutline, ClipboardListOutline } from "flowbite-svelte-icons"; | ||
import { HashType } from "$lib/utils/hash"; | ||
export let value: string; | ||
export let type: HashType | undefined = undefined; | ||
export let shorten = true; | ||
export let sliceLen = 5; | ||
$: id = shorten ? `hash-${value}` : undefined; | ||
$: displayValue = value && shorten ? `${value.slice(0, sliceLen)}...${value.slice(-1 * sliceLen)}` : value; | ||
function copy() { | ||
navigator.clipboard.writeText(value); | ||
toasts.success("Copied to clipboard"); | ||
} | ||
</script> | ||
|
||
<button type="button" {id} class="inline-block flex justify-start items-center space-x-2" on:click|stopPropagation={copy}> | ||
{#if type === HashType.Wallet } | ||
<WalletOutline size="sm" /> | ||
{:else if type === HashType.Identifier } | ||
<FingerprintOutline size="sm" /> | ||
{:else if type === HashType.Transaction} | ||
<ClipboardListOutline size="sm" /> | ||
{/if} | ||
<div>{displayValue}</div> | ||
</button> | ||
|
||
{#if shorten} | ||
<Tooltip triggeredBy={`#${id}`} class="inline-block flex justify-start items-center space-x-2"> | ||
{#if type === HashType.Wallet } | ||
<WalletOutline size="sm" /> | ||
{:else if type === HashType.Identifier } | ||
<FingerprintOutline size="sm" /> | ||
{:else if type === HashType.Transaction} | ||
<ClipboardListOutline size="sm" /> | ||
{/if} | ||
<div>{value}</div> | ||
</Tooltip> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum HashType { | ||
Identifier, | ||
Wallet, | ||
Transaction, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters