Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Address component to acceipt link prop #49

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nextjs/app/_components/ActiveGrants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ActiveGrantRow = ({ title, askAmount, builder, approvedAt }: GrantData) =>
<td className="p-4 pl-4">{title}</td>
<td className="p-4 pl-4">{askAmount} ETH</td>
<td className="p-4 pl-4">
<Address address={builder} />
<Address address={builder} link={`https://app.buidlguidl.com/builders/${builder}`} />
</td>
<td className="p-4 pl-4">{approvedAt ? formatDateFromNow(approvedAt) : "-"}</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/_components/CompletedGrants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CompletedGrantCard = ({ title, description, askAmount, builder, link, comp
<p className="m-0 absolute bottom-4 left-4 text-lg">{title}</p>
</div>
<div className="flex flex-col gap-2 px-3">
<Address address={builder} />
<Address address={builder} link={`https://app.buidlguidl.com/builders/${builder}`} />
<p className="text-base m-0 mt-2">
<span className="font-medium">{askAmount} ETH</span>
</p>
Expand Down
9 changes: 1 addition & 8 deletions packages/nextjs/app/admin/_components/GrantReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,7 @@ export const GrantReview = ({ grant }: { grant: GrantDataWithBuilder }) => {
<span className="text-sm text-gray-500 ml-2">({grant.id})</span>
</h3>
<div className="flex gap-4 items-center">
<a
href={`https://app.buidlguidl.com/builders/${grant.builder}`}
className="inline-block"
target="_blank"
rel="noreferrer"
>
<Address address={grant.builder} disableAddressLink />
</a>
<Address address={grant.builder} link={`https://app.buidlguidl.com/builders/${grant.builder}`} />
<BuilderSocials socialLinks={grant.builderData?.socialLinks} />
</div>
<p>{grant.description}</p>
Expand Down
11 changes: 6 additions & 5 deletions packages/nextjs/components/scaffold-eth/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type AddressProps = {
disableAddressLink?: boolean;
format?: "short" | "long";
size?: "xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "3xl";
link?: string;
};

const blockieSizeMap = {
Expand All @@ -31,7 +32,7 @@ const blockieSizeMap = {
/**
* Displays an address (or ENS) with a Blockie image and option to copy address.
*/
export const Address = ({ address, disableAddressLink, format, size = "base" }: AddressProps) => {
export const Address = ({ address, disableAddressLink, format, size = "base", link }: AddressProps) => {
const [ens, setEns] = useState<string | null>();
const [ensAvatar, setEnsAvatar] = useState<string | null>();
const [addressCopied, setAddressCopied] = useState(false);
Expand Down Expand Up @@ -71,7 +72,7 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }:
return <span className="text-error">Wrong address</span>;
}

const blockExplorerAddressLink = getBlockExplorerAddressLink(targetNetwork, address);
const destinationHref = link ?? getBlockExplorerAddressLink(targetNetwork, address);
let displayAddress = address?.slice(0, 5) + "..." + address?.slice(-4);

if (ens) {
Expand All @@ -91,15 +92,15 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }:
</div>
{disableAddressLink ? (
<span className={`ml-1.5 text-${size} font-normal`}>{displayAddress}</span>
) : targetNetwork.id === hardhat.id ? (
) : targetNetwork.id === hardhat.id && !Boolean(link) ? (
<span className={`ml-1.5 text-${size} font-normal`}>
<Link href={blockExplorerAddressLink}>{displayAddress}</Link>
<Link href={destinationHref}>{displayAddress}</Link>
</span>
) : (
<a
className={`ml-1.5 text-${size} font-normal`}
target="_blank"
href={blockExplorerAddressLink}
href={destinationHref}
rel="noopener noreferrer"
>
{displayAddress}
Expand Down
Loading