mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
2c556366e2
Load modules in React using importOverleafModules Babel macro GitOrigin-RevId: 5553ede59d75306a7085424b5e0a20dabe0792f5
36 lines
916 B
JavaScript
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'
|
|
}
|