Skip to content

Commit

Permalink
fix: add back component parameter option, rename template to component
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jul 19, 2019
1 parent 6a428af commit 0008b23
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
10 changes: 5 additions & 5 deletions app/marko/src/client/preview/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export default function renderMain({
}) {
const config = storyFn();

if (!config || !(config.appendTo || config.template || parameters.template)) {
if (!config || !(config.appendTo || config.component || parameters.component)) {
showError({
title: `Expecting an object with a template property to be returned from the story: "${selectedStory}" of "${selectedKind}".`,
title: `Expecting an object with a component property to be returned from the story: "${selectedStory}" of "${selectedKind}".`,
description: stripIndents`
Did you forget to return the template from the story?
Use "() => ({ template: MyTemplate, input: { hello: 'world' } })" when defining the story.
Did you forget to return the component from the story?
Use "() => ({ component: MyComponent, input: { hello: 'world' } })" when defining the story.
`,
});

Expand All @@ -39,7 +39,7 @@ export default function renderMain({

activeComponent = config.appendTo(rootEl).getComponent();
} else {
const template = config.template || parameters.template;
const template = config.component || parameters.component;

if (activeTemplate === template) {
// When rendering the same template with new input, we reuse the same instance.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/guides/guide-marko/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ import Button from '../components/button/index.marko';
storiesOf('Button', module)
.add('with text', () => ({
template: Button,
component: Button,
input: { text 'some text' }
}))
.add('with emoji', () => ({
template: Button,
component: Button,
input: { text '😀 😎 👍 💯' }
}));
```
Expand Down
6 changes: 4 additions & 2 deletions examples/marko-cli/src/stories/addon-actions.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import Button from '../components/action-button/index.marko';
export default {
title: 'Addons|Actions/Button',
parameters: {
options: { panelPosition: 'right' },
options: {
component: Button,
panelPosition: 'right',
},
},
};

export const Simple = () => ({
template: Button,
input: { click: action('action logged!') },
});
2 changes: 1 addition & 1 deletion examples/marko-cli/src/stories/addon-knobs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
title: 'Addons|Knobs/Hello',
decorators: [withKnobs],
parameters: {
template: Hello,
component: Hello,
options: { panelPosition: 'right' },
},
};
Expand Down
5 changes: 4 additions & 1 deletion examples/marko-cli/src/stories/clickcount.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import ClickCount from '../components/click-count/index.marko';

export default {
title: 'Main|ClickCount',
parameters: {
component: ClickCount,
},
};

export const Simple = () => ({ template: ClickCount });
export const Simple = () => ({ component: ClickCount });
5 changes: 4 additions & 1 deletion examples/marko-cli/src/stories/hello.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import Hello from '../components/hello/index.marko';

export default {
title: 'Main|Hello',
parameters: {
component: Hello,
},
};

export const Simple = () => ({ template: Hello, input: { name: 'abc', age: 20 } });
export const Simple = () => ({ input: { name: 'abc', age: 20 } });
export const story2 = () => 'NOT A MARKO RENDER_RESULT';
story2.story = { name: 'with ERROR!' };
5 changes: 4 additions & 1 deletion examples/marko-cli/src/stories/stopwatch.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import StopWatch from '../components/stop-watch/index.marko';

export default {
title: 'Main|StopWatch',
parameters: {
component: StopWatch,
},
};

export const Simple = () => ({ template: StopWatch });
export const Simple = () => ({ component: StopWatch });
5 changes: 4 additions & 1 deletion examples/marko-cli/src/stories/welcome.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Welcome from '../components/welcome/index.marko';

export default {
title: 'Main|Welcome',
parameters: {
component: Welcome,
},
};

export const welcome = () => ({ template: Welcome });
export const welcome = () => ({ component: Welcome });
2 changes: 1 addition & 1 deletion lib/cli/generators/MARKO/template/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { storiesOf } from '@storybook/marko';
import Welcome from './components/welcome/index.marko';

storiesOf('Welcome', module).add('welcome', () => ({ template: Welcome }));
storiesOf('Welcome', module).add('welcome', () => ({ component: Welcome }));

0 comments on commit 0008b23

Please sign in to comment.