Skip to content

Commit

Permalink
Remove src
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Jul 30, 2024
1 parent 1d58649 commit 1be5bd9
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/wallet/components/WalletDropdownBaseName.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { base } from 'viem/chains';
import { useAccount } from 'wagmi';
import { useName } from '../../identity/hooks/useName';
import { Spinner } from '../../internal/components/Spinner';
import { baseNameSvg } from '../../internal/svg/baseNameSvg';
import { cn, pressable, text } from '../../styles/theme';
import type { WalletDropdownBaseNameReact } from '../types';

export function WalletDropdownBaseName({
className,
}: WalletDropdownBaseNameReact) {
const { address } = useAccount();

if (!address) {
return null;
}

const { data: baseName, isLoading } = useName({
address,
chain: base,
});

const hasBaseUserName = !!baseName;
const title = hasBaseUserName ? 'Go to profile' : 'Claim a Basename';
const href = hasBaseUserName
? `https://www.base.org/name/${baseName}`
: 'https://www.base.org/names';

return (
<a
className={cn(
pressable.default,
'flex items-center px-4 py-2',
className,
)}
href={href}
target="_blank"
rel="noopener noreferrer"
>
{baseNameSvg && <div className="mr-2 h-5 w-5">{baseNameSvg}</div>}
<div className="flex items-center">
{isLoading ? (
<Spinner />
) : (
<>
<span className={cn(text.body, 'shrink-0')}>{title}</span>
{!hasBaseUserName && (
<span
className={cn(
'ml-2 rounded-full bg-[#E0E7FF] px-2 text-center font-bold font-inter text-[#4F46E5] text-[0.6875rem] uppercase leading-6',
)}
>
NEW
</span>
)}
</>
)}
</div>
</a>
);
}

0 comments on commit 1be5bd9

Please sign in to comment.