Skip to Content
Welcome to RitoSwap's documentation!
dAppStorybookDecorators & Providers

Decorators & Providers

Storybook applies two global decorators defined in dapp/.storybook/preview.tsx:

  1. Debug panel overlay (optional) for showing DebugPanel.
  2. MockAppProviders wrapper that seeds Wagmi, React Query, chain info, and rate-limit providers.

preview.tsx also sets window.__RITO_ASSET_PREFIX__ = '/storybook-static'. Use applyStorybookAssetPrefix (from @storybook-utils/assetPrefix) when a component references /images, /gifs, or /audio so assets resolve inside Storybook embeds.

      • preview.tsx
        • MockAppProviders.tsx

MockAppProviders

MockAppProviders composes:

  • QueryClientProvider with retries disabled for deterministic story behavior.
  • WagmiProvider using a mocked config (createMockWagmiConfig).
  • ChainInfoProvider to align chain metadata and visuals.
  • RateLimitModalProvider for any rate-limit overlays.
  • AutoConnect helper to simulate connecting when mockWallet.connected is true.

It also seeds ENS and balance data into React Query using applyEnsMocks and applyBalanceMocks.

Global toolbar: Debug Panel

The preview defines a debugPanel global toolbar with values:

  • auto (dev-only)
  • show (always visible)
  • hide (force hidden)

The overlay is suppressed for the Debug/DebugPanel story itself.

Story args read by preview

The preview file reads select context.args values to build mock wallet data. These are optional and only applied when provided.

ArgTypePurpose
walletConnectedbooleanWhen true, auto-connects the mock wallet.
walletNetworkstringChain name (e.g. mainnet, sepolia, polygon, arbitrum).
walletAccountsCsvstringComma or space-delimited list of account addresses.
showMainnetshowFantombooleanEnable or disable specific chain IDs for the wallet mock.
ensEnabled, ensNameboolean, stringControl whether ENS is available and which name is shown.
balanceEnabled, balanceEthboolean, stringControls mock balance availability and ETH amount.

You can also pass mockWallet, mockEns, and mockBalance in story.parameters for more control. The preview merges those with any args above.

Preview parameters

preview.tsx also sets:

  • parameters.nextjs.appDirectory = true for App Router compatibility.
  • parameters.docs.theme = RitoTheme to match the RitoSwap visual system.
Last updated on

RitoSwap Docs does not store, collect or access any of your conversations. All saved prompts are stored locally in your browser only.