diff --git a/.eslintrc.js b/.eslintrc.js index 179b5859e59..e989083566b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -909,5 +909,10 @@ module.exports = { 'no-loss-of-precision': 'off', }, - ignorePatterns: ['wdio.conf.js', 'app/util/termsOfUse/termsOfUseContent.ts'], + ignorePatterns: [ + 'wdio.conf.js', + 'app/util/termsOfUse/termsOfUseContent.ts', + '!.storybook', + '!.storybook/**', + ], }; diff --git a/.storybook/index.js b/.storybook/index.js index e8773f90e69..d4ec36674f6 100644 --- a/.storybook/index.js +++ b/.storybook/index.js @@ -1,4 +1,6 @@ +import React, { useEffect } from 'react'; import { getStorybookUI } from '@storybook/react-native'; +import { hideAsync } from 'expo-splash-screen'; import './storybook.requires'; @@ -6,4 +8,14 @@ const StorybookUIRoot = getStorybookUI({ asyncStorage: null, }); -export { StorybookUIRoot as default }; +function StorybookRoot() { + useEffect(() => { + hideAsync().catch(() => { + // Non-fatal — Storybook can still render if splash hide fails + }); + }, []); + + return ; +} + +export { StorybookRoot as default }; diff --git a/.storybook/storybook.requires.js b/.storybook/storybook.requires.js index 661188f3376..679e927255d 100644 --- a/.storybook/storybook.requires.js +++ b/.storybook/storybook.requires.js @@ -6,27 +6,27 @@ import { addParameters, addArgsEnhancer, clearDecorators, -} from "@storybook/react-native"; +} from '@storybook/react-native'; global.STORIES = [ { - titlePrefix: "", - directory: "./app", - files: "**/*.stories.?(ts|tsx|js|jsx)", + titlePrefix: '', + directory: './app', + files: '**/*.stories.?(ts|tsx|js|jsx)', importPathMatcher: - "^\\.[\\\\/](?:app(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$", + '^\\.[\\\\/](?:app(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$', }, ]; -import "@storybook/addon-ondevice-controls/register"; +import '@storybook/addon-ondevice-controls/register'; -import { decorators, parameters } from "./preview"; +import { decorators, parameters } from './preview'; if (decorators) { if (__DEV__) { // stops the warning from showing on every HMR - require("react-native").LogBox.ignoreLogs([ - "`clearDecorators` is deprecated and will be removed in Storybook 7.0", + require('react-native').LogBox.ignoreLogs([ + '`clearDecorators` is deprecated and will be removed in Storybook 7.0', ]); } // workaround for global decorators getting infinitely applied on HMR, see https://github.com/storybookjs/react-native/issues/185 @@ -38,116 +38,126 @@ if (parameters) { addParameters(parameters); } -const getStories = () => { - return { - "./app/component-library/base-components/TagBase/TagBase.stories.tsx": require("../app/component-library/base-components/TagBase/TagBase.stories.tsx"), - "./app/component-library/components-temp/ActionListItem/ActionListItem.stories.tsx": require("../app/component-library/components-temp/ActionListItem/ActionListItem.stories.tsx"), - "./app/component-library/components-temp/ButtonFilter/ButtonFilter.stories.tsx": require("../app/component-library/components-temp/ButtonFilter/ButtonFilter.stories.tsx"), - "./app/component-library/components-temp/Buttons/ButtonHero/ButtonHero.stories.tsx": require("../app/component-library/components-temp/Buttons/ButtonHero/ButtonHero.stories.tsx"), - "./app/component-library/components-temp/Buttons/ButtonSemantic/ButtonSemantic.stories.tsx": require("../app/component-library/components-temp/Buttons/ButtonSemantic/ButtonSemantic.stories.tsx"), - "./app/component-library/components-temp/Buttons/ButtonToggle/ButtonToggle.stories.tsx": require("../app/component-library/components-temp/Buttons/ButtonToggle/ButtonToggle.stories.tsx"), - "./app/component-library/components-temp/CellSelectWithMenu/CellSelectWithMenu.stories.tsx": require("../app/component-library/components-temp/CellSelectWithMenu/CellSelectWithMenu.stories.tsx"), - "./app/component-library/components-temp/HeaderCompactStandard/HeaderCompactStandard.stories.tsx": require("../app/component-library/components-temp/HeaderCompactStandard/HeaderCompactStandard.stories.tsx"), - "./app/component-library/components-temp/HeaderRoot/HeaderRoot.stories.tsx": require("../app/component-library/components-temp/HeaderRoot/HeaderRoot.stories.tsx"), - "./app/component-library/components-temp/HeaderSearch/HeaderSearch.stories.tsx": require("../app/component-library/components-temp/HeaderSearch/HeaderSearch.stories.tsx"), - "./app/component-library/components-temp/HeaderStandardAnimated/HeaderStandardAnimated.stories.tsx": require("../app/component-library/components-temp/HeaderStandardAnimated/HeaderStandardAnimated.stories.tsx"), - "./app/component-library/components-temp/KeyValueRow/KeyValueRow.stories.tsx": require("../app/component-library/components-temp/KeyValueRow/KeyValueRow.stories.tsx"), - "./app/component-library/components-temp/ListItemMultiSelectButton/ListItemMultiSelectButton.stories.tsx": require("../app/component-library/components-temp/ListItemMultiSelectButton/ListItemMultiSelectButton.stories.tsx"), - "./app/component-library/components-temp/ListItemMultiSelectWithMenuButton/ListItemMultiSelectWithMenuButton.stories.tsx": require("../app/component-library/components-temp/ListItemMultiSelectWithMenuButton/ListItemMultiSelectWithMenuButton.stories.tsx"), - "./app/component-library/components-temp/MainActionButton/MainActionButton.stories.tsx": require("../app/component-library/components-temp/MainActionButton/MainActionButton.stories.tsx"), - "./app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.stories.tsx": require("../app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.stories.tsx"), - "./app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/MultichainAccountSelectorList.stories.tsx": require("../app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/MultichainAccountSelectorList.stories.tsx"), - "./app/component-library/components-temp/MultichainAccounts/MultichainAddressRow/MultichainAddressRow.stories.tsx": require("../app/component-library/components-temp/MultichainAccounts/MultichainAddressRow/MultichainAddressRow.stories.tsx"), - "./app/component-library/components-temp/MultichainAccounts/MultichainAddressRowsList/MultichainAddressRowsList.stories.tsx": require("../app/component-library/components-temp/MultichainAccounts/MultichainAddressRowsList/MultichainAddressRowsList.stories.tsx"), - "./app/component-library/components-temp/Pressable/Pressable.stories.tsx": require("../app/component-library/components-temp/Pressable/Pressable.stories.tsx"), - "./app/component-library/components-temp/Price/PercentageChange/PercentageChange.stories.tsx": require("../app/component-library/components-temp/Price/PercentageChange/PercentageChange.stories.tsx"), - "./app/component-library/components-temp/SectionHeader/SectionHeader.stories.tsx": require("../app/component-library/components-temp/SectionHeader/SectionHeader.stories.tsx"), - "./app/component-library/components-temp/TabBar/TabBar.stories.tsx": require("../app/component-library/components-temp/TabBar/TabBar.stories.tsx"), - "./app/component-library/components-temp/TabEmptyState/TabEmptyState.stories.tsx": require("../app/component-library/components-temp/TabEmptyState/TabEmptyState.stories.tsx"), - "./app/component-library/components-temp/Tabs/Tabs.stories.tsx": require("../app/component-library/components-temp/Tabs/Tabs.stories.tsx"), - "./app/component-library/components-temp/TagColored/TagColored.stories.tsx": require("../app/component-library/components-temp/TagColored/TagColored.stories.tsx"), - "./app/component-library/components-temp/TitleStandard/TitleStandard.stories.tsx": require("../app/component-library/components-temp/TitleStandard/TitleStandard.stories.tsx"), - "./app/component-library/components-temp/TitleSubpage/TitleSubpage.stories.tsx": require("../app/component-library/components-temp/TitleSubpage/TitleSubpage.stories.tsx"), - "./app/component-library/components/Accordions/Accordion/Accordion.stories.tsx": require("../app/component-library/components/Accordions/Accordion/Accordion.stories.tsx"), - "./app/component-library/components/Accordions/Accordion/foundation/AccordionHeader/AccordionHeader.stories.tsx": require("../app/component-library/components/Accordions/Accordion/foundation/AccordionHeader/AccordionHeader.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/Avatar.stories.tsx": require("../app/component-library/components/Avatars/Avatar/Avatar.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/variants/AvatarAccount/AvatarAccount.stories.tsx": require("../app/component-library/components/Avatars/Avatar/variants/AvatarAccount/AvatarAccount.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/variants/AvatarFavicon/AvatarFavicon.stories.tsx": require("../app/component-library/components/Avatars/Avatar/variants/AvatarFavicon/AvatarFavicon.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/variants/AvatarIcon/AvatarIcon.stories.tsx": require("../app/component-library/components/Avatars/Avatar/variants/AvatarIcon/AvatarIcon.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/variants/AvatarNetwork/AvatarNetwork.stories.tsx": require("../app/component-library/components/Avatars/Avatar/variants/AvatarNetwork/AvatarNetwork.stories.tsx"), - "./app/component-library/components/Avatars/Avatar/variants/AvatarToken/AvatarToken.stories.tsx": require("../app/component-library/components/Avatars/Avatar/variants/AvatarToken/AvatarToken.stories.tsx"), - "./app/component-library/components/Avatars/AvatarGroup/AvatarGroup.stories.tsx": require("../app/component-library/components/Avatars/AvatarGroup/AvatarGroup.stories.tsx"), - "./app/component-library/components/Badges/Badge/Badge.stories.tsx": require("../app/component-library/components/Badges/Badge/Badge.stories.tsx"), - "./app/component-library/components/Badges/Badge/variants/BadgeNetwork/BadgeNetwork.stories.tsx": require("../app/component-library/components/Badges/Badge/variants/BadgeNetwork/BadgeNetwork.stories.tsx"), - "./app/component-library/components/Badges/Badge/variants/BadgeNotifications/BadgeNotifications.stories.tsx": require("../app/component-library/components/Badges/Badge/variants/BadgeNotifications/BadgeNotifications.stories.tsx"), - "./app/component-library/components/Badges/Badge/variants/BadgeStatus/BadgeStatus.stories.tsx": require("../app/component-library/components/Badges/Badge/variants/BadgeStatus/BadgeStatus.stories.tsx"), - "./app/component-library/components/Badges/BadgeWrapper/BadgeWrapper.stories.tsx": require("../app/component-library/components/Badges/BadgeWrapper/BadgeWrapper.stories.tsx"), - "./app/component-library/components/Banners/Banner/Banner.stories.tsx": require("../app/component-library/components/Banners/Banner/Banner.stories.tsx"), - "./app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx": require("../app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx"), - "./app/component-library/components/Banners/Banner/variants/BannerTip/BannerTip.stories.tsx": require("../app/component-library/components/Banners/Banner/variants/BannerTip/BannerTip.stories.tsx"), - "./app/component-library/components/BottomSheets/BottomSheet/BottomSheet.stories.tsx": require("../app/component-library/components/BottomSheets/BottomSheet/BottomSheet.stories.tsx"), - "./app/component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.stories.tsx": require("../app/component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.stories.tsx"), - "./app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx": require("../app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx"), - "./app/component-library/components/Buttons/Button/Button.stories.tsx": require("../app/component-library/components/Buttons/Button/Button.stories.tsx"), - "./app/component-library/components/Buttons/Button/variants/ButtonLink/ButtonLink.stories.tsx": require("../app/component-library/components/Buttons/Button/variants/ButtonLink/ButtonLink.stories.tsx"), - "./app/component-library/components/Buttons/Button/variants/ButtonPrimary/ButtonPrimary.stories.tsx": require("../app/component-library/components/Buttons/Button/variants/ButtonPrimary/ButtonPrimary.stories.tsx"), - "./app/component-library/components/Buttons/Button/variants/ButtonSecondary/ButtonSecondary.stories.tsx": require("../app/component-library/components/Buttons/Button/variants/ButtonSecondary/ButtonSecondary.stories.tsx"), - "./app/component-library/components/Buttons/ButtonIcon/ButtonIcon.stories.tsx": require("../app/component-library/components/Buttons/ButtonIcon/ButtonIcon.stories.tsx"), - "./app/component-library/components/Cards/Card/Card.stories.tsx": require("../app/component-library/components/Cards/Card/Card.stories.tsx"), - "./app/component-library/components/Cells/Cell/Cell.stories.tsx": require("../app/component-library/components/Cells/Cell/Cell.stories.tsx"), - "./app/component-library/components/Cells/Cell/variants/CellDisplay/CellDisplay.stories.tsx": require("../app/component-library/components/Cells/Cell/variants/CellDisplay/CellDisplay.stories.tsx"), - "./app/component-library/components/Cells/Cell/variants/CellMultiSelect/CellMultiSelect.stories.tsx": require("../app/component-library/components/Cells/Cell/variants/CellMultiSelect/CellMultiSelect.stories.tsx"), - "./app/component-library/components/Cells/Cell/variants/CellSelect/CellSelect.stories.tsx": require("../app/component-library/components/Cells/Cell/variants/CellSelect/CellSelect.stories.tsx"), - "./app/component-library/components/Checkbox/Checkbox.stories.tsx": require("../app/component-library/components/Checkbox/Checkbox.stories.tsx"), - "./app/component-library/components/design-system.stories.tsx": require("../app/component-library/components/design-system.stories.tsx"), - "./app/component-library/components/Form/HelpText/HelpText.stories.tsx": require("../app/component-library/components/Form/HelpText/HelpText.stories.tsx"), - "./app/component-library/components/Form/Label/Label.stories.tsx": require("../app/component-library/components/Form/Label/Label.stories.tsx"), - "./app/component-library/components/Form/TextField/foundation/Input/Input.stories.tsx": require("../app/component-library/components/Form/TextField/foundation/Input/Input.stories.tsx"), - "./app/component-library/components/Form/TextField/TextField.stories.tsx": require("../app/component-library/components/Form/TextField/TextField.stories.tsx"), - "./app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx": require("../app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx"), - "./app/component-library/components/HeaderBase/HeaderBase.stories.tsx": require("../app/component-library/components/HeaderBase/HeaderBase.stories.tsx"), - "./app/component-library/components/Icons/Icon/Icon.stories.tsx": require("../app/component-library/components/Icons/Icon/Icon.stories.tsx"), - "./app/component-library/components/List/ListItem/ListItem.stories.tsx": require("../app/component-library/components/List/ListItem/ListItem.stories.tsx"), - "./app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx": require("../app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx"), - "./app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx": require("../app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx"), - "./app/component-library/components/Modals/ModalConfirmation/ModalConfirmation.stories.tsx": require("../app/component-library/components/Modals/ModalConfirmation/ModalConfirmation.stories.tsx"), - "./app/component-library/components/Modals/ModalMandatory/ModalMandatory.stories.tsx": require("../app/component-library/components/Modals/ModalMandatory/ModalMandatory.stories.tsx"), - "./app/component-library/components/Navigation/TabBar/TabBar.stories.tsx": require("../app/component-library/components/Navigation/TabBar/TabBar.stories.tsx"), - "./app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx": require("../app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx"), - "./app/component-library/components/Overlay/Overlay.stories.tsx": require("../app/component-library/components/Overlay/Overlay.stories.tsx"), - "./app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx": require("../app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx"), - "./app/component-library/components/Pickers/PickerBase/PickerBase.stories.tsx": require("../app/component-library/components/Pickers/PickerBase/PickerBase.stories.tsx"), - "./app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx": require("../app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx"), - "./app/component-library/components/RadioButton/RadioButton.stories.tsx": require("../app/component-library/components/RadioButton/RadioButton.stories.tsx"), - "./app/component-library/components/Select/SelectButton/SelectButton.stories.tsx": require("../app/component-library/components/Select/SelectButton/SelectButton.stories.tsx"), - "./app/component-library/components/Select/SelectOption/SelectOption.stories.tsx": require("../app/component-library/components/Select/SelectOption/SelectOption.stories.tsx"), - "./app/component-library/components/Select/SelectValue/SelectValue.stories.tsx": require("../app/component-library/components/Select/SelectValue/SelectValue.stories.tsx"), - "./app/component-library/components/Sheet/SheetHeader/SheetHeader.stories.tsx": require("../app/component-library/components/Sheet/SheetHeader/SheetHeader.stories.tsx"), - "./app/component-library/components/Skeleton/Skeleton.stories.tsx": require("../app/component-library/components/Skeleton/Skeleton.stories.tsx"), - "./app/component-library/components/Tags/Tag/Tag.stories.tsx": require("../app/component-library/components/Tags/Tag/Tag.stories.tsx"), - "./app/component-library/components/Tags/TagUrl/TagUrl.stories.tsx": require("../app/component-library/components/Tags/TagUrl/TagUrl.stories.tsx"), - "./app/component-library/components/Texts/SensitiveText/SensitiveText.stories.tsx": require("../app/component-library/components/Texts/SensitiveText/SensitiveText.stories.tsx"), - "./app/component-library/components/Texts/Text/Text.stories.tsx": require("../app/component-library/components/Texts/Text/Text.stories.tsx"), - "./app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx": require("../app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx"), - "./app/component-library/components/Toast/Toast.stories.tsx": require("../app/component-library/components/Toast/Toast.stories.tsx"), - "./app/components/Base/Keypad/Keypad.stories.tsx": require("../app/components/Base/Keypad/Keypad.stories.tsx"), - "./app/components/UI/BalanceEmptyState/BalanceEmptyState.stories.tsx": require("../app/components/UI/BalanceEmptyState/BalanceEmptyState.stories.tsx"), - "./app/components/UI/CollectiblesEmptyState/CollectiblesEmptyState.stories.tsx": require("../app/components/UI/CollectiblesEmptyState/CollectiblesEmptyState.stories.tsx"), - "./app/components/UI/DefiEmptyState/DefiEmptyState.stories.tsx": require("../app/components/UI/DefiEmptyState/DefiEmptyState.stories.tsx"), - "./app/components/UI/Perps/Views/PerpsEmptyState/PerpsEmptyState.stories.tsx": require("../app/components/UI/Perps/Views/PerpsEmptyState/PerpsEmptyState.stories.tsx"), - "./app/components/UI/Ramp/Aggregator/components/ShapesBackgroundAnimation/index.stories.tsx": require("../app/components/UI/Ramp/Aggregator/components/ShapesBackgroundAnimation/index.stories.tsx"), - "./app/components/UI/Rewards/components/RewardPointsAnimation/RewardPointsAnimation.stories.tsx": require("../app/components/UI/Rewards/components/RewardPointsAnimation/RewardPointsAnimation.stories.tsx"), - "./app/components/UI/SettingsButtonSection/SettingsButtonSection.stories.tsx": require("../app/components/UI/SettingsButtonSection/SettingsButtonSection.stories.tsx"), - "./app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.stories.tsx": require("../app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.stories.tsx"), - "./app/components/Views/confirmations/components/deposit-keyboard/deposit-keyboard.stories.tsx": require("../app/components/Views/confirmations/components/deposit-keyboard/deposit-keyboard.stories.tsx"), - "./app/components/Views/confirmations/components/edit-amount-keyboard/edit-amount-keyboard.stories.tsx": require("../app/components/Views/confirmations/components/edit-amount-keyboard/edit-amount-keyboard.stories.tsx"), - "./app/components/Views/ConnectHardware/HardwareWalletDiscoveryFlow/screens/errors/index.stories.tsx": require("../app/components/Views/ConnectHardware/HardwareWalletDiscoveryFlow/screens/errors/index.stories.tsx"), - "./app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.stories.tsx": require("../app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.stories.tsx"), - "./app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnectMultiSelector/MultichainAccountConnectMultiSelector.stories.tsx": require("../app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnectMultiSelector/MultichainAccountConnectMultiSelector.stories.tsx"), - "./app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.stories.tsx": require("../app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.stories.tsx"), - "./app/components/Views/MultichainAccounts/MultichainPermissionsSummary/MultichainPermissionsSummary.stories.tsx": require("../app/components/Views/MultichainAccounts/MultichainPermissionsSummary/MultichainPermissionsSummary.stories.tsx"), - "./app/components/Views/QRAccountDisplay/QRAccountDisplay.stories.tsx": require("../app/components/Views/QRAccountDisplay/QRAccountDisplay.stories.tsx"), - }; -}; +const getStories = () => ({ + './app/component-library/base-components/TagBase/TagBase.stories.tsx': require('../app/component-library/base-components/TagBase/TagBase.stories.tsx'), + './app/component-library/components-temp/ActionListItem/ActionListItem.stories.tsx': require('../app/component-library/components-temp/ActionListItem/ActionListItem.stories.tsx'), + './app/component-library/components-temp/BaseNotification/BaseNotification.stories.tsx': require('../app/component-library/components-temp/BaseNotification/BaseNotification.stories.tsx'), + './app/component-library/components-temp/ButtonFilter/ButtonFilter.stories.tsx': require('../app/component-library/components-temp/ButtonFilter/ButtonFilter.stories.tsx'), + './app/component-library/components-temp/Buttons/ButtonHero/ButtonHero.stories.tsx': require('../app/component-library/components-temp/Buttons/ButtonHero/ButtonHero.stories.tsx'), + './app/component-library/components-temp/Buttons/ButtonSemantic/ButtonSemantic.stories.tsx': require('../app/component-library/components-temp/Buttons/ButtonSemantic/ButtonSemantic.stories.tsx'), + './app/component-library/components-temp/Buttons/ButtonToggle/ButtonToggle.stories.tsx': require('../app/component-library/components-temp/Buttons/ButtonToggle/ButtonToggle.stories.tsx'), + './app/component-library/components-temp/CellSelectWithMenu/CellSelectWithMenu.stories.tsx': require('../app/component-library/components-temp/CellSelectWithMenu/CellSelectWithMenu.stories.tsx'), + './app/component-library/components-temp/HeaderCompactStandard/HeaderCompactStandard.stories.tsx': require('../app/component-library/components-temp/HeaderCompactStandard/HeaderCompactStandard.stories.tsx'), + './app/component-library/components-temp/HeaderRoot/HeaderRoot.stories.tsx': require('../app/component-library/components-temp/HeaderRoot/HeaderRoot.stories.tsx'), + './app/component-library/components-temp/HeaderSearch/HeaderSearch.stories.tsx': require('../app/component-library/components-temp/HeaderSearch/HeaderSearch.stories.tsx'), + './app/component-library/components-temp/HeaderStandardAnimated/HeaderStandardAnimated.stories.tsx': require('../app/component-library/components-temp/HeaderStandardAnimated/HeaderStandardAnimated.stories.tsx'), + './app/component-library/components-temp/KeyValueRow/KeyValueRow.stories.tsx': require('../app/component-library/components-temp/KeyValueRow/KeyValueRow.stories.tsx'), + './app/component-library/components-temp/ListItemMultiSelectButton/ListItemMultiSelectButton.stories.tsx': require('../app/component-library/components-temp/ListItemMultiSelectButton/ListItemMultiSelectButton.stories.tsx'), + './app/component-library/components-temp/ListItemMultiSelectWithMenuButton/ListItemMultiSelectWithMenuButton.stories.tsx': require('../app/component-library/components-temp/ListItemMultiSelectWithMenuButton/ListItemMultiSelectWithMenuButton.stories.tsx'), + './app/component-library/components-temp/MainActionButton/MainActionButton.stories.tsx': require('../app/component-library/components-temp/MainActionButton/MainActionButton.stories.tsx'), + './app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.stories.tsx': require('../app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.stories.tsx'), + './app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/MultichainAccountSelectorList.stories.tsx': require('../app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/MultichainAccountSelectorList.stories.tsx'), + './app/component-library/components-temp/MultichainAccounts/MultichainAddressRow/MultichainAddressRow.stories.tsx': require('../app/component-library/components-temp/MultichainAccounts/MultichainAddressRow/MultichainAddressRow.stories.tsx'), + './app/component-library/components-temp/MultichainAccounts/MultichainAddressRowsList/MultichainAddressRowsList.stories.tsx': require('../app/component-library/components-temp/MultichainAccounts/MultichainAddressRowsList/MultichainAddressRowsList.stories.tsx'), + './app/component-library/components-temp/Pressable/Pressable.stories.tsx': require('../app/component-library/components-temp/Pressable/Pressable.stories.tsx'), + './app/component-library/components-temp/Price/PercentageChange/PercentageChange.stories.tsx': require('../app/component-library/components-temp/Price/PercentageChange/PercentageChange.stories.tsx'), + './app/component-library/components-temp/SectionHeader/SectionHeader.stories.tsx': require('../app/component-library/components-temp/SectionHeader/SectionHeader.stories.tsx'), + './app/component-library/components-temp/TabBar/TabBar.stories.tsx': require('../app/component-library/components-temp/TabBar/TabBar.stories.tsx'), + './app/component-library/components-temp/TabEmptyState/TabEmptyState.stories.tsx': require('../app/component-library/components-temp/TabEmptyState/TabEmptyState.stories.tsx'), + './app/component-library/components-temp/Tabs/Tabs.stories.tsx': require('../app/component-library/components-temp/Tabs/Tabs.stories.tsx'), + './app/component-library/components-temp/TagColored/TagColored.stories.tsx': require('../app/component-library/components-temp/TagColored/TagColored.stories.tsx'), + './app/component-library/components-temp/TitleStandard/TitleStandard.stories.tsx': require('../app/component-library/components-temp/TitleStandard/TitleStandard.stories.tsx'), + './app/component-library/components-temp/TitleSubpage/TitleSubpage.stories.tsx': require('../app/component-library/components-temp/TitleSubpage/TitleSubpage.stories.tsx'), + './app/component-library/components/Accordions/Accordion/Accordion.stories.tsx': require('../app/component-library/components/Accordions/Accordion/Accordion.stories.tsx'), + './app/component-library/components/Accordions/Accordion/foundation/AccordionHeader/AccordionHeader.stories.tsx': require('../app/component-library/components/Accordions/Accordion/foundation/AccordionHeader/AccordionHeader.stories.tsx'), + './app/component-library/components/Avatars/Avatar/Avatar.stories.tsx': require('../app/component-library/components/Avatars/Avatar/Avatar.stories.tsx'), + './app/component-library/components/Avatars/Avatar/variants/AvatarAccount/AvatarAccount.stories.tsx': require('../app/component-library/components/Avatars/Avatar/variants/AvatarAccount/AvatarAccount.stories.tsx'), + './app/component-library/components/Avatars/Avatar/variants/AvatarFavicon/AvatarFavicon.stories.tsx': require('../app/component-library/components/Avatars/Avatar/variants/AvatarFavicon/AvatarFavicon.stories.tsx'), + './app/component-library/components/Avatars/Avatar/variants/AvatarIcon/AvatarIcon.stories.tsx': require('../app/component-library/components/Avatars/Avatar/variants/AvatarIcon/AvatarIcon.stories.tsx'), + './app/component-library/components/Avatars/Avatar/variants/AvatarNetwork/AvatarNetwork.stories.tsx': require('../app/component-library/components/Avatars/Avatar/variants/AvatarNetwork/AvatarNetwork.stories.tsx'), + './app/component-library/components/Avatars/Avatar/variants/AvatarToken/AvatarToken.stories.tsx': require('../app/component-library/components/Avatars/Avatar/variants/AvatarToken/AvatarToken.stories.tsx'), + './app/component-library/components/Avatars/AvatarGroup/AvatarGroup.stories.tsx': require('../app/component-library/components/Avatars/AvatarGroup/AvatarGroup.stories.tsx'), + './app/component-library/components/Badges/Badge/Badge.stories.tsx': require('../app/component-library/components/Badges/Badge/Badge.stories.tsx'), + './app/component-library/components/Badges/Badge/variants/BadgeNetwork/BadgeNetwork.stories.tsx': require('../app/component-library/components/Badges/Badge/variants/BadgeNetwork/BadgeNetwork.stories.tsx'), + './app/component-library/components/Badges/Badge/variants/BadgeNotifications/BadgeNotifications.stories.tsx': require('../app/component-library/components/Badges/Badge/variants/BadgeNotifications/BadgeNotifications.stories.tsx'), + './app/component-library/components/Badges/Badge/variants/BadgeStatus/BadgeStatus.stories.tsx': require('../app/component-library/components/Badges/Badge/variants/BadgeStatus/BadgeStatus.stories.tsx'), + './app/component-library/components/Badges/BadgeWrapper/BadgeWrapper.stories.tsx': require('../app/component-library/components/Badges/BadgeWrapper/BadgeWrapper.stories.tsx'), + './app/component-library/components/Banners/Banner/Banner.stories.tsx': require('../app/component-library/components/Banners/Banner/Banner.stories.tsx'), + './app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx': require('../app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx'), + './app/component-library/components/Banners/Banner/variants/BannerTip/BannerTip.stories.tsx': require('../app/component-library/components/Banners/Banner/variants/BannerTip/BannerTip.stories.tsx'), + './app/component-library/components/BottomSheets/BottomSheet/BottomSheet.stories.tsx': require('../app/component-library/components/BottomSheets/BottomSheet/BottomSheet.stories.tsx'), + './app/component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.stories.tsx': require('../app/component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.stories.tsx'), + './app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx': require('../app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx'), + './app/component-library/components/Buttons/Button/Button.stories.tsx': require('../app/component-library/components/Buttons/Button/Button.stories.tsx'), + './app/component-library/components/Buttons/Button/variants/ButtonLink/ButtonLink.stories.tsx': require('../app/component-library/components/Buttons/Button/variants/ButtonLink/ButtonLink.stories.tsx'), + './app/component-library/components/Buttons/Button/variants/ButtonPrimary/ButtonPrimary.stories.tsx': require('../app/component-library/components/Buttons/Button/variants/ButtonPrimary/ButtonPrimary.stories.tsx'), + './app/component-library/components/Buttons/Button/variants/ButtonSecondary/ButtonSecondary.stories.tsx': require('../app/component-library/components/Buttons/Button/variants/ButtonSecondary/ButtonSecondary.stories.tsx'), + './app/component-library/components/Buttons/ButtonIcon/ButtonIcon.stories.tsx': require('../app/component-library/components/Buttons/ButtonIcon/ButtonIcon.stories.tsx'), + './app/component-library/components/Cards/Card/Card.stories.tsx': require('../app/component-library/components/Cards/Card/Card.stories.tsx'), + './app/component-library/components/Cells/Cell/Cell.stories.tsx': require('../app/component-library/components/Cells/Cell/Cell.stories.tsx'), + './app/component-library/components/Cells/Cell/variants/CellDisplay/CellDisplay.stories.tsx': require('../app/component-library/components/Cells/Cell/variants/CellDisplay/CellDisplay.stories.tsx'), + './app/component-library/components/Cells/Cell/variants/CellMultiSelect/CellMultiSelect.stories.tsx': require('../app/component-library/components/Cells/Cell/variants/CellMultiSelect/CellMultiSelect.stories.tsx'), + './app/component-library/components/Cells/Cell/variants/CellSelect/CellSelect.stories.tsx': require('../app/component-library/components/Cells/Cell/variants/CellSelect/CellSelect.stories.tsx'), + './app/component-library/components/Checkbox/Checkbox.stories.tsx': require('../app/component-library/components/Checkbox/Checkbox.stories.tsx'), + './app/component-library/components/design-system.stories.tsx': require('../app/component-library/components/design-system.stories.tsx'), + './app/component-library/components/Form/HelpText/HelpText.stories.tsx': require('../app/component-library/components/Form/HelpText/HelpText.stories.tsx'), + './app/component-library/components/Form/Label/Label.stories.tsx': require('../app/component-library/components/Form/Label/Label.stories.tsx'), + './app/component-library/components/Form/TextField/foundation/Input/Input.stories.tsx': require('../app/component-library/components/Form/TextField/foundation/Input/Input.stories.tsx'), + './app/component-library/components/Form/TextField/TextField.stories.tsx': require('../app/component-library/components/Form/TextField/TextField.stories.tsx'), + './app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx': require('../app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx'), + './app/component-library/components/HeaderBase/HeaderBase.stories.tsx': require('../app/component-library/components/HeaderBase/HeaderBase.stories.tsx'), + './app/component-library/components/Icons/Icon/Icon.stories.tsx': require('../app/component-library/components/Icons/Icon/Icon.stories.tsx'), + './app/component-library/components/List/ListItem/ListItem.stories.tsx': require('../app/component-library/components/List/ListItem/ListItem.stories.tsx'), + './app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx': require('../app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx'), + './app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx': require('../app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx'), + './app/component-library/components/Modals/ModalConfirmation/ModalConfirmation.stories.tsx': require('../app/component-library/components/Modals/ModalConfirmation/ModalConfirmation.stories.tsx'), + './app/component-library/components/Modals/ModalMandatory/ModalMandatory.stories.tsx': require('../app/component-library/components/Modals/ModalMandatory/ModalMandatory.stories.tsx'), + './app/component-library/components/Navigation/TabBar/TabBar.stories.tsx': require('../app/component-library/components/Navigation/TabBar/TabBar.stories.tsx'), + './app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx': require('../app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx'), + './app/component-library/components/Overlay/Overlay.stories.tsx': require('../app/component-library/components/Overlay/Overlay.stories.tsx'), + './app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx': require('../app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx'), + './app/component-library/components/Pickers/PickerBase/PickerBase.stories.tsx': require('../app/component-library/components/Pickers/PickerBase/PickerBase.stories.tsx'), + './app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx': require('../app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx'), + './app/component-library/components/RadioButton/RadioButton.stories.tsx': require('../app/component-library/components/RadioButton/RadioButton.stories.tsx'), + './app/component-library/components/Select/SelectButton/SelectButton.stories.tsx': require('../app/component-library/components/Select/SelectButton/SelectButton.stories.tsx'), + './app/component-library/components/Select/SelectOption/SelectOption.stories.tsx': require('../app/component-library/components/Select/SelectOption/SelectOption.stories.tsx'), + './app/component-library/components/Select/SelectValue/SelectValue.stories.tsx': require('../app/component-library/components/Select/SelectValue/SelectValue.stories.tsx'), + './app/component-library/components/Sheet/SheetHeader/SheetHeader.stories.tsx': require('../app/component-library/components/Sheet/SheetHeader/SheetHeader.stories.tsx'), + './app/component-library/components/Skeleton/Skeleton.stories.tsx': require('../app/component-library/components/Skeleton/Skeleton.stories.tsx'), + './app/component-library/components/Tags/Tag/Tag.stories.tsx': require('../app/component-library/components/Tags/Tag/Tag.stories.tsx'), + './app/component-library/components/Tags/TagUrl/TagUrl.stories.tsx': require('../app/component-library/components/Tags/TagUrl/TagUrl.stories.tsx'), + './app/component-library/components/Texts/SensitiveText/SensitiveText.stories.tsx': require('../app/component-library/components/Texts/SensitiveText/SensitiveText.stories.tsx'), + './app/component-library/components/Texts/Text/Text.stories.tsx': require('../app/component-library/components/Texts/Text/Text.stories.tsx'), + './app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx': require('../app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx'), + './app/component-library/components/Toast/Toast.stories.tsx': require('../app/component-library/components/Toast/Toast.stories.tsx'), + './app/component-library/components/Toast/ToastEarn.stories.tsx': require('../app/component-library/components/Toast/ToastEarn.stories.tsx'), + './app/component-library/components/Toast/ToastEdgeCases.stories.tsx': require('../app/component-library/components/Toast/ToastEdgeCases.stories.tsx'), + './app/component-library/components/Toast/ToastMoney.stories.tsx': require('../app/component-library/components/Toast/ToastMoney.stories.tsx'), + './app/component-library/components/Toast/ToastPerps.stories.tsx': require('../app/component-library/components/Toast/ToastPerps.stories.tsx'), + './app/component-library/components/Toast/ToastPerpsWithdraw.stories.tsx': require('../app/component-library/components/Toast/ToastPerpsWithdraw.stories.tsx'), + './app/component-library/components/Toast/ToastPredict.stories.tsx': require('../app/component-library/components/Toast/ToastPredict.stories.tsx'), + './app/component-library/components/Toast/ToastQuickBuy.stories.tsx': require('../app/component-library/components/Toast/ToastQuickBuy.stories.tsx'), + './app/component-library/components/Toast/ToastRamp.stories.tsx': require('../app/component-library/components/Toast/ToastRamp.stories.tsx'), + './app/component-library/components/Toast/ToastRewards.stories.tsx': require('../app/component-library/components/Toast/ToastRewards.stories.tsx'), + './app/components/Base/Keypad/Keypad.stories.tsx': require('../app/components/Base/Keypad/Keypad.stories.tsx'), + './app/components/UI/BalanceEmptyState/BalanceEmptyState.stories.tsx': require('../app/components/UI/BalanceEmptyState/BalanceEmptyState.stories.tsx'), + './app/components/UI/CollectiblesEmptyState/CollectiblesEmptyState.stories.tsx': require('../app/components/UI/CollectiblesEmptyState/CollectiblesEmptyState.stories.tsx'), + './app/components/UI/DefiEmptyState/DefiEmptyState.stories.tsx': require('../app/components/UI/DefiEmptyState/DefiEmptyState.stories.tsx'), + './app/components/UI/NetworkConnectionBanner/NetworkConnectionBanner.stories.tsx': require('../app/components/UI/NetworkConnectionBanner/NetworkConnectionBanner.stories.tsx'), + './app/components/UI/Perps/components/PerpsWebSocketHealthToast/PerpsWebSocketHealthToast.stories.tsx': require('../app/components/UI/Perps/components/PerpsWebSocketHealthToast/PerpsWebSocketHealthToast.stories.tsx'), + './app/components/UI/Perps/Views/PerpsEmptyState/PerpsEmptyState.stories.tsx': require('../app/components/UI/Perps/Views/PerpsEmptyState/PerpsEmptyState.stories.tsx'), + './app/components/UI/Ramp/Aggregator/components/ShapesBackgroundAnimation/index.stories.tsx': require('../app/components/UI/Ramp/Aggregator/components/ShapesBackgroundAnimation/index.stories.tsx'), + './app/components/UI/Rewards/components/RewardPointsAnimation/RewardPointsAnimation.stories.tsx': require('../app/components/UI/Rewards/components/RewardPointsAnimation/RewardPointsAnimation.stories.tsx'), + './app/components/UI/SettingsButtonSection/SettingsButtonSection.stories.tsx': require('../app/components/UI/SettingsButtonSection/SettingsButtonSection.stories.tsx'), + './app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.stories.tsx': require('../app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.stories.tsx'), + './app/components/Views/confirmations/components/deposit-keyboard/deposit-keyboard.stories.tsx': require('../app/components/Views/confirmations/components/deposit-keyboard/deposit-keyboard.stories.tsx'), + './app/components/Views/confirmations/components/edit-amount-keyboard/edit-amount-keyboard.stories.tsx': require('../app/components/Views/confirmations/components/edit-amount-keyboard/edit-amount-keyboard.stories.tsx'), + './app/components/Views/ConnectHardware/HardwareWalletDiscoveryFlow/screens/errors/index.stories.tsx': require('../app/components/Views/ConnectHardware/HardwareWalletDiscoveryFlow/screens/errors/index.stories.tsx'), + './app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.stories.tsx': require('../app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnect.stories.tsx'), + './app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnectMultiSelector/MultichainAccountConnectMultiSelector.stories.tsx': require('../app/components/Views/MultichainAccounts/MultichainAccountConnect/MultichainAccountConnectMultiSelector/MultichainAccountConnectMultiSelector.stories.tsx'), + './app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.stories.tsx': require('../app/components/Views/MultichainAccounts/MultichainAccountsConnectedList/MultichainAccountsConnectedList.stories.tsx'), + './app/components/Views/MultichainAccounts/MultichainPermissionsSummary/MultichainPermissionsSummary.stories.tsx': require('../app/components/Views/MultichainAccounts/MultichainPermissionsSummary/MultichainPermissionsSummary.stories.tsx'), + './app/components/Views/QRAccountDisplay/QRAccountDisplay.stories.tsx': require('../app/components/Views/QRAccountDisplay/QRAccountDisplay.stories.tsx'), + }); configure(getStories, module, false); diff --git a/app/component-library/components-temp/BaseNotification/BaseNotification.stories.tsx b/app/component-library/components-temp/BaseNotification/BaseNotification.stories.tsx new file mode 100644 index 00000000000..97a4dd6c6c7 --- /dev/null +++ b/app/component-library/components-temp/BaseNotification/BaseNotification.stories.tsx @@ -0,0 +1,181 @@ +import React, { useCallback, useState } from 'react'; +import { ScrollView, View } from 'react-native'; +import { Text, TextVariant } from '@metamask/design-system-react-native'; +import { useTailwind } from '@metamask/design-system-twrnc-preset'; + +import Button, { ButtonVariants } from '../../components/Buttons/Button'; +import BaseNotification from './index'; +import type { + BaseNotificationData, + BaseNotificationProps, + BaseNotificationStatus, +} from './BaseNotification.types'; + +interface NotificationTrigger { + label: string; + status: BaseNotificationStatus; + data?: BaseNotificationData; + autoDismiss?: boolean; + onHide?: () => void; +} + +interface ActiveNotification extends NotificationTrigger { + key: number; +} + +interface NotificationTriggerSection { + title: string; + triggers: NotificationTrigger[]; +} + +const STORYBOOK_PROPS: Pick< + BaseNotificationProps, + 'persistUntilDismiss' | 'isVisible' +> = { + isVisible: true, + persistUntilDismiss: true, +}; + +const LOADING_TRIGGERS: NotificationTrigger[] = [ + { label: 'Pending', status: 'pending' }, + { label: 'Pending deposit', status: 'pending_deposit' }, + { label: 'Pending withdrawal', status: 'pending_withdrawal' }, + { + label: 'Speedup', + status: 'speedup', + data: { nonce: '12' }, + }, +]; + +const SUCCESS_TRIGGERS: NotificationTrigger[] = [ + { + label: 'Success', + status: 'success', + data: { nonce: '42' }, + }, + { label: 'Success deposit', status: 'success_deposit' }, + { label: 'Success withdrawal', status: 'success_withdrawal' }, + { + label: 'Received', + status: 'received', + data: { amount: '0.5', assetType: 'ETH' }, + }, + { label: 'Received payment', status: 'received_payment' }, + { label: 'ETH received', status: 'eth_received' }, + { label: 'Import success', status: 'import_success' }, + { label: 'Simple notification', status: 'simple_notification' }, +]; + +const FAILURE_TRIGGERS: NotificationTrigger[] = [ + { label: 'Error', status: 'error' }, + { label: 'Cancelled', status: 'cancelled' }, + { + label: 'Simple notification rejected', + status: 'simple_notification_rejected', + }, +]; + +const INTERACTION_TRIGGERS: NotificationTrigger[] = [ + { + label: 'Custom copy', + status: 'simple_notification', + data: { + title: 'Transaction submitted', + description: 'Your swap is being processed on Ethereum Mainnet.', + }, + }, + { + label: 'With close button', + status: 'success', + autoDismiss: true, + data: { + title: 'Wallet ready', + description: 'Your wallet was imported successfully.', + }, + onHide: () => { + // eslint-disable-next-line no-console + console.log('BaseNotification dismissed'); + }, + }, +]; + +const STORY_SECTIONS: NotificationTriggerSection[] = [ + { title: 'Loading', triggers: LOADING_TRIGGERS }, + { title: 'Success', triggers: SUCCESS_TRIGGERS }, + { title: 'Failure', triggers: FAILURE_TRIGGERS }, + { title: 'Interaction', triggers: INTERACTION_TRIGGERS }, +]; + +const StoryContainer = ({ children }: { children: React.ReactNode }) => { + const tw = useTailwind(); + + return ( + + {children} + + ); +}; + +const NotificationTriggerStory = ({ + sections, +}: { + sections: NotificationTriggerSection[]; +}) => { + const tw = useTailwind(); + const [active, setActive] = useState(null); + + const showNotification = useCallback((trigger: NotificationTrigger) => { + setActive(null); + setTimeout(() => { + setActive({ + key: Date.now(), + ...trigger, + }); + }, 50); + }, []); + + return ( + + + {sections.map((section) => ( + + {section.title} + {section.triggers.map((trigger) => ( + ); const renderCloseButton = (closeButtonOptions?: ToastCloseButtonOptions) => { @@ -187,17 +270,23 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { closeButtonOptions?.onPress?.()} iconName={closeButtonOptions?.iconName} + size={ButtonIconSizes.Md} + style={styles.closeButton} /> ); } + const legacyCloseButton = closeButtonOptions as ButtonProps; + return ( ); }; @@ -216,7 +305,6 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { // should receive avatar type as props type={accountAvatarType} size={AvatarSize.Md} - style={styles.avatar} /> ); } @@ -227,8 +315,7 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { variant={AvatarVariant.Network} name={networkName} imageSource={networkImageSource} - size={AvatarSize.Md} - style={styles.avatar} + size={AvatarSize.Sm} /> ); } @@ -239,21 +326,26 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { variant={AvatarVariant.Favicon} imageSource={appIconSource} size={AvatarSize.Md} - style={styles.avatar} /> ); } case ToastVariants.Icon: { const { iconName, iconColor, backgroundColor } = toastOptions; - return ( - + const icon = ( + ); + const hasIconBackground = + backgroundColor != null && backgroundColor !== 'transparent'; + + if (hasIconBackground) { + return ( + + {icon} + + ); + } + + return icon; } } }; @@ -269,10 +361,15 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { const isStartAccessoryValid = startAccessory != null && React.isValidElement(startAccessory); + const leadingAccessory = isStartAccessoryValid + ? startAccessory + : renderAvatar(); return ( <> - {isStartAccessoryValid ? startAccessory : renderAvatar()} + {leadingAccessory ? ( + {leadingAccessory} + ) : null} EarnToastOptions; +} + +interface EarnToastTriggerSection { + title: string; + triggers: EarnToastTrigger[]; +} + +const buildEarnToastSections = ( + options: EarnToastOptionsConfig, +): EarnToastTriggerSection[] => [ + { + title: 'mUSD conversion', + triggers: [ + { + label: 'Conversion in progress', + getConfig: () => + options.mUsdConversion.inProgress({ + tokenSymbol: MOCK_TOKEN_SYMBOL, + }), + }, + { + label: 'Conversion success', + getConfig: () => options.mUsdConversion.success, + }, + { + label: 'Conversion failed', + getConfig: () => options.mUsdConversion.failed, + }, + ], + }, + { + title: 'Bonus claim', + triggers: [ + { + label: 'Claim in progress', + getConfig: () => options.bonusClaim.inProgress, + }, + { + label: 'Claim success', + getConfig: () => options.bonusClaim.success, + }, + { + label: 'Claim failed', + getConfig: () => options.bonusClaim.failed, + }, + ], + }, + { + title: 'TRON withdrawal', + triggers: [ + { + label: 'Withdrawal failed', + getConfig: () => options.tronWithdrawal.failed(MOCK_WITHDRAWAL_ERRORS), + }, + { + label: 'Withdrawal failed (no details)', + getConfig: () => options.tronWithdrawal.failed([]), + }, + ], + }, +]; + +const EarnToastsStoryContent = () => { + const tw = useTailwind(); + const { toastRef } = useContext(ToastContext); + const { showToast, EarnToastOptions } = useEarnToasts(); + const sections = useMemo( + () => buildEarnToastSections(EarnToastOptions), + [EarnToastOptions], + ); + + const triggerEarnToast = useCallback( + (trigger: EarnToastTrigger) => { + showToast({ + ...trigger.getConfig(EarnToastOptions), + hasNoTimeout: true, + }); + }, + [EarnToastOptions, showToast], + ); + + return ( + + + {sections.map((section) => ( + + {section.title} + {section.triggers.map((trigger) => ( + + ))} + + ))} + + + + ); +}; + +const EdgeCaseToastsStory = () => ( + + + +); + +const EdgeCaseToastsMeta = { + title: 'Component Library / Toast', + component: Toast, +}; + +export default EdgeCaseToastsMeta; + +export const EdgeCases = { + render: () => , +}; diff --git a/app/component-library/components/Toast/ToastMoney.stories.tsx b/app/component-library/components/Toast/ToastMoney.stories.tsx new file mode 100644 index 00000000000..524d7dac3e9 --- /dev/null +++ b/app/component-library/components/Toast/ToastMoney.stories.tsx @@ -0,0 +1,218 @@ +import React, { useCallback, useContext, useMemo } from 'react'; +import { ScrollView, View } from 'react-native'; +import { Text, TextVariant } from '@metamask/design-system-react-native'; +import { useTailwind } from '@metamask/design-system-twrnc-preset'; + +import useMoneyToasts, { + type MoneyToastOptions, + type MoneyToastOptionsConfig, +} from '../../../components/UI/Money/hooks/useMoneyToasts'; +import { strings } from '../../../../locales/i18n'; +import Button, { ButtonVariants } from '../Buttons/Button'; +import Toast from './Toast'; +import { ToastContext, ToastContextWrapper } from './Toast.context'; +import { StoryContainer, StoryToastHost } from './ToastStory.shared'; + +const MOCK_FIAT_AMOUNT = '$50.00'; +const MOCK_WITHDRAW_DESTINATION = strings( + 'money.toasts.withdraw_fallback_destination', +); + +interface MoneyToastTrigger { + label: string; + getConfig: (options: MoneyToastOptionsConfig) => MoneyToastOptions; +} + +interface MoneyToastTriggerSection { + title: string; + triggers: MoneyToastTrigger[]; +} + +const buildMoneyToastSections = ( + options: MoneyToastOptionsConfig, +): MoneyToastTriggerSection[] => [ + { + title: 'Deposit — convert', + triggers: [ + { + label: 'In progress', + getConfig: () => options.deposit.inProgress({ intent: 'convert' }), + }, + { + label: 'Success', + getConfig: () => + options.deposit.success({ + amountFiat: MOCK_FIAT_AMOUNT, + intent: 'convert', + }), + }, + { + label: 'Success (no amount)', + getConfig: () => options.deposit.success({ intent: 'convert' }), + }, + { + label: 'Failed', + getConfig: () => options.deposit.failed({ intent: 'convert' }), + }, + ], + }, + { + title: 'Deposit — add mUSD', + triggers: [ + { + label: 'In progress', + getConfig: () => options.deposit.inProgress({ intent: 'addMusd' }), + }, + { + label: 'Success', + getConfig: () => + options.deposit.success({ + amountFiat: MOCK_FIAT_AMOUNT, + intent: 'addMusd', + }), + }, + { + label: 'Failed', + getConfig: () => options.deposit.failed({ intent: 'addMusd' }), + }, + ], + }, + { + title: 'Deposit — card', + triggers: [ + { + label: 'In progress', + getConfig: () => options.deposit.inProgress({ intent: 'card' }), + }, + { + label: 'Success', + getConfig: () => + options.deposit.success({ + amountFiat: MOCK_FIAT_AMOUNT, + intent: 'card', + }), + }, + { + label: 'Failed', + getConfig: () => options.deposit.failed({ intent: 'card' }), + }, + ], + }, + { + title: 'Withdraw', + triggers: [ + { + label: 'In progress', + getConfig: () => options.withdraw.inProgress(), + }, + { + label: 'Success', + getConfig: () => + options.withdraw.success({ + amountFiat: MOCK_FIAT_AMOUNT, + destination: MOCK_WITHDRAW_DESTINATION, + }), + }, + { + label: 'Success (no amount)', + getConfig: () => + options.withdraw.success({ + destination: MOCK_WITHDRAW_DESTINATION, + }), + }, + { + label: 'Failed', + getConfig: () => options.withdraw.failed(), + }, + ], + }, + { + title: 'Send', + triggers: [ + { + label: 'In progress', + getConfig: () => options.send.inProgress(), + }, + { + label: 'Success — Perps', + getConfig: () => + options.send.success({ + amountFiat: MOCK_FIAT_AMOUNT, + destination: strings('money.toasts.send_destination_perps'), + }), + }, + { + label: 'Success — Predict (no amount)', + getConfig: () => + options.send.success({ + destination: strings('money.toasts.send_destination_predict'), + }), + }, + { + label: 'Failed', + getConfig: () => options.send.failed(), + }, + ], + }, +]; + +const MoneyToastsStoryContent = () => { + const tw = useTailwind(); + const { toastRef } = useContext(ToastContext); + const { showToast, MoneyToastOptions } = useMoneyToasts(); + const sections = useMemo( + () => buildMoneyToastSections(MoneyToastOptions), + [MoneyToastOptions], + ); + + const triggerMoneyToast = useCallback( + (trigger: MoneyToastTrigger) => { + showToast({ + ...trigger.getConfig(MoneyToastOptions), + hasNoTimeout: true, + }); + }, + [MoneyToastOptions, showToast], + ); + + return ( + + + {sections.map((section) => ( + + {section.title} + {section.triggers.map((trigger) => ( +