-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proof of Concept] Multiple Stories inside one MD #178
base: master
Are you sure you want to change the base?
Conversation
``` | ||
|
||
```js | ||
// const Button = require('../components/Button'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now don't know how correctly import components.
It should work in context of md file dir.
@@ -130,10 +130,11 @@ export default class ReadmeContent extends React.Component { | |||
case LAYOUT_TYPE_MD: | |||
return ( | |||
<DocPreview key={index}> | |||
<div | |||
<div className={'markdown-body'}>{content}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content
is rendered components tree
@@ -66,6 +66,14 @@ export default function getDocsLayout({ | |||
}) { | |||
const mdAsArray = Array.isArray(md) ? [...md] : [md]; | |||
// const mdWithEmojis = mdAsArray.map(md => transformEmojis(md)); | |||
|
|||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove old md features for Proof of convept. Returns only compiled md content
|
||
const unsemicolon = s => s.replace(/;\s*$/, ''); | ||
|
||
function processCode(code) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const value = state.counter || 0;
<button
onClick={() => {
setState({
counter: value + 1,
});
}}
>
Hello World {value}
</button>;
Transforms into
const value = state.counter || 0;
return <button
onClick={() => {
setState({
counter: value + 1,
});
}}
>
Hello World {value}
</button>;
} | ||
|
||
const getStoryComponent = code => { | ||
return new Function('require', 'state', 'setState', 'React', code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval
Current blockers:
Importing components from md code blocks
The problem is that we parse it in runtime and seems it is not possible to make dynamic imports.
To make it possible we should parse it with webpack but this seems to be a complicated solution.
Maybe it is better to pass components as story arguments instead of importing them.
Implementation for VUE
I am not experienced with vue. Would be nice if someone with experience would help with implementation.
We could start with React implementation and then add support for Vue.
@lonyele What do you think?