From af31b25ef2f67c66e149b7c15c095f538dd39c3b Mon Sep 17 00:00:00 2001 From: ClaudiaHolhos Date: Mon, 20 Jun 2022 16:36:55 +0300 Subject: [PATCH] remove locale, currency and prices as props, use providers for stories --- .../AssetComputeList/index.stories.tsx | 5 +---- .../@shared/AssetList/index.stories.tsx | 5 +---- .../@shared/AssetTeaser/index.stories.tsx | 3 --- .../AssetSelection/index.stories.tsx | 12 +++-------- .../FormFields/AssetSelection/index.tsx | 3 --- .../@shared/FormInput/InputElement.tsx | 11 +--------- .../Price/Conversion/index.stories.tsx | 13 +++++++++++- .../@shared/Price/PriceUnit/index.stories.tsx | 20 +++++++++---------- 8 files changed, 28 insertions(+), 44 deletions(-) diff --git a/src/components/@shared/AssetList/AssetComputeList/index.stories.tsx b/src/components/@shared/AssetList/AssetComputeList/index.stories.tsx index 2b2d8ce02..e6c90db1b 100644 --- a/src/components/@shared/AssetList/AssetComputeList/index.stories.tsx +++ b/src/components/@shared/AssetList/AssetComputeList/index.stories.tsx @@ -24,8 +24,5 @@ interface Props { export const Default: Props = Template.bind({}) Default.args = { - assets: assetSelectionAsset, - locale, - currency: 'OCEAN', - prices + assets: assetSelectionAsset } diff --git a/src/components/@shared/AssetList/index.stories.tsx b/src/components/@shared/AssetList/index.stories.tsx index c44016e30..5693f86de 100644 --- a/src/components/@shared/AssetList/index.stories.tsx +++ b/src/components/@shared/AssetList/index.stories.tsx @@ -29,11 +29,8 @@ interface Props { export const Default: Props = Template.bind({}) Default.args = { - locale, assets, showPagination: false, chainIds: config.chainIds, - accountId: mockWallet, - currency: 'OCEAN', - prices + accountId: mockWallet } diff --git a/src/components/@shared/AssetTeaser/index.stories.tsx b/src/components/@shared/AssetTeaser/index.stories.tsx index 006250ea1..291cb38c1 100644 --- a/src/components/@shared/AssetTeaser/index.stories.tsx +++ b/src/components/@shared/AssetTeaser/index.stories.tsx @@ -25,8 +25,5 @@ interface Props { export const Default: Props = Template.bind({}) Default.args = { - locale, - currency, - prices, asset: assetExtended } diff --git a/src/components/@shared/FormFields/AssetSelection/index.stories.tsx b/src/components/@shared/FormFields/AssetSelection/index.stories.tsx index 8dacb392a..915aaf0d6 100644 --- a/src/components/@shared/FormFields/AssetSelection/index.stories.tsx +++ b/src/components/@shared/FormFields/AssetSelection/index.stories.tsx @@ -24,23 +24,17 @@ interface Props { export const Default: Props = Template.bind({}) Default.args = { - assets: assetSelectionAsset, - currency: 'OCEAN', - prices + assets: assetSelectionAsset } export const Multiple: Props = Template.bind({}) Multiple.args = { assets: assetSelectionAsset, - multiple: true, - currency: 'OCEAN', - prices + multiple: true } export const Disabled: Props = Template.bind({}) Disabled.args = { assets: assetSelectionAsset, - disabled: true, - currency: 'OCEAN', - prices + disabled: true } diff --git a/src/components/@shared/FormFields/AssetSelection/index.tsx b/src/components/@shared/FormFields/AssetSelection/index.tsx index 64af4bb23..d07d3c1b8 100644 --- a/src/components/@shared/FormFields/AssetSelection/index.tsx +++ b/src/components/@shared/FormFields/AssetSelection/index.tsx @@ -7,7 +7,6 @@ import External from '@images/external.svg' import InputElement from '@shared/FormInput/InputElement' import Loader from '@shared/atoms/Loader' import styles from './index.module.css' -import { Prices } from '@context/Prices' const cx = classNames.bind(styles) @@ -21,8 +20,6 @@ export interface AssetSelectionAsset { export interface AssetSelectionProps { assets: AssetSelectionAsset[] - currency: string - prices: Prices multiple?: boolean disabled?: boolean } diff --git a/src/components/@shared/FormInput/InputElement.tsx b/src/components/@shared/FormInput/InputElement.tsx index 902289879..9ff9a409e 100644 --- a/src/components/@shared/FormInput/InputElement.tsx +++ b/src/components/@shared/FormInput/InputElement.tsx @@ -11,8 +11,6 @@ import AssetSelection, { } from '../FormFields/AssetSelection' import Nft from '../FormFields/Nft' import InputRadio from './InputRadio' -import { useUserPreferences } from '@context/UserPreferences' -import { usePrices } from '@context/Prices' const cx = classNames.bind(styles) @@ -57,8 +55,7 @@ export default function InputElement({ ...props }: InputProps): ReactElement { const styleClasses = cx({ select: true, [size]: size }) - const { locale, currency } = useUserPreferences() - const { prices } = usePrices() + switch (props.type) { case 'select': { const sortedOptions = @@ -95,9 +92,6 @@ export default function InputElement({ return ( @@ -107,9 +101,6 @@ export default function InputElement({ return ( const Template: ComponentStory = (args: ConversionProps) => { - return + return ( + + + + + + + + ) } interface Props { diff --git a/src/components/@shared/Price/PriceUnit/index.stories.tsx b/src/components/@shared/Price/PriceUnit/index.stories.tsx index 02614e25c..42aaf0406 100644 --- a/src/components/@shared/Price/PriceUnit/index.stories.tsx +++ b/src/components/@shared/Price/PriceUnit/index.stories.tsx @@ -1,11 +1,8 @@ import React from 'react' import { ComponentStory, ComponentMeta } from '@storybook/react' import PriceUnit, { PriceUnitProps } from '@shared/Price/PriceUnit' -import { - locale, - currency, - prices -} from '../../../../../.storybook/__mockdata__' +import MarketMetadataProvider from '@context/MarketMetadata' +import PricesProvider from '@context/Prices' export default { title: 'Component/@shared/Price/PriceUnit', @@ -13,7 +10,13 @@ export default { } as ComponentMeta const Template: ComponentStory = (args: PriceUnitProps) => { - return + return ( + + + + + + ) } interface Props { @@ -22,8 +25,5 @@ interface Props { export const Default: Props = Template.bind({}) Default.args = { - price: '11.12333', - locale, - currency, - prices + price: '11.12333' }