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

fix: logo #201

Merged
merged 2 commits into from
Sep 20, 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 .storybook/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const defaultTheme: ThemeVars = {
appBg: "black",
colorSecondary: "#FF4C8B",
brandImage:
"https://github.com/covalenthq/goldrush-kit/blob/main/src/static/goldrush-powered-by-covalent.svg",
"https://raw.githubusercontent.com/covalenthq/goldrush-kit/refs/heads/main/src/static/goldrush-powered-by-covalent.svg",
base: "light",
brandTitle: "GoldRush Kit - powered by Covalent",
brandUrl: "https://github.com/covalenthq/goldrush-kit/",
Expand Down
1 change: 0 additions & 1 deletion src/components/Atoms/Address/Address.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Story = StoryObj<typeof AddressComponent>;
export const Address: Story = {
args: {
address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
show_copy_icon: true,
actionable_address: (address) => storyAction(address),
},
};
61 changes: 8 additions & 53 deletions src/components/Atoms/Address/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,29 @@
import { AddressAvatar } from "../AddressAvatar/AddressAvatar";
import { IconWrapper } from "@/components/Shared";
import { Toaster } from "@/components/ui/toaster";
import {
actionableWrapper,
copyToClipboard,
truncate,
} from "@/utils/functions";
import { useToast } from "@/utils/hooks";
import { CopyData } from "@/components/Shared";
import { actionableWrapper, truncate } from "@/utils/functions";
import { type AddressProps } from "@/utils/types/atoms.types";
import { useState } from "react";

export const Address: React.FC<AddressProps> = ({
address,
label = null,
show_copy_icon = true,
avatar = null,
actionable_address = () => null,
}) => {
if (!address) {
return <></>;
}

const [showCopy, setShowCopy] = useState<boolean>(false);
const { toast } = useToast();

const handleCopyClick = () => {
toast({
title: "Copied to clipboard!",
description: address,
});
setShowCopy(true);
setTimeout(() => {
setShowCopy(false);
}, 3000);
};

return (
<>
<Toaster />
<p className="flex items-center gap-x-2">
{avatar && <AddressAvatar {...avatar} address={address} />}

{actionableWrapper(
actionable_address(address),
label?.trim() || truncate(address),
)}

{show_copy_icon && (
<button
className="cursor-pointer"
onClick={() => {
copyToClipboard(address);
}}
>
{showCopy ? (
<IconWrapper
icon_class_name="done"
icon_size="text-sm"
class_name="text-foreground-light dark:text-foreground-dark opacity-75"
/>
) : (
<IconWrapper
icon_class_name="content_copy"
icon_size="text-sm"
class_name="text-foreground-light dark:text-foreground-dark opacity-75"
on_click={() => handleCopyClick()}
/>
)}
</button>
)}
<CopyData data={address}>
{actionableWrapper(
actionable_address(address),
label?.trim() || truncate(address),
)}
</CopyData>
</p>
</>
);
Expand Down
2 changes: 0 additions & 2 deletions src/components/Atoms/AddressCard/AddressCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const AddressCard: React.FC<AddressCardProps> = ({
address,
avatar,
label = "Unnamed Wallet",
show_copy_icon = true,
show_qr_code = true,
actionable_address,
}) => {
Expand All @@ -29,7 +28,6 @@ export const AddressCard: React.FC<AddressCardProps> = ({
<Address
address={address}
label={null}
show_copy_icon={show_copy_icon}
actionable_address={actionable_address}
/>
{show_qr_code && (
Expand Down
58 changes: 58 additions & 0 deletions src/components/Shared/CopyData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { IconWrapper } from ".";
import { Toaster } from "../ui/toaster";
import { copyToClipboard } from "@/utils/functions";
import { useToast } from "@/utils/hooks";
import { type CopyDataProps } from "@/utils/types/shared.types";
import { useState } from "react";

export const CopyData: React.FC<CopyDataProps> = ({ children, data }) => {
const [copied, showCopied] = useState<boolean>(false);

const { toast } = useToast();

const handleCopyClick = () => {
toast({
title: "Copied to clipboard!",
description: data,
});
showCopied(true);
setTimeout(() => {
showCopied(false);
}, 3000);
};

return (
<>
<Toaster />

<button
className="cursor-pointer flex items-center gap-x-2"
onClick={() => {
handleCopyClick();
}}
>
{children}

{copied ? (
<IconWrapper
icon_class_name="done"
icon_size="text-sm text-secondary-light dark:text-secondary-dark"
/>
) : (
<IconWrapper
icon_class_name="content_copy"
icon_size="text-sm text-slate-900 dark:text-slate-50"
class_name="cursor-pointer"
on_click={() => {
copyToClipboard(data);
showCopied(true);
setTimeout(() => {
showCopied(false);
}, 3000);
}}
/>
)}
</button>
</>
);
};
28 changes: 0 additions & 28 deletions src/components/Shared/CopyImage.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Shared/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { BalancePriceDelta } from "./BalancePriceDelta";
export { CardDetail } from "./CardDetail";
export { CopyImage } from "./CopyImage";
export { CopyData } from "./CopyData";
export { Heading } from "./Heading";
export { IconWrapper } from "./IconWrapper";
export { PaginationFooter } from "./PaginationFooter";
Expand Down
2 changes: 0 additions & 2 deletions src/utils/types/atoms.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
export interface AddressProps {
address: string | null;
label?: string | null;
show_copy_icon?: boolean;
avatar?: Omit<AddressAvatarProps, "address">;
actionable_address?: (address: string | null) => ActionableType;
}
Expand All @@ -20,7 +19,6 @@ export interface AddressCardProps {
label?: string | null;
address: string;
avatar: Omit<AddressAvatarProps, "address">;
show_copy_icon?: boolean;
show_qr_code?: boolean;
actionable_address?: (address: string | null) => ActionableType;
}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/types/shared.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export interface CardDetailProps {
wrapperClassName?: string;
}

export interface CopyImageProps {
url: string;
export interface CopyDataProps {
data: string;
children: React.ReactNode;
}

export interface IconWrapperProps {
Expand Down
Loading