feat: polish

This commit is contained in:
2024-01-13 20:24:52 +07:00
parent 72870bb131
commit ab27bd5f44
11 changed files with 70 additions and 64 deletions

View File

@@ -552,9 +552,11 @@ export class Ark {
if (!res.ok) throw new Error(`Failed to fetch NIP-05 service: ${nip05}`);
const data: NIP05 = await res.json();
if (!data.names) return false;
if (data.names[localPath.toLowerCase()] === pubkey) return true;
if (data.names[localPath] === pubkey) return true;
return false;
}

View File

@@ -12,17 +12,16 @@ export function ThreadNote({ eventId }: { eventId: string }) {
return (
<Note.Provider event={data}>
<Note.Root>
<div className="flex items-center justify-between px-3 h-14">
<Note.User className="flex-1 pr-1" />
<div className="flex items-center justify-between px-3 h-16">
<User.Provider pubkey={data.pubkey}>
<User.Root className="flex h-16 items-center gap-3 px-3 flex-1">
<User.Root className="flex h-16 items-center gap-3 flex-1">
<User.Avatar className="size-10 shrink-0 rounded-lg object-cover ring-1 ring-neutral-200/50 dark:ring-neutral-800/50" />
<div className="flex flex-1 flex-col">
<User.Name className="font-semibold text-neutral-900 dark:text-neutral-100" />
<div className="inline-flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-400">
<User.Time time={data.created_at} />
<span>·</span>
<User.NIP05 />
<User.NIP05 pubkey={data.pubkey} />
</div>
</div>
</User.Root>

View File

@@ -1,6 +1,7 @@
import { cn } from "@lume/utils";
import * as Avatar from "@radix-ui/react-avatar";
import { minidenticon } from "minidenticons";
import { nanoid } from "nanoid";
import { useMemo } from "react";
import { useUserContext } from "./provider";
@@ -9,7 +10,7 @@ export function UserAvatar({ className }: { className?: string }) {
const fallbackAvatar = useMemo(
() =>
`data:image/svg+xml;utf8,${encodeURIComponent(
minidenticon(user?.pubkey, 90, 50),
minidenticon(user?.pubkey || nanoid(), 90, 50),
)}`,
[user],
);

View File

@@ -4,19 +4,25 @@ import { useQuery } from "@tanstack/react-query";
import { useArk } from "../../hooks/useArk";
import { useUserContext } from "./provider";
export function UserNip05({ className }: { className?: string }) {
export function UserNip05({
pubkey,
className,
}: { pubkey: string; className?: string }) {
const ark = useArk();
const user = useUserContext();
const { isLoading, data: verified } = useQuery({
queryKey: ["nip05", user?.nip05],
queryFn: async ({ signal }: { signal: AbortSignal }) => {
if (!user) return false;
if (!user.nip05) return false;
return ark.validateNIP05({
pubkey: user?.pubkey,
nip05: user?.nip05,
pubkey,
nip05: user.nip05,
signal,
});
},
enabled: !!user,
});
if (!user) {
@@ -38,10 +44,8 @@ export function UserNip05({ className }: { className?: string }) {
: user.nip05}
</p>
{!isLoading && verified ? (
<VerifiedIcon className="size-5 text-teal-500" />
) : (
<UnverifiedIcon className="size-5 text-red-500" />
)}
<VerifiedIcon className="size-4 text-teal-500" />
) : null}
</div>
);
}

View File

@@ -1,21 +1,21 @@
import { SVGProps } from 'react';
import { SVGProps } from "react";
export function VerifiedIcon(props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="none"
viewBox="0 0 24 24"
{...props}
>
<path
fill="currentColor"
fillRule="evenodd"
d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm3.58 7.975a.75.75 0 00-1.16-.95l-3.976 4.859L9.03 12.47a.75.75 0 00-1.06 1.06l2 2a.75.75 0 001.11-.055l4.5-5.5z"
clipRule="evenodd"
/>
</svg>
);
export function VerifiedIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="none"
viewBox="0 0 24 24"
{...props}
>
<path
fill="currentColor"
d="M8.522 3.587C9.32 2.491 10.557 1.75 12 1.75c1.44 0 2.684.74 3.486 1.837 1.34-.21 2.746.145 3.764 1.163 1.018 1.019 1.373 2.425 1.163 3.767 1.094.802 1.837 2.039 1.837 3.483s-.743 2.68-1.837 3.483c.21 1.342-.145 2.748-1.163 3.767-1.021 1.02-2.427 1.365-3.762 1.16-.801 1.1-2.046 1.84-3.488 1.84-1.446 0-2.683-.744-3.485-1.84-1.337.206-2.743-.139-3.765-1.16-1.02-1.021-1.366-2.429-1.154-3.767-1.094-.8-1.846-2.036-1.846-3.483s.752-2.682 1.846-3.483c-.212-1.338.133-2.746 1.154-3.767 1.02-1.02 2.426-1.373 3.772-1.163zm7.042 7.094a1 1 0 10-1.128-1.652l-.087.06a13.844 13.844 0 00-3.517 3.468l-1.125-1.124a1 1 0 00-1.414 1.415l2.007 2.004a1 1 0 001.575-.21 11.843 11.843 0 013.602-3.902l.087-.06z"
/>
</svg>
);
}

View File

@@ -13,7 +13,7 @@ export function AppLayout({ platform }: { platform: Platform }) {
platform !== "macos" ? "bg-blue-50 dark:bg-blue-950" : "",
)}
>
{platform !== "macos" ? (
{platform === "windows" ? (
<WindowTitleBar platform={platform} />
) : (
<div data-tauri-drag-region className="h-9 shrink-0" />

View File

@@ -11,7 +11,7 @@ export function AuthLayout({ platform }: { platform: Platform }) {
return (
<div className="flex flex-col w-screen h-screen bg-black text-neutral-50">
{platform !== "macos" ? (
{platform === "windows" ? (
<WindowTitleBar platform={platform} />
) : (
<div data-tauri-drag-region className="h-9 shrink-0" />

View File

@@ -82,24 +82,6 @@ export function Navigation() {
</div>
)}
</NavLink>
<NavLink
to="/nwc"
preventScrollReset={true}
className="inline-flex flex-col items-center justify-center"
>
{({ isActive }) => (
<div
className={cn(
"inline-flex aspect-square h-auto w-full items-center justify-center rounded-xl",
isActive
? "bg-black/10 text-black dark:bg-white/10 dark:text-white"
: "text-black/50 dark:text-neutral-400",
)}
>
<NwcIcon className="size-6 rotate-12" />
</div>
)}
</NavLink>
</div>
</div>
<div className="flex flex-col">