overleaf/services/web/frontend/stories/import-overleaf-modules.stories.js
Alasdair Smith 2c556366e2 Merge pull request #3464 from overleaf/as-import-from-settings-macro
Load modules in React using importOverleafModules Babel macro

GitOrigin-RevId: 5553ede59d75306a7085424b5e0a20dabe0792f5
2020-12-17 03:07:42 +00:00

36 lines
916 B
JavaScript

import React from 'react'
import importOverleafModules from '../macros/import-overleaf-module.macro'
const imports = importOverleafModules('storybook')
function ImportOverleafModulesMacroDemo() {
if (!imports.length) {
return (
<div style={{ backgroundColor: 'white' }}>
<p>
You do not have any module imports configured. Add the following to
your settings:
</p>
<code>
{`moduleImports: { storybook: [PATH_TO_MODULE_THAT_EXPORTS_COMPONENT] }`}
</code>
<p>Then restart Storybook.</p>
</div>
)
}
return (
<div style={{ backgroundColor: 'white' }}>
{imports.map(({ import: { default: Component }, path }) => {
return <Component key={path} />
})}
</div>
)
}
export const Demo = args => <ImportOverleafModulesMacroDemo {...args} />
export default {
title: 'importOverleafModule Macro'
}