Skip to content

Commit

Permalink
fix string only template for vue
Browse files Browse the repository at this point in the history
  • Loading branch information
yaodingyd committed Oct 8, 2018
1 parent e52a3d3 commit c93bcaf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/vue/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ const decorateStory = (getStory, decorators) =>
decorators.reduce(
(decorated, decorator) => context => {
const story = () => decorated(context);
const decoratedStory = decorator(story, context);
let decoratedStory = decorator(story, context);

if (typeof decoratedStory === 'string') {
decoratedStory = { template: decoratedStory };
}

decoratedStory.components = decoratedStory.components || {};
decoratedStory.components.story = createWrapperComponent(story());
return decoratedStory;
Expand Down
4 changes: 0 additions & 4 deletions app/vue/src/client/preview/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export default function render({
Vue.config.errorHandler = showException;

const component = story();

if (typeof component === 'string') {
component = { template: component };
}

if (!component) {
showError({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Core|Template string only 1`] = `
<button
class="button"
style="color: rgb(66, 185, 131); border-color: #42b983;"
>
A Button with square edges!
</button>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { storiesOf } from '@storybook/vue';

storiesOf('Core|Template', module).add(
'string only',
() => '<my-button :rounded="false">A Button with square edges</my-button>'
);

0 comments on commit c93bcaf

Please sign in to comment.