mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 15:41:57 +08:00
31 lines
718 B
Plaintext
31 lines
718 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 = {
|
|
component: MyComponent,
|
|
} satisfies Meta<typeof MyComponent>;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const StyledHighlight: Story = {
|
|
decorators: [
|
|
(storyFn) => {
|
|
const emit = useChannel({});
|
|
emit(HIGHLIGHT, {
|
|
elements: ['h2', 'a', '.storybook-button'],
|
|
color: 'blue',
|
|
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
|
});
|
|
return storyFn();
|
|
},
|
|
],
|
|
};
|
|
```
|