-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transaction table and transactions details (#95)
- Loading branch information
Showing
29 changed files
with
643 additions
and
53 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
packages/circle-demo-webapp/app/components/TokenItem/TokenItem.stories.ts
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,33 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Token } from '~/lib/types'; | ||
|
||
import { TokenItem } from './TokenItem'; | ||
|
||
const meta = { | ||
title: 'TokenItem', | ||
component: TokenItem, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof TokenItem>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
token: { | ||
blockchain: 'ARB-SEPOLIA', | ||
createDate: '2024-08-12T21:58:31Z', | ||
decimals: 18, | ||
id: '9ad91eb5-e152-5d81-b60e-151d5fd2b3d3', | ||
isNative: true, | ||
name: 'Arbitrum Ethereum-Sepolia', | ||
symbol: 'ETH-SEPOLIA', | ||
updateDate: '2024-08-12T21:58:31Z', | ||
} as Token, | ||
}, | ||
}; |
23 changes: 23 additions & 0 deletions
23
packages/circle-demo-webapp/app/components/TokenItem/TokenItem.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,23 @@ | ||
import { TokenIcon } from '@web3icons/react'; | ||
|
||
import { Token } from '~/lib/types'; | ||
|
||
export interface TokenItemProps { | ||
/** The balance details */ | ||
token: Token; | ||
} | ||
|
||
/** A token balance for an on-chain account */ | ||
export function TokenItem({ token }: TokenItemProps) { | ||
return ( | ||
<div className="flex items-center space-x-2"> | ||
<TokenIcon | ||
symbol={token.symbol.split('-')[0]} | ||
size={24} | ||
variant="branded" | ||
className="flex-shrink-0" | ||
/> | ||
<div className="text-sm text-muted-foreground">{token.symbol}</div> | ||
</div> | ||
); | ||
} |
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 @@ | ||
export * from './TokenItem'; |
21 changes: 21 additions & 0 deletions
21
...s/circle-demo-webapp/app/components/TransactionStatusText/TransactionStateText.stories.ts
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,21 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { TransactionState } from '~/lib/constants'; | ||
|
||
import { TransactionStateText } from './TransactionStateText'; | ||
|
||
const meta = { | ||
title: 'TransactionStateText', | ||
component: TransactionStateText, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof TransactionStateText>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
state: TransactionState.Complete, | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
packages/circle-demo-webapp/app/components/TransactionStatusText/TransactionStateText.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,33 @@ | ||
import { Badge } from '~/components/ui/badge'; | ||
import { TransactionState } from '~/lib/constants'; | ||
|
||
export interface TransactionStateTextProps { | ||
state: (typeof TransactionState)[keyof typeof TransactionState]; | ||
} | ||
|
||
const greenStates = [TransactionState.Complete, TransactionState.Confirmed]; | ||
const yellowStates = [ | ||
TransactionState.Sent, | ||
TransactionState.Initiated, | ||
TransactionState.Queued, | ||
TransactionState.PendingRiskScreening, | ||
]; | ||
|
||
const capitalize = (str: string) => | ||
str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); | ||
|
||
export function TransactionStateText({ state }: TransactionStateTextProps) { | ||
return greenStates.includes(state) ? ( | ||
<Badge variant="accent" className="font-normal text-green-600 dark:text-green-500"> | ||
{capitalize(state)} ✓ | ||
</Badge> | ||
) : yellowStates.includes(state) ? ( | ||
<Badge variant="accent" className="font-normal text-yellow-500 dark:text-yellow-400"> | ||
{capitalize(state)} | ||
</Badge> | ||
) : ( | ||
<Badge variant="accent" className="font-normal text-red-500 dark:text-red-400"> | ||
{capitalize(state)} ✘ | ||
</Badge> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/circle-demo-webapp/app/components/TransactionStatusText/index.ts
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 @@ | ||
export * from './TransactionStateText'; |
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
22 changes: 11 additions & 11 deletions
22
packages/circle-demo-webapp/app/components/TransactionTableRow/TransactionTableRow.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
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
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
31 changes: 31 additions & 0 deletions
31
packages/circle-demo-webapp/app/components/ui/inputWithIcon.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,31 @@ | ||
import { Search } from 'lucide-react'; | ||
import * as React from 'react'; | ||
|
||
import { cn } from '~/lib/utils'; | ||
|
||
interface InputProps extends React.ComponentProps<'input'> { | ||
className?: string; | ||
type?: string; | ||
} | ||
|
||
const InputWithIcon = React.forwardRef<HTMLInputElement, InputProps>( | ||
({ className, type, ...props }, ref) => { | ||
return ( | ||
<div className="relative"> | ||
<Search className="absolute mt-2 ml-[9px] w-[17px]" /> | ||
<input | ||
type={type} | ||
className={cn( | ||
'border border-input py-2 justify-between h-10 flex w-full px-8 rounded-md bg-background text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', | ||
className, | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
</div> | ||
); | ||
}, | ||
); | ||
InputWithIcon.displayName = 'InputWithIcon'; | ||
|
||
export { InputWithIcon }; |
112 changes: 112 additions & 0 deletions
112
packages/circle-demo-webapp/app/components/ui/pagination.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,112 @@ | ||
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'; | ||
import * as React from 'react'; | ||
|
||
import { ButtonProps, buttonVariants } from '~/components/ui/button'; | ||
import { cn } from '~/lib/utils'; | ||
|
||
const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => ( | ||
<nav | ||
role="navigation" | ||
aria-label="pagination" | ||
className={cn('mx-auto flex w-full justify-center', className)} | ||
{...props} | ||
/> | ||
); | ||
Pagination.displayName = 'Pagination'; | ||
|
||
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>( | ||
({ className, ...props }, ref) => ( | ||
<ul | ||
ref={ref} | ||
className={cn('flex flex-row items-center gap-1', className)} | ||
{...props} | ||
/> | ||
), | ||
); | ||
PaginationContent.displayName = 'PaginationContent'; | ||
|
||
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>( | ||
({ className, ...props }, ref) => ( | ||
<li ref={ref} className={cn('', className)} {...props} /> | ||
), | ||
); | ||
PaginationItem.displayName = 'PaginationItem'; | ||
|
||
type PaginationLinkProps = { | ||
isActive?: boolean; | ||
} & Pick<ButtonProps, 'size'> & | ||
React.ComponentProps<'a'>; | ||
|
||
const PaginationLink = ({ | ||
className, | ||
isActive, | ||
size = 'icon', | ||
...props | ||
}: PaginationLinkProps) => ( | ||
<a | ||
aria-current={isActive ? 'page' : undefined} | ||
className={cn( | ||
buttonVariants({ | ||
variant: isActive ? 'outline' : 'ghost', | ||
size, | ||
}), | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
); | ||
PaginationLink.displayName = 'PaginationLink'; | ||
|
||
const PaginationPrevious = ({ | ||
className, | ||
...props | ||
}: React.ComponentProps<typeof PaginationLink>) => ( | ||
<PaginationLink | ||
aria-label="Go to previous page" | ||
size="default" | ||
className={cn('gap-1 pl-2.5', className)} | ||
{...props} | ||
> | ||
<ChevronLeft className="h-4 w-4" /> | ||
<span>Previous</span> | ||
</PaginationLink> | ||
); | ||
PaginationPrevious.displayName = 'PaginationPrevious'; | ||
|
||
const PaginationNext = ({ | ||
className, | ||
...props | ||
}: React.ComponentProps<typeof PaginationLink>) => ( | ||
<PaginationLink | ||
aria-label="Go to next page" | ||
size="default" | ||
className={cn('gap-1 pr-2.5', className)} | ||
{...props} | ||
> | ||
<span>Next</span> | ||
<ChevronRight className="h-4 w-4" /> | ||
</PaginationLink> | ||
); | ||
PaginationNext.displayName = 'PaginationNext'; | ||
|
||
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => ( | ||
<span | ||
aria-hidden | ||
className={cn('flex h-9 w-9 items-center justify-center', className)} | ||
{...props} | ||
> | ||
<MoreHorizontal className="h-4 w-4" /> | ||
<span className="sr-only">More pages</span> | ||
</span> | ||
); | ||
PaginationEllipsis.displayName = 'PaginationEllipsis'; | ||
|
||
export { | ||
Pagination, | ||
PaginationContent, | ||
PaginationEllipsis, | ||
PaginationItem, | ||
PaginationLink, | ||
PaginationNext, | ||
PaginationPrevious, | ||
}; |
Oops, something went wrong.