diff --git a/src/components/Address.tsx b/src/components/Address.tsx deleted file mode 100644 index 478f4f6..0000000 --- a/src/components/Address.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from "react"; - -type AddressProps = { - address: string; -}; - -const Address: React.FC = ({ address }) => ( - - {address} - -); - -export default Address; diff --git a/src/components/AddressLink.tsx b/src/components/AddressLink.tsx deleted file mode 100644 index 8353457..0000000 --- a/src/components/AddressLink.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react"; -import { NavLink } from "react-router-dom"; - -type AddressLinkProps = { - address: string; - text?: string; - dontOverrideColors?: boolean; -}; - -const AddressLink: React.FC = ({ - address, - text, - dontOverrideColors, -}) => ( - - {text ?? address} - -); - -export default AddressLink; diff --git a/src/components/AddressOrENSName.tsx b/src/components/AddressOrENSName.tsx index dd865d7..83fd0cd 100644 --- a/src/components/AddressOrENSName.tsx +++ b/src/components/AddressOrENSName.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Address from "./Address"; -import AddressLink from "./AddressLink"; -import ENSName from "./ENSName"; -import ENSNameLink from "./ENSNameLink"; import { ensResolver, ResolvedAddresses } from "../api/address-resolver"; +import PlainAddress from "./PlainAddress"; +import ENSName from "./ENSName"; type AddressOrENSNameProps = { address: string; @@ -20,36 +18,34 @@ const AddressOrENSName: React.FC = ({ dontOverrideColors, resolvedAddresses, }) => { - const name = resolvedAddresses?.[address]; - return ( - <> - {address === selectedAddress ? ( - <> - {name?.[0] === ensResolver ? ( - - ) : ( -
- )} - - ) : ( - <> - {name?.[0] ? ( - - ) : ( - - )} - - )} - - ); + const resolvedAddress = resolvedAddresses?.[address]; + const linkable = address !== selectedAddress; + + if (resolvedAddress === undefined) { + return ( + + ); + } + + const [resolver, resolvedName] = resolvedAddress; + if (resolver === ensResolver) { + return ( + + ); + } + + return <>; }; export default AddressOrENSName; diff --git a/src/components/ENSName.tsx b/src/components/ENSName.tsx index 95f1e1f..ac1b038 100644 --- a/src/components/ENSName.tsx +++ b/src/components/ENSName.tsx @@ -1,25 +1,62 @@ import React from "react"; +import { NavLink } from "react-router-dom"; import ENSLogo from "./ensLogo.svg"; type ENSNameProps = { name: string; address: string; + text: string | undefined; + linkable: boolean; + dontOverrideColors?: boolean; }; -const ENSName: React.FC = ({ name, address }) => ( -
+const ENSName: React.FC = ({ + name, + address, + text, + linkable, + dontOverrideColors, +}) => { + if (linkable) { + return ( + + + + ); + } + + return ( +
+ +
+ ); +}; + +type ContentProps = { + linkable: boolean; + name: string; +}; + +const Content: React.FC = ({ linkable, name }) => ( + <> ENS Logo {name} -
+ ); export default ENSName; diff --git a/src/components/ENSNameLink.tsx b/src/components/ENSNameLink.tsx deleted file mode 100644 index ad5df4d..0000000 --- a/src/components/ENSNameLink.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from "react"; -import { NavLink } from "react-router-dom"; -import ENSLogo from "./ensLogo.svg"; - -type ENSNameLinkProps = { - name: string; - address: string; - dontOverrideColors?: boolean; -}; - -const ENSNameLink: React.FC = ({ - name, - address, - dontOverrideColors, -}) => ( - - ENS Logo - {name} - -); - -export default ENSNameLink; diff --git a/src/components/PlainAddress.tsx b/src/components/PlainAddress.tsx new file mode 100644 index 0000000..6ebe634 --- /dev/null +++ b/src/components/PlainAddress.tsx @@ -0,0 +1,38 @@ +import React from "react"; +import { NavLink } from "react-router-dom"; + +type PlainAddressProps = { + address: string; + text: string | undefined; + linkable: boolean; + dontOverrideColors: boolean | undefined; +}; + +const PlainAddress: React.FC = ({ + address, + text, + linkable, + dontOverrideColors, +}) => { + if (linkable) { + return ( + + <>{text ?? address} + + ); + } + + return ( + + {address} + + ); +}; + +export default PlainAddress;