This repository was archived by the owner on Jul 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
new design components #136
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { fn } from "@storybook/test"; | ||
|
||
import { CounterButton } from "./CounterButton"; | ||
|
||
const meta: Meta<typeof CounterButton> = { | ||
component: CounterButton, | ||
tags: ["autodocs"], | ||
args: { | ||
onAdd: fn(), | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
counter: 0, | ||
max: 5, | ||
}, | ||
}; | ||
|
||
export const WithCounter: Story = { | ||
args: { | ||
counter: 2, | ||
max: 5, | ||
}, | ||
}; | ||
|
||
export const AlmostAtMax: Story = { | ||
args: { | ||
counter: 4, | ||
max: 5, | ||
}, | ||
}; | ||
|
||
export const AtMaxCapacity: Story = { | ||
args: { | ||
counter: 5, | ||
max: 5, | ||
}, | ||
}; | ||
|
||
export const AlwaysShowCounter: Story = { | ||
args: { | ||
counter: 0, | ||
max: 3, | ||
alwaysShowCounter: true, | ||
}, | ||
}; | ||
|
||
export const AlwaysShowCounterWithValue: Story = { | ||
args: { | ||
counter: 1, | ||
max: 3, | ||
alwaysShowCounter: true, | ||
}, | ||
}; | ||
|
||
export const SingleMax: Story = { | ||
args: { | ||
counter: 0, | ||
max: 1, | ||
}, | ||
}; | ||
|
||
export const SingleMaxAtCapacity: Story = { | ||
args: { | ||
counter: 1, | ||
max: 1, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { AiOutlinePlus } from "react-icons/ai"; | ||
import { twJoin } from "tailwind-merge"; | ||
|
||
interface CounterButtonProps { | ||
counter: number; | ||
max: number; | ||
onAdd: () => void; | ||
alwaysShowCounter?: boolean; | ||
} | ||
|
||
export function CounterButton({ counter, max, onAdd, alwaysShowCounter = false }: CounterButtonProps) { | ||
jonybur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const isClickable = counter < max; | ||
const showsCounter = (0 < counter && 1 < max) || (alwaysShowCounter && counter === 0); | ||
|
||
return ( | ||
<div | ||
className={twJoin( | ||
"bg-primary-highlight flex overflow-hidden rounded-md border border-accent-primary", | ||
isClickable && "cursor-pointer", | ||
!showsCounter && !isClickable && "hidden", | ||
!showsCounter && "w-10", | ||
)} | ||
onClick={isClickable ? onAdd : undefined} | ||
> | ||
{isClickable && ( | ||
<div className="flex h-10 w-10 items-center justify-center"> | ||
<AiOutlinePlus size={20} /> | ||
</div> | ||
)} | ||
{showsCounter && ( | ||
<div className="flex h-10 items-center border-l border-accent-primary px-2 text-sm sm:px-4 sm:text-base"> | ||
{counter}/{max} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { CounterButton } from "./CounterButton"; |
93 changes: 93 additions & 0 deletions
93
src/components/FinalityProviderItem/FinalityProviderItem.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
jonybur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import { FinalityProviderItem } from "./FinalityProviderItem"; | ||
|
||
const meta: Meta<typeof FinalityProviderItem> = { | ||
component: FinalityProviderItem, | ||
tags: ["autodocs"], | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
const mockProvider = { | ||
logo_url: "/images/fps/lombard.jpeg", | ||
rank: 1, | ||
description: { | ||
moniker: "Lombard Protocol", | ||
}, | ||
}; | ||
|
||
const mockProviderWithoutLogo = { | ||
logo_url: undefined, | ||
rank: 5, | ||
description: { | ||
moniker: "Bitcoin Staking Provider", | ||
}, | ||
}; | ||
|
||
export const Default: Story = { | ||
args: { | ||
bsnId: "bsn123", | ||
bsnName: "Babylon", | ||
bsnLogoUrl: "/images/fps/pumpbtc.jpeg", | ||
provider: mockProvider, | ||
onRemove: (bsnId) => alert(`Remove clicked for ${bsnId}`), | ||
}, | ||
}; | ||
|
||
export const WithoutBsnLogo: Story = { | ||
args: { | ||
bsnId: "bsn456", | ||
bsnName: "Babylon Chain", | ||
bsnLogoUrl: undefined, | ||
provider: mockProvider, | ||
onRemove: (bsnId) => alert(`Remove clicked for ${bsnId}`), | ||
}, | ||
}; | ||
|
||
export const WithoutProviderLogo: Story = { | ||
args: { | ||
bsnId: "bsn789", | ||
bsnName: "Babylon Network", | ||
bsnLogoUrl: "/images/fps/solv.jpeg", | ||
provider: mockProviderWithoutLogo, | ||
onRemove: (bsnId) => alert(`Remove clicked for ${bsnId}`), | ||
}, | ||
}; | ||
|
||
export const HighRankProvider: Story = { | ||
args: { | ||
bsnId: "bsn999", | ||
bsnName: "Babylon Testnet", | ||
bsnLogoUrl: "/images/fps/pumpbtc.jpeg", | ||
provider: { | ||
logo_url: "/images/fps/solv.jpeg", | ||
rank: 99, | ||
description: { | ||
moniker: "High Rank Provider", | ||
}, | ||
}, | ||
onRemove: (bsnId) => alert(`Remove clicked for ${bsnId}`), | ||
}, | ||
}; | ||
|
||
export const LongNames: Story = { | ||
args: { | ||
bsnId: "bsn_very_long_id_123456789", | ||
bsnName: "Very Long Babylon Network Name That Might Wrap", | ||
bsnLogoUrl: "/images/fps/lombard.jpeg", | ||
provider: { | ||
logo_url: "/images/fps/pumpbtc.jpeg", | ||
rank: 42, | ||
description: { | ||
moniker: "Very Long Finality Provider Name That Should Handle Text Overflow", | ||
}, | ||
}, | ||
onRemove: (bsnId) => alert(`Remove clicked for ${bsnId}`), | ||
}, | ||
}; |
60 changes: 60 additions & 0 deletions
60
src/components/FinalityProviderItem/FinalityProviderItem.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Avatar } from "../Avatar"; | ||
import { Text } from "../Text"; | ||
import { FinalityProviderLogo } from "../FinalityProviderLogo"; | ||
|
||
interface ProviderDescription { | ||
moniker?: string; | ||
} | ||
|
||
interface Provider { | ||
logo_url?: string; | ||
rank: number; | ||
description?: ProviderDescription; | ||
} | ||
|
||
interface FinalityProviderItemProps { | ||
bsnId: string; | ||
bsnName: string; | ||
bsnLogoUrl?: string; | ||
provider: Provider; | ||
onRemove: (bsnId?: string) => void; | ||
} | ||
|
||
export function FinalityProviderItem({ bsnId, bsnName, bsnLogoUrl, provider, onRemove }: FinalityProviderItemProps) { | ||
jonybur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!provider) return null; | ||
|
||
const renderBsnLogo = () => { | ||
if (!bsnLogoUrl) return null; | ||
|
||
return <Avatar url={bsnLogoUrl} alt={bsnName} variant="rounded" size="tiny" className="mr-1" />; | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-row items-center justify-between"> | ||
<div className="flex h-10 flex-row gap-2"> | ||
<FinalityProviderLogo | ||
logoUrl={provider.logo_url} | ||
rank={provider.rank} | ||
moniker={provider.description?.moniker} | ||
size="lg" | ||
/> | ||
<div className="flex flex-col justify-center text-accent-primary"> | ||
<div className="flex items-center text-xs text-accent-secondary"> | ||
{renderBsnLogo()} | ||
{bsnName} | ||
</div> | ||
<Text as="div" className="text-base font-medium text-accent-primary"> | ||
{provider.description?.moniker} | ||
</Text> | ||
</div> | ||
</div> | ||
|
||
<button | ||
onClick={() => onRemove(bsnId)} | ||
className="cursor-pointer rounded bg-accent-secondary/20 px-2 py-0.5 text-xs tracking-[0.4px] text-accent-primary" | ||
> | ||
Remove | ||
</button> | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./FinalityProviderItem"; |
75 changes: 75 additions & 0 deletions
75
src/components/FinalityProviderLogo/FinalityProviderLogo.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { FinalityProviderLogo } from "./FinalityProviderLogo"; | ||
|
||
const meta: Meta<typeof FinalityProviderLogo> = { | ||
component: FinalityProviderLogo, | ||
tags: ["autodocs"], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const WithImage: Story = { | ||
args: { | ||
logoUrl: "/images/fps/lombard.jpeg", | ||
rank: 1, | ||
moniker: "Lombard Protocol", | ||
}, | ||
}; | ||
|
||
export const WithImageLarge: Story = { | ||
args: { | ||
logoUrl: "/images/fps/pumpbtc.jpeg", | ||
rank: 2, | ||
moniker: "PumpBTC", | ||
size: "lg", | ||
}, | ||
}; | ||
|
||
export const WithImageSmall: Story = { | ||
args: { | ||
logoUrl: "/images/fps/solv.jpeg", | ||
rank: 3, | ||
moniker: "Solv Protocol", | ||
size: "sm", | ||
}, | ||
}; | ||
|
||
export const FallbackWithMoniker: Story = { | ||
args: { | ||
rank: 1, | ||
moniker: "Babylon Network", | ||
}, | ||
}; | ||
|
||
export const FallbackWithoutMoniker: Story = { | ||
args: { | ||
rank: 5, | ||
}, | ||
}; | ||
|
||
export const FallbackLarge: Story = { | ||
args: { | ||
rank: 2, | ||
moniker: "Large Provider", | ||
size: "lg", | ||
}, | ||
}; | ||
|
||
export const FallbackSmall: Story = { | ||
args: { | ||
rank: 3, | ||
moniker: "Small Provider", | ||
size: "sm", | ||
}, | ||
}; | ||
|
||
export const InvalidImage: Story = { | ||
args: { | ||
logoUrl: "/invalid-image-url.jpg", | ||
rank: 4, | ||
moniker: "Provider with Invalid Image", | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.