feat: update ui

This commit is contained in:
reya
2024-07-28 20:23:54 +07:00
parent fe0864c0ee
commit c791ea802c
9 changed files with 178 additions and 50 deletions

View File

@@ -3,6 +3,7 @@ import { type ClassValue, clsx } from "clsx";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import updateLocale from "dayjs/plugin/updateLocale";
import { nip19 } from "nostr-tools";
import { twMerge } from "tailwind-merge";
import { commands } from "./commands";
@@ -29,6 +30,7 @@ export function cn(...inputs: ClassValue[]) {
export function npub(pubkey: string, len: number) {
if (pubkey.length <= len) return pubkey;
const npub = pubkey.startsWith("npub1") ? pubkey : nip19.npubEncode(pubkey);
const separator = " ... ";
const sepLen = separator.length;
@@ -37,9 +39,9 @@ export function npub(pubkey: string, len: number) {
const backChars = Math.floor(charsToShow / 2);
return (
pubkey.substring(0, frontChars) +
npub.substring(0, frontChars) +
separator +
pubkey.substring(pubkey.length - backChars)
npub.substring(npub.length - backChars)
);
}