-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
libs/webb-ui-components/src/components/buttons/LoadingPill.tsx
This file contains 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,48 @@ | ||
import { forwardRef } from 'react'; | ||
import { LoadingPillProps } from './types'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { | ||
CheckboxCircleLine, | ||
CloseCircleLineIcon, | ||
Spinner, | ||
} from '@webb-tools/icons'; | ||
|
||
const LoadingPill = forwardRef<HTMLButtonElement, LoadingPillProps>( | ||
({ className, status = 'loading', ...props }, ref) => { | ||
return ( | ||
<button | ||
{...props} | ||
type="button" | ||
className={twMerge( | ||
'rounded-full border-2 py-2 px-4', | ||
'bg-mono-0/10 border-mono-60', | ||
'hover:bg-mono-0/30', | ||
'dark:bg-mono-0/5 dark:border-mono-140', | ||
'dark:hover:bg-mono-0/10', | ||
className | ||
)} | ||
ref={ref} | ||
> | ||
<div className="flex items-center justify-center"> | ||
{status === 'loading' ? ( | ||
<Spinner size="lg" /> | ||
) : status === 'success' ? ( | ||
<CheckboxCircleLine | ||
className="fill-green-70 dark:fill-green-50" | ||
size="lg" | ||
/> | ||
) : ( | ||
status === 'error' && ( | ||
<CloseCircleLineIcon | ||
className="fill-red-70 dark:fill-red-50" | ||
size="lg" | ||
/> | ||
) | ||
)} | ||
</div> | ||
</button> | ||
); | ||
} | ||
); | ||
|
||
export default LoadingPill; |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as Button } from './Button'; | ||
export { default as ChainButton } from './ChainButton'; | ||
export { default as WalletButton } from './WalletButton'; | ||
export { default as LoadingPill } from './LoadingPill'; | ||
export * from './types'; |
This file contains 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
25 changes: 25 additions & 0 deletions
25
libs/webb-ui-components/src/stories/molecules/LoadingPill.stories.tsx
This file contains 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,25 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import LoadingPill from '../../components/buttons/LoadingPill'; | ||
|
||
const meta: Meta<typeof LoadingPill> = { | ||
title: 'Design System/V2 (WIP)/Molecules/LoadingPill', | ||
component: LoadingPill, | ||
}; | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof LoadingPill>; | ||
|
||
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
export const Default: Story = { | ||
render: () => <LoadingPill />, | ||
}; | ||
|
||
export const Success: Story = { | ||
render: () => <LoadingPill status="success" />, | ||
}; | ||
|
||
export const Error: Story = { | ||
render: () => <LoadingPill status="error" />, | ||
}; |