mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
added stories for Token and SuccessConfetti
This commit is contained in:
parent
dfa3c5d6cc
commit
b42f44dda0
23
src/components/@shared/SuccessConfetti/index.stories.tsx
Normal file
23
src/components/@shared/SuccessConfetti/index.stories.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { ComponentStory, ComponentMeta } from '@storybook/react'
|
||||||
|
import SuccessConfetti, { SuccessConfettiProps } from '@shared/SuccessConfetti'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Component/@shared/SuccessConfetti',
|
||||||
|
component: SuccessConfetti
|
||||||
|
} as ComponentMeta<typeof SuccessConfetti>
|
||||||
|
|
||||||
|
const Template: ComponentStory<typeof SuccessConfetti> = (
|
||||||
|
args: SuccessConfettiProps
|
||||||
|
) => {
|
||||||
|
return <SuccessConfetti {...args} />
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
args: SuccessConfettiProps
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Default: Props = Template.bind({})
|
||||||
|
Default.args = {
|
||||||
|
success: 'Success'
|
||||||
|
}
|
@ -23,15 +23,17 @@ const confettiConfig = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SuccessConfettiProps {
|
||||||
|
success: string
|
||||||
|
action?: ReactNode
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
export default function SuccessConfetti({
|
export default function SuccessConfetti({
|
||||||
success,
|
success,
|
||||||
action,
|
action,
|
||||||
className
|
className
|
||||||
}: {
|
}: SuccessConfettiProps): ReactElement {
|
||||||
success: string
|
|
||||||
action?: ReactNode
|
|
||||||
className?: string
|
|
||||||
}): ReactElement {
|
|
||||||
// Have some confetti upon success
|
// Have some confetti upon success
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!success || typeof window === 'undefined') return
|
if (!success || typeof window === 'undefined') return
|
||||||
|
26
src/components/@shared/Token/index.stories.tsx
Normal file
26
src/components/@shared/Token/index.stories.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { ComponentStory, ComponentMeta } from '@storybook/react'
|
||||||
|
import Token, { TokenProps } from '@shared/Token'
|
||||||
|
import { locale, currency, prices } from '../../../../.storybook/__mockdata__'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Component/@shared/Token',
|
||||||
|
component: Token
|
||||||
|
} as ComponentMeta<typeof Token>
|
||||||
|
|
||||||
|
const Template: ComponentStory<typeof Token> = (args: TokenProps) => {
|
||||||
|
return <Token {...args} />
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
args: TokenProps
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Default: Props = Template.bind({})
|
||||||
|
Default.args = {
|
||||||
|
symbol: 'ETH',
|
||||||
|
balance: '1',
|
||||||
|
locale,
|
||||||
|
currency,
|
||||||
|
prices
|
||||||
|
}
|
@ -3,24 +3,29 @@ import styles from './index.module.css'
|
|||||||
import PriceUnit from '@shared/Price/PriceUnit'
|
import PriceUnit from '@shared/Price/PriceUnit'
|
||||||
import Logo from '@shared/atoms/Logo'
|
import Logo from '@shared/atoms/Logo'
|
||||||
import Conversion from '@shared/Price/Conversion'
|
import Conversion from '@shared/Price/Conversion'
|
||||||
import { useUserPreferences } from '@context/UserPreferences'
|
import { Prices } from '@context/Prices'
|
||||||
import { usePrices } from '@context/Prices'
|
|
||||||
|
export interface TokenProps {
|
||||||
|
symbol: string
|
||||||
|
balance: string
|
||||||
|
conversion?: boolean
|
||||||
|
noIcon?: boolean
|
||||||
|
size?: 'small' | 'mini'
|
||||||
|
locale: string
|
||||||
|
currency: string
|
||||||
|
prices: Prices
|
||||||
|
}
|
||||||
|
|
||||||
export default function Token({
|
export default function Token({
|
||||||
symbol,
|
symbol,
|
||||||
balance,
|
balance,
|
||||||
conversion,
|
conversion,
|
||||||
noIcon,
|
noIcon,
|
||||||
size
|
size,
|
||||||
}: {
|
locale,
|
||||||
symbol: string
|
currency,
|
||||||
balance: string
|
prices
|
||||||
conversion?: boolean
|
}: TokenProps): ReactElement {
|
||||||
noIcon?: boolean
|
|
||||||
size?: 'small' | 'mini'
|
|
||||||
}): ReactElement {
|
|
||||||
const { locale, currency } = useUserPreferences()
|
|
||||||
const { prices } = usePrices()
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={`${styles.token} ${size ? styles[size] : ''}`}>
|
<div className={`${styles.token} ${size ? styles[size] : ''}`}>
|
||||||
|
@ -4,6 +4,8 @@ import Token from '../../../../@shared/Token'
|
|||||||
import styles from './Output.module.css'
|
import styles from './Output.module.css'
|
||||||
import content from '../../../../../../content/price.json'
|
import content from '../../../../../../content/price.json'
|
||||||
import { usePool } from '@context/Pool'
|
import { usePool } from '@context/Pool'
|
||||||
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
|
import { usePrices } from '@context/Prices'
|
||||||
|
|
||||||
export default function Output({
|
export default function Output({
|
||||||
newPoolTokens,
|
newPoolTokens,
|
||||||
@ -14,6 +16,8 @@ export default function Output({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { help, titleIn } = content.pool.add.output
|
const { help, titleIn } = content.pool.add.output
|
||||||
const { poolInfo } = usePool()
|
const { poolInfo } = usePool()
|
||||||
|
const { locale, currency } = useUserPreferences()
|
||||||
|
const { prices } = usePrices()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -22,8 +26,22 @@ export default function Output({
|
|||||||
</FormHelp>
|
</FormHelp>
|
||||||
<div className={styles.output}>
|
<div className={styles.output}>
|
||||||
<p>{titleIn}</p>
|
<p>{titleIn}</p>
|
||||||
<Token symbol="pool shares" balance={newPoolTokens} noIcon />
|
<Token
|
||||||
<Token symbol="% of pool" balance={newPoolShare} noIcon />
|
symbol="pool shares"
|
||||||
|
balance={newPoolTokens}
|
||||||
|
noIcon
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
|
/>
|
||||||
|
<Token
|
||||||
|
symbol="% of pool"
|
||||||
|
balance={newPoolShare}
|
||||||
|
noIcon
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -22,6 +22,8 @@ import { useAsset } from '@context/Asset'
|
|||||||
import content from '../../../../../../content/price.json'
|
import content from '../../../../../../content/price.json'
|
||||||
import { usePool } from '@context/Pool'
|
import { usePool } from '@context/Pool'
|
||||||
import { getMax } from './_utils'
|
import { getMax } from './_utils'
|
||||||
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
|
import { usePrices } from '@context/Prices'
|
||||||
|
|
||||||
const slippagePresets = ['5', '10', '15', '25', '50']
|
const slippagePresets = ['5', '10', '15', '25', '50']
|
||||||
|
|
||||||
@ -32,6 +34,8 @@ export default function Remove({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId, web3 } = useWeb3()
|
const { accountId, web3 } = useWeb3()
|
||||||
const { isAssetNetwork } = useAsset()
|
const { isAssetNetwork } = useAsset()
|
||||||
|
const { locale, currency } = useUserPreferences()
|
||||||
|
const { prices } = usePrices()
|
||||||
const { poolData, poolInfo, poolInfoUser, fetchAllData } = usePool()
|
const { poolData, poolInfo, poolInfoUser, fetchAllData } = usePool()
|
||||||
|
|
||||||
const [amountPercent, setAmountPercent] = useState('0')
|
const [amountPercent, setAmountPercent] = useState('0')
|
||||||
@ -193,11 +197,20 @@ export default function Remove({
|
|||||||
symbol={poolInfo?.baseTokenSymbol}
|
symbol={poolInfo?.baseTokenSymbol}
|
||||||
balance={amountOcean}
|
balance={amountOcean}
|
||||||
noIcon
|
noIcon
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>{content.pool.remove.output.titleOutMinimum}</p>
|
<p>{content.pool.remove.output.titleOutMinimum}</p>
|
||||||
<Token symbol={poolInfo?.baseTokenSymbol} balance={minOceanAmount} />
|
<Token
|
||||||
|
symbol={poolInfo?.baseTokenSymbol}
|
||||||
|
balance={minOceanAmount}
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.slippage}>
|
<div className={styles.slippage}>
|
||||||
|
@ -93,6 +93,9 @@ export default function PoolSections() {
|
|||||||
symbol={poolInfo?.baseTokenSymbol}
|
symbol={poolInfo?.baseTokenSymbol}
|
||||||
balance={poolInfoUser?.liquidity}
|
balance={poolInfoUser?.liquidity}
|
||||||
conversion
|
conversion
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</PoolSection>
|
</PoolSection>
|
||||||
|
|
||||||
@ -104,6 +107,9 @@ export default function PoolSections() {
|
|||||||
symbol={poolInfo?.baseTokenSymbol}
|
symbol={poolInfo?.baseTokenSymbol}
|
||||||
balance={poolInfoOwner?.liquidity}
|
balance={poolInfoOwner?.liquidity}
|
||||||
conversion
|
conversion
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</PoolSection>
|
</PoolSection>
|
||||||
|
|
||||||
@ -112,6 +118,9 @@ export default function PoolSections() {
|
|||||||
symbol={poolInfo?.baseTokenSymbol}
|
symbol={poolInfo?.baseTokenSymbol}
|
||||||
balance={poolData?.baseTokenLiquidity.toString()}
|
balance={poolData?.baseTokenLiquidity.toString()}
|
||||||
conversion
|
conversion
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</PoolSection>
|
</PoolSection>
|
||||||
|
|
||||||
@ -132,18 +141,27 @@ export default function PoolSections() {
|
|||||||
balance={poolInfo?.liquidityProviderSwapFee}
|
balance={poolInfo?.liquidityProviderSwapFee}
|
||||||
noIcon
|
noIcon
|
||||||
size="mini"
|
size="mini"
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
<Token
|
<Token
|
||||||
symbol="% market fee"
|
symbol="% market fee"
|
||||||
balance={poolInfo?.publishMarketSwapFee}
|
balance={poolInfo?.publishMarketSwapFee}
|
||||||
noIcon
|
noIcon
|
||||||
size="mini"
|
size="mini"
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
<Token
|
<Token
|
||||||
symbol="% OPC fee"
|
symbol="% OPC fee"
|
||||||
balance={oceanCommunitySwapFee}
|
balance={oceanCommunitySwapFee}
|
||||||
noIcon
|
noIcon
|
||||||
size="mini"
|
size="mini"
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</PoolSection>
|
</PoolSection>
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import styles from './Output.module.css'
|
|||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
import { FormTradeData } from './_types'
|
import { FormTradeData } from './_types'
|
||||||
import { usePool } from '@context/Pool'
|
import { usePool } from '@context/Pool'
|
||||||
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
|
import { usePrices } from '@context/Prices'
|
||||||
|
|
||||||
Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 })
|
Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 })
|
||||||
|
|
||||||
@ -19,6 +21,8 @@ export default function Output({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { isAssetNetwork } = useAsset()
|
const { isAssetNetwork } = useAsset()
|
||||||
const { poolInfo } = usePool()
|
const { poolInfo } = usePool()
|
||||||
|
const { locale, currency } = useUserPreferences()
|
||||||
|
const { prices } = usePrices()
|
||||||
const [outputWithSlippage, setOutputWithSlippage] = useState<string>('0')
|
const [outputWithSlippage, setOutputWithSlippage] = useState<string>('0')
|
||||||
// Connect with form
|
// Connect with form
|
||||||
const { values }: FormikContextType<FormTradeData> = useFormikContext()
|
const { values }: FormikContextType<FormTradeData> = useFormikContext()
|
||||||
@ -73,6 +77,9 @@ export default function Output({
|
|||||||
: poolInfo.datatokenSymbol
|
: poolInfo.datatokenSymbol
|
||||||
}
|
}
|
||||||
balance={outputWithSlippage}
|
balance={outputWithSlippage}
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -88,6 +95,9 @@ export default function Output({
|
|||||||
: ''
|
: ''
|
||||||
}`}
|
}`}
|
||||||
balance={lpSwapFee}
|
balance={lpSwapFee}
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,6 +55,9 @@ export function Liquidity({
|
|||||||
symbol={row.poolShare.pool.baseToken.symbol}
|
symbol={row.poolShare.pool.baseToken.symbol}
|
||||||
balance={liquidity}
|
balance={liquidity}
|
||||||
noIcon
|
noIcon
|
||||||
|
locale={locale}
|
||||||
|
currency={currency}
|
||||||
|
prices={prices}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user