Skip to content

Commit

Permalink
fix: decorators were not being applied (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Mar 1, 2024
1 parent b965b8d commit 7acb618
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/red-hotels-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@storybook/marko": patch
---

Fix issue with decorators not being applied.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@ export const Secondary = {
};
```

### Using Decorators

[Storybook `decorators`](https://storybook.js.org/docs/writing-stories/decorators) provide a way to wrap a component with another component to provide context, styling, or additional functionality.

With `@storybook/marko` your decorators _must_ be a function that returns the same signature as the story functions.
The `component` specified in the decorator will be provided a [`renderBody`](https://markojs.com/docs/syntax/#dynamic-body-content) which can be used to render the nested `Story` or another decorator.

```js
import Button from "./button.marko";
import Decorator from "./decorator.marko";

export default {
title: "Button",
component: Button,
decorators: [
() => ({
component: Decorator,
input: {
// optionally pass some input to the decorator
},
}),
],
};

export const Primary = {
args: {
// ...
},
};
```

### Using with TypeScript

Some types are exposed by this module to make it easier to write your stores using TypeScript.
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers/marko/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { parameters as docsParams } from "./docs/config";
export const parameters = { renderer: "marko" as const, ...docsParams };
export { decorators, argTypesEnhancers } from "./docs/config";
export { render, renderToCanvas } from "./render";
export { decorateStory } from "./decorators";
export { decorateStory, decorateStory as applyDecorators } from "./decorators";

0 comments on commit 7acb618

Please sign in to comment.