Skip to content

Commit

Permalink
fix: mdx inherit webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 26, 2020
1 parent 5152a18 commit 74faadd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 18 deletions.
34 changes: 16 additions & 18 deletions core/webpack-configs/src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,23 @@ export const react: Configuration = {
{
test: /\.(md|mdx)$/i,
exclude: [/node_modules/],
use: [
{
loader: 'babel-loader',
options: {
presets: [
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }],
require.resolve('@babel/preset-react'),
],
},
},
{
loader: '@component-controls/loader/loader',
options: {
mdx: {
transformMDX: true,
},
},
loader: 'babel-loader',
options: {
presets: [
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }],
require.resolve('@babel/preset-react'),
],
},
},
{
test: /\.(md|mdx)$/i,
exclude: [/node_modules/],
loader: '@component-controls/loader/loader',
options: {
mdx: {
transformMDX: true,
},
],
},
},
{
test: /\.(story|stories|doc|docs).(js|jsx|ts|tsx)$/,
Expand Down
48 changes: 48 additions & 0 deletions examples/gatsby/src/stories/smart-controls.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Meta} from '@component-controls/storybook';
import { PropsTable, Playground, Story, ComponentSource, StorySource } from '@component-controls/blocks';
import { Button } from '../../../stories/src/components/Button';

<Meta title="Introduction/MDX Smart" parameters={{component: Button}} />


# Smart controls
<ComponentSource of={Button} title='Component source' />

<Story id="." />

<StorySource id="." />

<PropsTable of={Button} />


<Playground>
<Story name="smart story">
{(props) => (
<Button label="default" {...props}/>
)}
</Story>
</Playground>


# Small story with custom controls

<Playground>
<Story name="small story"
controls={{
text: {type: 'text', value: 'Hello'},
}}
>
{({ text }) => (
<Button label={text}/>
)}
</Story>
</Playground>

# Story with no parameters == no smart controls

<Playground>
<Story name="no controls">
<Button label="Hello"/>
<Button label="Second button"/>
</Story>
</Playground>

0 comments on commit 74faadd

Please sign in to comment.