1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

added AddToken story (needs improvements)

This commit is contained in:
Enzo Vezzaro 2022-05-30 09:44:23 -04:00
parent dde191630d
commit f4fc47c6d0
4 changed files with 48 additions and 13 deletions

View File

@ -0,0 +1,31 @@
import React from 'react'
import { ComponentStory, ComponentMeta } from '@storybook/react'
import AddToken, { AddTokenProps } from '@shared/AddToken'
export default {
title: 'Component/@shared/AddToken',
component: AddToken
} as ComponentMeta<typeof AddToken>
const Template: ComponentStory<typeof AddToken> = (args: AddTokenProps) => (
<AddToken {...args} />
)
interface Props {
args: AddTokenProps
}
export const Default: Props = Template.bind({})
Default.args = {
address: '0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8',
symbol: 'OCEAN',
logo: 'https://raw.githubusercontent.com/oceanprotocol/art/main/logo/datatoken.png'
}
export const Minimal: Props = Template.bind({})
Minimal.args = {
address: '0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8',
symbol: 'OCEAN',
logo: 'https://raw.githubusercontent.com/oceanprotocol/art/main/logo/datatoken.png',
minimal: true
}

View File

@ -1,29 +1,31 @@
import React, { ReactElement } from 'react' import React, { ReactElement } from 'react'
import classNames from 'classnames/bind' import classNames from 'classnames/bind'
import { addTokenToWallet } from '@utils/web3' import { addTokenToWallet } from '@utils/web3'
import { useWeb3 } from '@context/Web3'
import Button from '@shared/atoms/Button' import Button from '@shared/atoms/Button'
import styles from './index.module.css' import styles from './index.module.css'
import { IProviderInfo } from 'web3modal'
const cx = classNames.bind(styles) const cx = classNames.bind(styles)
export interface AddTokenProps {
address: string
symbol: string
logo: string // needs to be a remote image
text?: string
className?: string
minimal?: boolean
web3Provider: IProviderInfo
}
export default function AddToken({ export default function AddToken({
address, address,
symbol, symbol,
logo, logo,
text, text,
className, className,
minimal minimal,
}: { web3Provider
address: string }: AddTokenProps): ReactElement {
symbol: string
logo: string // needs to be a remote image
text?: string
className?: string
minimal?: boolean
}): ReactElement {
const { web3Provider } = useWeb3()
const styleClasses = cx({ const styleClasses = cx({
button: true, button: true,
minimal, minimal,

View File

@ -15,7 +15,7 @@ export default function MetaAsset({
isBlockscoutExplorer: boolean isBlockscoutExplorer: boolean
}): ReactElement { }): ReactElement {
const { isAssetNetwork } = useAsset() const { isAssetNetwork } = useAsset()
const { web3ProviderInfo } = useWeb3() const { web3Provider, web3ProviderInfo } = useWeb3()
const dataTokenSymbol = asset?.datatokens[0]?.symbol const dataTokenSymbol = asset?.datatokens[0]?.symbol
@ -45,6 +45,7 @@ export default function MetaAsset({
text={`Add ${(asset as Asset)?.datatokens[0]?.symbol} to wallet`} text={`Add ${(asset as Asset)?.datatokens[0]?.symbol} to wallet`}
className={styles.add} className={styles.add}
minimal minimal
web3Provider={web3Provider}
/> />
</span> </span>
)} )}

View File

@ -92,6 +92,7 @@ export default function Details(): ReactElement {
symbol={oceanTokenMetadata?.symbol} symbol={oceanTokenMetadata?.symbol}
logo="https://raw.githubusercontent.com/oceanprotocol/art/main/logo/token.png" logo="https://raw.githubusercontent.com/oceanprotocol/art/main/logo/token.png"
className={styles.addToken} className={styles.addToken}
web3Provider={web3Provider}
/> />
)} )}
</div> </div>