Skip to content

Commit b206df8

Browse files
Service layers (#311)
* feat: add service layers * refactorise the entire UI of cards and modal to hook up with the service layer code
1 parent e174ebf commit b206df8

File tree

33 files changed

+1237
-463
lines changed

33 files changed

+1237
-463
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { ActivityList } from "./ActivityList";
3+
4+
const meta: Meta<typeof ActivityList> = {
5+
title: "Components/Lists/ActivityList",
6+
component: ActivityList,
7+
tags: ["autodocs"],
8+
parameters: {
9+
docs: {
10+
description: {
11+
component: "A container component for displaying a list of items with an add button. Commonly used for vault positions or activity feeds.",
12+
},
13+
},
14+
},
15+
};
16+
17+
export default meta;
18+
type Story = StoryObj<typeof meta>;
19+
20+
export const Default: Story = {
21+
args: {
22+
onNewItem: () => console.log("New item clicked"),
23+
},
24+
};
25+
26+
export const VaultPositions: Story = {
27+
args: {
28+
onNewItem: () => console.log("Create new vault position"),
29+
},
30+
};
31+
32+
export const WithCustomStyling: Story = {
33+
args: {
34+
className: "border-2 border-primary-light",
35+
onNewItem: () => console.log("Custom styled list"),
36+
},
37+
};
38+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Card } from "../Card";
2+
import { IconButton } from "../Button";
3+
import { PlusIcon } from "../Icons";
4+
import type { PropsWithChildren } from "react";
5+
6+
/**
7+
* ActivityList component - Container for displaying a list of items with an add button
8+
*
9+
* @example
10+
* ```tsx
11+
* <ActivityList onNewItem={() => handleNewVault()}>
12+
* <ActivityCard data={vaultActivityData} />
13+
* <ActivityCard data={vaultActivityData} />
14+
* </ActivityList>
15+
* ```
16+
*/
17+
export interface ActivityListProps {
18+
onNewItem?: () => void;
19+
className?: string;
20+
}
21+
22+
export function ActivityList({
23+
onNewItem,
24+
className,
25+
children,
26+
}: PropsWithChildren<ActivityListProps>) {
27+
return (
28+
<Card className={className}>
29+
<div className="flex flex-col gap-4">
30+
{children}
31+
32+
<div className="flex justify-center py-4">
33+
<IconButton
34+
variant="outlined"
35+
size="large"
36+
onClick={onNewItem}
37+
aria-label="Create new item"
38+
>
39+
<PlusIcon />
40+
</IconButton>
41+
</div>
42+
</div>
43+
</Card>
44+
);
45+
}
46+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { ActivityList } from "./ActivityList";
2+
export type { ActivityListProps } from "./ActivityList";
3+

packages/babylon-core-ui/src/components/BorrowCard/BorrowCard.stories.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

packages/babylon-core-ui/src/components/BorrowCard/BorrowCard.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.

packages/babylon-core-ui/src/components/BorrowCard/index.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/babylon-core-ui/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export { Copy } from './Copy';
22
export { Toggle } from './Toggle';
33
export { DisplayHash } from './DisplayHash';
44
export * from './Avatar';
5-
export * from './BorrowCard';
5+
export * from './ActivityList';
66
export * from './Text';
77

packages/babylon-core-ui/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export * from "./components/Card";
1717
export * from "./components/Toggle";
1818
export * from "./components/List";
1919
export * from "./components/Badge";
20-
export * from "./components/BorrowCard";
20+
export * from "./components/ActivityList";
2121
export * from "./components/SubSection";
2222
export * from "./components/CounterButton";
2323
export * from "./components/Menu";

packages/babylon-wallet-connector/src/hooks/useAppKitBridge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect } from "react";
22
import { useAppKitAccount } from "@reown/appkit/react";
3+
34
import { useChainConnector } from "./useChainConnector";
45

56
interface UseAppKitBridgeOptions {

routes/vault/src/VaultLayout.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { useAppKitBridge } from '@babylonlabs-io/wallet-connector';
2-
import { Borrow } from './components/ui';
3-
import { PegInTest } from './components/examples/PegInTest';
2+
import { Activities } from './components/Activities';
43

54
// TODO: Uncomment this when we have a way to test the contract queries
6-
import ContractQueryExample from "./components/examples/ContractQueryExample";
5+
// import { PegInTest } from './components/examples/PegInTest';
6+
// import ContractQueryExample from "./components/examples/ContractQueryExample";
77

88
export default function VaultLayout() {
99
// Initialize AppKit bridge for ETH wallet connection
1010
useAppKitBridge();
1111

1212
return (
1313
<div className="container mx-auto flex max-w-[760px] flex-1 flex-col gap-12 px-4 py-8">
14-
<ContractQueryExample />
15-
<PegInTest />
16-
<Borrow />
14+
{/* <ContractQueryExample /> */}
15+
{/* <PegInTest /> */}
16+
<Activities />
1717
</div>
1818
);
1919
}

0 commit comments

Comments
 (0)