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

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-05-07 08:03:30 +02:00
import React from 'react'
import { addDecorator } from '@storybook/react'
import {
createHistory,
createMemorySource,
LocationProvider
} from '@reach/router'
2020-05-07 08:03:30 +02:00
// Import global css with custom properties once for all stories.
2020-07-13 23:48:19 +02:00
import '@oceanprotocol/typographies/css/ocean-typo.css'
import '../src/global/styles.css'
2020-05-07 08:03:30 +02:00
// Wrapper for all stories previews
const history = createHistory(createMemorySource('/'))
addDecorator((storyFn) => (
<LocationProvider history={history}>
<div
style={{
minHeight: '100vh',
width: '100%',
padding: '2rem'
}}
>
{storyFn()}
</div>
</LocationProvider>
2020-05-07 08:03:30 +02:00
))
// Gatsby's Link overrides:
// Gatsby defines a global called ___loader to prevent its method calls from creating console errors you override it here
global.___loader = {
enqueue: () => {},
hovering: () => {}
}
// Gatsby internal mocking to prevent unnecessary errors in storybook testing environment
global.__PATH_PREFIX__ = ''
global.__BASE_PATH__ = ''
// This is to utilized to override the window.___navigate method Gatsby defines and uses to report what path a Link would be taking us to if it wasn't inside a storybook
window.___navigate = (pathname) => {
action('NavigateTo:')(pathname)
}