Skip to content

Commit

Permalink
feat(app): highlight tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
cor committed Jan 24, 2025
1 parent a67905c commit 0fefc65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions app/src/lib/components/token.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { formatUnits } from "viem"
import { onMount } from "svelte"
import { tokenInfoQuery } from "$lib/queries/tokens"
import LoadingDots from "./loading-dots.svelte"
import { highlightItem } from "$lib/stores/highlight"
import { cn } from "$lib/utilities/shadcn"
export let chains: Array<Chain>
export let chainId: string
Expand All @@ -23,13 +25,20 @@ $: tokenInfo = tokenInfoQuery(chainId, denom.toLowerCase(), chains)

{#if $tokenInfo.data}
{@const token = $tokenInfo.data}
<div>
<!-- svelte-ignore a11y-interactive-supports-focus -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="flex flex-col gap-1"
on:mouseleave={() => highlightItem.set(null)}
on:mouseenter={() => {
highlightItem.set(denom ? { kind: "token", denom} : null)
}}>
<div class="flex gap-1 items-center">
<TokenQualityLevel level={token.graphql != null ? "GRAPHQL" : token.onchain != null ? "ONCHAIN" : "NONE"} />
{#if amount !== null}
{formatUnits(BigInt(amount), token.combined.decimals)}
{/if}
<b><Truncate value={token.combined.symbol} type="symbol"/></b>
<span class={cn("inline-flex gap-1 transition-colors", $highlightItem?.kind === "token" && $highlightItem.denom === denom ? "bg-union-accent-300 dark:bg-union-accent-950" : "")}><b><Truncate value={token.combined.symbol} type="symbol"/></b>
<div class="text-muted-foreground text-xs flex gap-1 items-center">
{toDisplayName(chainId, chains)}
{#each token.combined.wrapping as wrapping}
Expand All @@ -38,7 +47,7 @@ $: tokenInfo = tokenInfoQuery(chainId, denom.toLowerCase(), chains)
chains,
)}
{/each}
</div>
</div></span>
</div>
{#if expanded}
<div class="text-xs flex flex-col gap gap-4 text-muted-foreground">
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/stores/highlight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writable, type Writable } from "svelte/store"

type HighlightItem = { kind: "address"; address: string } | null
type HighlightItem = { kind: "address"; address: string } | { kind: "token"; denom: string } | null
export const highlightItem: Writable<HighlightItem> = writable(null)

0 comments on commit 0fefc65

Please sign in to comment.