docs/_snippets/highlight-reset.md
import { type Meta, type StoryObj, componentWrapperDecorator } from '@storybook/angular';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import { MyComponent } from './my-component.component';
const meta: Meta<MyComponent> = {
component: MyComponent,
};
export default meta;
type Story = StoryObj<MyComponent>;
export const ResetHighlight: Story = {
decorators: [
componentWrapperDecorator((story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story;
}),
],
};
import { componentWrapperDecorator } from '@storybook/angular';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
import { MyComponent } from './my-component.component';
const meta = preview.meta({
component: MyComponent,
});
export const ResetHighlight = meta.story({
decorators: [
componentWrapperDecorator((story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story;
}),
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import { MyComponent } from './MyComponent';
export default {
component: MyComponent,
};
export const ResetHighlight = {
decorators: [
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
};
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
import type { Meta, StoryObj } from '@storybook/your-framework';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/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, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.svelte';
const { Story } = defineMeta({
component: MyComponent,
});
</script>
<Story
name="ResetHighlight"
decorators={[
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
]}
/>
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.svelte';
export default {
component: MyComponent,
};
export const ResetHighlight = {
decorators: [
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.svelte';
const { Story } = defineMeta({
component: MyComponent,
});
</script>
<Story
name="ResetHighlight"
decorators={[
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
]}
/>
// Replace your-framework with svelte-vite or sveltekit
import type { Meta, StoryObj } from '@storybook/your-framework';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.svelte';
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, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
};
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.vue';
export default {
component: MyComponent,
};
export const ResetHighlight = {
decorators: [
() => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return {
template: '<story />',
};
},
],
};
import type { Meta, StoryObj } from '@storybook/vue3-vite';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import MyComponent from './MyComponent.vue';
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
export const ResetHighlight: Story = {
decorators: [
() => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return {
template: '<story />',
};
},
],
};
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
export default {
component: 'my-component',
};
export const ResetHighlight = {
decorators: [
(story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story();
},
],
};
import type { Meta, StoryObj } from '@storybook/web-components-vite';
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
const meta: Meta = {
component: 'my-component',
};
export default meta;
type Story = StoryObj;
export const ResetHighlight: Story = {
decorators: [
(story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story();
},
],
};
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'my-component',
});
export const ResetHighlight = meta.story({
decorators: [
(story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story();
},
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'my-component',
});
export const ResetHighlight = meta.story({
decorators: [
(story) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return story();
},
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
import MyComponent from './MyComponent.vue';
const meta = preview.meta({
component: MyComponent,
});
export const ResetHighlight = meta.story({
decorators: [
() => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return {
template: '<story />',
};
},
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
import MyComponent from './MyComponent.vue';
const meta = preview.meta({
component: MyComponent,
});
export const ResetHighlight = meta.story({
decorators: [
() => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return {
template: '<story />',
};
},
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
import { MyComponent } from './MyComponent';
const meta = preview.meta({
component: MyComponent,
});
export const ResetHighlight = meta.story({
decorators: [
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
});
import { useChannel } from 'storybook/preview-api';
import { HIGHLIGHT, RESET_HIGHLIGHT } from 'storybook/highlight';
import preview from '../.storybook/preview';
import { MyComponent } from './MyComponent';
const meta = preview.meta({
component: MyComponent,
});
export const ResetHighlight = meta.story({
decorators: [
(storyFn) => {
const emit = useChannel({});
emit(RESET_HIGHLIGHT); //๐ Remove previously highlighted elements
emit(HIGHLIGHT, {
selectors: ['header', 'section', 'footer'],
});
return storyFn();
},
],
});