mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 09:31:47 +08:00
29 lines
620 B
Plaintext
29 lines
620 B
Plaintext
```ts
|
|
// MyComponent.stories.ts|tsx
|
|
|
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { useChannel } from '@storybook/preview-api';
|
|
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
|
|
|
import { MyComponent } from './MyComponent';
|
|
|
|
const meta: Meta<typeof MyComponent> = {
|
|
component: MyComponent,
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof MyComponent>;
|
|
|
|
export const Highlighted: Story = {
|
|
decorators: [
|
|
(storyFn) => {
|
|
const emit = useChannel({});
|
|
emit(HIGHLIGHT, {
|
|
elements: ['h2', 'a', '.storybook-button'],
|
|
});
|
|
return storyFn();
|
|
},
|
|
],
|
|
};
|
|
```
|