Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @0xDazzer @jonybur @jeremy-babylonlabs @jrwbabylonlab @gbarkhatov
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Avatar } from "../Avatar";
import { Text } from "../Text";
import { FinalityProviderLogo } from "../FinalityProviderLogo";
import { Avatar } from "../../components/Avatar";
import { Text } from "../../components/Text";
import { FinalityProviderLogo } from "../FinalityProviderLogo/FinalityProviderLogo";

interface ProviderDescription {
moniker?: string;
Expand All @@ -17,7 +17,7 @@ interface FinalityProviderItemProps {
bsnName: string;
bsnLogoUrl?: string;
provider: Provider;
onRemove: (bsnId?: string) => void;
onRemove: (id?: string) => void;
}

export function FinalityProviderItem({ bsnId, bsnName, bsnLogoUrl, provider, onRemove }: FinalityProviderItemProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text } from "../Text";
import { Text } from "../../components/Text";
import { useState } from "react";
import { twMerge } from "tailwind-merge";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface ProviderItem {

interface ProvidersListProps {
items: ProviderItem[];
onRemove: (bsnId?: string) => void;
onRemove: (id?: string) => void;
}

export function ProvidersList({ items, onRemove }: ProvidersListProps) {
Expand Down
12 changes: 7 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export * from "./components/Toggle";
export * from "./components/List";
export * from "./components/Badge";
export * from "./components/SubSection";
export * from "./components/FinalityProviderLogo";
export * from "./components/CounterButton";
export * from "./components/Menu";

Expand All @@ -30,10 +29,13 @@ export * from "./widgets/form/SelectField";
export * from "./widgets/form/HiddenField";
export * from "./widgets/form/hooks";

export * from "./widgets/new-design/AmountSubsection";
export * from "./widgets/new-design/FinalityProviderSubsection";
export * from "./widgets/new-design/FeesSection";
export * from "./widgets/new-design/PreviewModal";
export * from "./widgets/sections/AmountSubsection";
export * from "./widgets/sections/FinalityProviderSubsection";
export * from "./widgets/sections/FeesSection";
export * from "./widgets/sections/PreviewModal";

export * from "./elements/FinalityProviderLogo";
export * from "./elements/FinalityProviderItem";

export * from "./components/ListLegacy";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";

import { FinalityProviderSubsection } from "./FinalityProviderSubsection";
import type { ProviderItem } from "../../../components/ProvidersList/ProvidersList";
import type { ProviderItem } from "../../../elements/ProvidersList/ProvidersList";

const sampleItems: ProviderItem[] = [
{
Expand Down Expand Up @@ -84,72 +84,102 @@ export const Default: Story = {
args: {
max: 3,
items: sampleItems,
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: () => alert("Remove clicked"),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const Empty: Story = {
args: {
max: 3,
items: [],
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: () => alert("Remove clicked"),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const MultipleItems: Story = {
args: {
max: 5,
items: multipleItems,
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: (bsnId?: string) => alert(`Remove clicked for ${bsnId}`),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const AtMaximumCapacity: Story = {
args: {
max: 3,
items: maxCapacityItems,
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: (bsnId?: string) => alert(`Remove clicked for ${bsnId}`),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const SingleProviderMode: Story = {
args: {
max: 1,
items: [],
actionText: "Add Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: () => alert("Remove clicked"),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const SingleProviderModeWithItem: Story = {
args: {
max: 1,
items: [sampleItems[0]],
actionText: "Add Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: (bsnId?: string) => alert(`Remove clicked for ${bsnId}`),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const ProvidersWithoutLogos: Story = {
Expand All @@ -174,12 +204,17 @@ export const ProvidersWithoutLogos: Story = {
},
},
],
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: (bsnId?: string) => alert(`Remove clicked for ${bsnId}`),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};

export const ProvidersWithoutDescriptions: Story = {
Expand All @@ -206,10 +241,15 @@ export const ProvidersWithoutDescriptions: Story = {
},
},
],
actionText: "Add BSN and Finality Provider",
onAdd: () => alert("Add clicked"),
onRemove: (bsnId?: string) => alert(`Remove clicked for ${bsnId}`),
},
render: (props: { max: number; items: ProviderItem[]; onAdd: () => void; onRemove: (bsnId?: string) => void }) => (
<FinalityProviderSubsection {...props} />
),
render: (props: {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
}) => <FinalityProviderSubsection {...props} />,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import { SubSection } from "../../../components/SubSection";
import { useMemo } from "react";

import { CounterButton } from "../../../components/CounterButton/CounterButton";
import { ProvidersList, ProviderItem } from "../../../components/ProvidersList/ProvidersList";
import { ProvidersList, ProviderItem } from "../../../elements/ProvidersList/ProvidersList";

interface Props {
max: number;
items: ProviderItem[];
actionText: string;
onAdd: () => void;
onRemove: (bsnId?: string) => void;
onRemove: (id?: string) => void;
}

export function FinalityProviderSubsection({ max, items = [], onAdd, onRemove }: Props) {
export function FinalityProviderSubsection({ max, items = [], actionText, onAdd, onRemove }: Props) {
const count = useMemo(() => items.length, [items]);

const allowsMultipleBsns = max > 1;
const actionText = allowsMultipleBsns ? "Add BSN and Finality Provider" : "Add Finality Provider";

return (
<SubSection>
<div className="flex w-full flex-col gap-4">
Expand Down