mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 05:41:49 +08:00
30 lines
716 B
Plaintext
30 lines
716 B
Plaintext
```ts
|
|
// MyComponent.stories.ts|tsx
|
|
|
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { useChannel } from '@storybook/preview-api';
|
|
import { HIGHLIGHT, RESET_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 ResetHighlight: Story = {
|
|
decorators: [
|
|
(storyFn) => {
|
|
const emit = useChannel({});
|
|
emit(RESET_HIGHLIGHT); //👈 Remove previously highlighted elements
|
|
emit(HIGHLIGHT, {
|
|
elements: ['header', 'section', 'footer'],
|
|
});
|
|
return storyFn();
|
|
},
|
|
],
|
|
};
|
|
```
|