2021-07-03 00:40:02 +00:00
|
|
|
import React from "react";
|
2021-10-31 06:16:03 +00:00
|
|
|
import { NavLink } from "react-router-dom";
|
2021-10-31 08:10:42 +00:00
|
|
|
import { ResolvedAddressRenderer } from "../api/address-resolver/address-resolver";
|
2021-07-03 00:40:02 +00:00
|
|
|
import ENSLogo from "./ensLogo.svg";
|
|
|
|
|
|
|
|
type ENSNameProps = {
|
|
|
|
name: string;
|
|
|
|
address: string;
|
2021-10-31 06:16:03 +00:00
|
|
|
linkable: boolean;
|
|
|
|
dontOverrideColors?: boolean;
|
2021-07-03 00:40:02 +00:00
|
|
|
};
|
|
|
|
|
2021-10-31 06:16:03 +00:00
|
|
|
const ENSName: React.FC<ENSNameProps> = ({
|
|
|
|
name,
|
|
|
|
address,
|
|
|
|
linkable,
|
|
|
|
dontOverrideColors,
|
|
|
|
}) => {
|
|
|
|
if (linkable) {
|
|
|
|
return (
|
|
|
|
<NavLink
|
|
|
|
className={`flex items-baseline space-x-1 font-sans ${
|
|
|
|
dontOverrideColors ? "" : "text-link-blue hover:text-link-blue-hover"
|
|
|
|
} truncate`}
|
|
|
|
to={`/address/${name}`}
|
|
|
|
title={`${name}: ${address}`}
|
|
|
|
>
|
|
|
|
<Content linkable={true} name={name} />
|
|
|
|
</NavLink>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className="flex items-baseline space-x-1 font-sans text-gray-700 truncate"
|
|
|
|
title={`${name}: ${address}`}
|
|
|
|
>
|
|
|
|
<Content linkable={false} name={name} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
type ContentProps = {
|
|
|
|
linkable: boolean;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Content: React.FC<ContentProps> = ({ linkable, name }) => (
|
|
|
|
<>
|
2021-07-03 00:40:02 +00:00
|
|
|
<img
|
2021-10-31 06:16:03 +00:00
|
|
|
className={`self-center ${linkable ? "" : "filter grayscale"}`}
|
2021-07-03 00:40:02 +00:00
|
|
|
src={ENSLogo}
|
|
|
|
alt="ENS Logo"
|
|
|
|
width={12}
|
|
|
|
height={12}
|
|
|
|
/>
|
2021-07-19 04:03:32 +00:00
|
|
|
<span className="truncate">{name}</span>
|
2021-10-31 06:16:03 +00:00
|
|
|
</>
|
2021-07-03 00:40:02 +00:00
|
|
|
);
|
|
|
|
|
2021-10-31 08:10:42 +00:00
|
|
|
export const ensRenderer: ResolvedAddressRenderer = (
|
|
|
|
address,
|
|
|
|
resolvedAddress,
|
|
|
|
linkable,
|
|
|
|
dontOverrideColors
|
|
|
|
) => (
|
|
|
|
<ENSName
|
|
|
|
address={address}
|
|
|
|
name={resolvedAddress}
|
|
|
|
linkable={linkable}
|
|
|
|
dontOverrideColors={dontOverrideColors}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-10-31 01:05:26 +00:00
|
|
|
export default ENSName;
|