-
Notifications
You must be signed in to change notification settings - Fork 8
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
Pivi
authored and
Pivi
committed
Jul 31, 2023
1 parent
525e4fe
commit 25a835b
Showing
4 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MassaLogo } from '../Icons'; | ||
import { Token } from './Token'; | ||
|
||
export default { title: 'Components/Token', component: Token }; | ||
|
||
export const _Token = { | ||
render: () => ( | ||
<> | ||
<Token | ||
logo={<MassaLogo size={40} />} | ||
balance={'000,000,000.00'} | ||
name={'Token'} | ||
symbol={'SYMBL'} | ||
tooltipContent={'000,000,000.000000000'} | ||
onDelete={() => console.log('delete')} | ||
/> | ||
</> | ||
), | ||
}; |
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,13 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { Token } from '.'; | ||
|
||
describe('Components | Toggle', () => { | ||
test('it should render', () => { | ||
render(<Token />); | ||
|
||
let toggle = screen.getByTestId('token'); | ||
|
||
expect(toggle).toBeInTheDocument(); | ||
}); | ||
}); |
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,52 @@ | ||
import { ComponentPropsWithoutRef } from 'react'; | ||
import { FiTrash } from 'react-icons/fi'; | ||
import { Button } from '../Button'; | ||
import { Tooltip } from '../Tooltip'; | ||
|
||
export interface ToggleProps extends ComponentPropsWithoutRef<'div'> { | ||
customClass?: string; | ||
logo?: JSX.Element; | ||
name?: string; | ||
symbol?: string; | ||
balance?: string; | ||
tooltipContent?: string; | ||
onDelete?: () => void; | ||
} | ||
|
||
export function Token({ ...props }) { | ||
const { | ||
string, | ||
name, | ||
symbol, | ||
logo, | ||
balance, | ||
tooltipContent, | ||
onDelete, | ||
customClass, | ||
...rest | ||
} = props; | ||
return ( | ||
<div data-testid="token" className="w-full h-fit bg-primary" {...rest}> | ||
<div | ||
className={`w-full flex justify-between items-center text-neutral ${customClass}`} | ||
> | ||
<div className="flex w-fit gap-2 items-center"> | ||
{logo} | ||
<div> | ||
<p>{`${name} (${symbol})`} </p> | ||
<span className="flex items-center gap-2"> | ||
<p>{balance}</p> | ||
{/* see wallet for tooltip size */} | ||
<Tooltip content={tooltipContent} /> | ||
</span> | ||
</div> | ||
</div> | ||
<div> | ||
<Button variant="icon" onClick={onDelete}> | ||
<FiTrash /> | ||
</Button> | ||
</div> | ||
</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 './Token'; |