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

feat: add latest redirect actionables #210

Merged
merged 2 commits into from
Oct 16, 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 src/components/Atoms/Timestamp/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Timestamp: React.FC<TimestampProps> = ({
>
{parsedTime}

<span className="text-foreground-light opacity-75 dark:text-foreground-dark">
<span className="text-foreground-light opacity-75 dark:text-foreground-dark mt-0.5">
<ClockIcon />
</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LatestBlocks as LatestBlocksComponent } from "./LatestBlocks";
import { storyAction } from "@/utils/functions";
import { type Block } from "@covalenthq/client-sdk";
import { type Meta, type StoryObj } from "@storybook/react";

type Story = StoryObj<typeof LatestBlocksComponent>;
Expand All @@ -16,5 +15,12 @@ export const LatestBlocks: Story = {
args: {
chain_name: "eth-mainnet",
actionable_block: (block_height) => storyAction(block_height),
actionable_redirect: () => ({
parent: "a",
parentProps: {
href: "/?path=/story/molecules-block-blocks-list--blocks-list",
className: "hover:underline w-fit mx-auto",
},
}),
},
};
9 changes: 9 additions & 0 deletions src/components/Molecules/Block/LatestBlocks/LatestBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useEffect, useState } from "react";
export const LatestBlocks: React.FC<LatestBlocksProps> = ({
chain_name,
actionable_block = () => null,
actionable_redirect,
}) => {
const { goldrushClient } = useGoldRush();
const [errorMessage, setErrorMessage] = useState<string | null>(null);
Expand Down Expand Up @@ -111,6 +112,14 @@ export const LatestBlocks: React.FC<LatestBlocksProps> = ({
<></>
),
})}

{actionable_redirect &&
actionableWrapper(
actionable_redirect(),
<span className="text-center py-4 flex">
View all blocks
</span>,
)}
</Card>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ export const LatestTransactions: Story = {
chain_name: "eth-mainnet",
actionable_transaction: (address) => storyAction(address),
actionable_address: (address) => storyAction(address),
actionable_redirect: () => ({
parent: "a",
parentProps: {
href: "/?path=/story/molecules-transaction-transactions-list--transactions-list",
className: "hover:underline w-fit mx-auto",
},
}),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DEFAULT_ERROR_MESSAGE,
FALLBACK_ERROR,
} from "@/utils/constants/shared.constants";
import { timestampParser } from "@/utils/functions";
import { actionableWrapper, timestampParser } from "@/utils/functions";
import { None, Some, type Option } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
import { type LatestTransactionsProps } from "@/utils/types/molecules.types";
Expand All @@ -22,6 +22,7 @@ export const LatestTransactions: React.FC<LatestTransactionsProps> = ({
chain_name,
actionable_address,
actionable_transaction,
actionable_redirect,
}) => {
const { goldrushClient } = useGoldRush();
const [errorMessage, setErrorMessage] = useState<string | null>(null);
Expand Down Expand Up @@ -179,6 +180,14 @@ export const LatestTransactions: React.FC<LatestTransactionsProps> = ({
<></>
),
})}

{actionable_redirect &&
actionableWrapper(
actionable_redirect(),
<span className="text-center py-4 flex">
View all blocks
</span>,
)}
</Card>
);
};
2 changes: 2 additions & 0 deletions src/utils/types/molecules.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface LatestBlocksProps {
chain_name: Chain;
page_size?: number;
actionable_block?: (block_height: number | null) => ActionableType;
actionable_redirect?: () => ActionableType;
}

export interface TransactionsListProps {
Expand All @@ -82,6 +83,7 @@ export interface LatestTransactionsProps {
chain_name: Chain;
actionable_transaction?: (address: string | null) => ActionableType;
actionable_address?: (address: string | null) => ActionableType;
actionable_redirect?: () => ActionableType;
}

export interface LatestPriceProps {
Expand Down
Loading