mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 23:32:08 +08:00
Initial feedback addressed
This commit is contained in:
parent
c0b2a48250
commit
c7bffac080
@ -19,7 +19,7 @@ yarn add --dev @storybook/addon-highlight
|
||||
npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @storybook/addon-highlight --save-dev
|
||||
npm install @storybook/addon-highlight --save-dev
|
||||
```
|
||||
|
||||
pnpm:
|
||||
@ -45,15 +45,13 @@ export default config;
|
||||
|
||||
### Highlighting DOM Elements
|
||||
|
||||
Highlight DOM nodes by emitting the `HIGHLIGHT` event from within a story or an addon. The event payload must contain a list of selectors you want to highlight.
|
||||
Highlight DOM nodes by emitting the `HIGHLIGHT` event from within a story or an addon. The event payload must contain an `elements` property assigned to an array of selectors matching the elements you want to highlight.
|
||||
|
||||
```ts
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent';
|
||||
@ -86,9 +84,7 @@ Highlights are automatically cleared when the story changes. You can also manual
|
||||
// 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';
|
||||
@ -116,15 +112,13 @@ export const ResetHighlight: Story = {
|
||||
|
||||
### Customize style
|
||||
|
||||
The addon applies a standard style to the highlighted elements you've enabled for the story. However, you can enable your custom style by extending the configuration object and providing a `color` and `style` option. For example:
|
||||
The addon applies a standard style to the highlighted elements you've enabled for the story. However, you can enable your custom style by extending the payload object and providing a `color` and/or `style` properties. For example:
|
||||
|
||||
```ts
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent';
|
||||
|
@ -8,7 +8,7 @@ Storybook's [Highlight](https://storybook.js.org/addons/@storybook/addon-highlig
|
||||
|
||||
## Highlighting DOM Elements
|
||||
|
||||
To highlight DOM elements with the addon, you'll need to emit the `HIGHLIGHT` event from within a story or an addon. The event payload must contain a list of selectors you want to highlight. For example:
|
||||
To highlight DOM elements with the addon, you'll need to emit the `HIGHLIGHT` event from within a story or an addon. The event payload must contain an `elements` property assigned to an array of selectors matching the elements you want to highlight. For example:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
@ -48,7 +48,7 @@ Out of the box, Storybook automatically removes highlighted elements when transi
|
||||
|
||||
## Customize style
|
||||
|
||||
By default, the addon applies a standard style to the highlighted elements you've enabled for the story. However, you can enable your custom style by extending the configuration object and providing a `color` and `style` option. For example:
|
||||
By default, the addon applies a standard style to the highlighted elements you've enabled for the story. However, you can enable your custom style by extending the payload object and providing a `color` and/or `style` properties. For example:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
|
@ -2,11 +2,8 @@
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/angular';
|
||||
|
||||
import { componentWrapperDecorator } from '@storybook/angular';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent.component';
|
||||
|
@ -2,11 +2,8 @@
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/angular';
|
||||
|
||||
import { componentWrapperDecorator } from '@storybook/angular';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent.component';
|
||||
@ -25,8 +22,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return story;
|
||||
}),
|
||||
|
@ -2,7 +2,6 @@
|
||||
// MyComponent.stories.js|jsx
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent';
|
||||
|
@ -2,9 +2,7 @@
|
||||
// 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';
|
||||
|
@ -2,9 +2,7 @@
|
||||
// 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';
|
||||
|
@ -2,7 +2,6 @@
|
||||
// MyComponent.stories.js|jsx
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import { MyComponent } from './MyComponent';
|
||||
@ -18,8 +17,7 @@ export const StyledHighlight = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return storyFn();
|
||||
},
|
||||
|
@ -2,9 +2,7 @@
|
||||
// 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';
|
||||
@ -23,8 +21,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return storyFn();
|
||||
},
|
||||
|
@ -2,9 +2,7 @@
|
||||
// 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';
|
||||
@ -23,8 +21,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return storyFn();
|
||||
},
|
||||
|
@ -2,7 +2,6 @@
|
||||
// MyComponent.stories.js
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
// Replace vue3 with vue if you are using Storybook for Vue 2
|
||||
import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
// Replace vue3 with vue if you are using Storybook for Vue 2
|
||||
import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
|
@ -2,9 +2,7 @@
|
||||
// MyComponent.stories.js
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
|
||||
export default {
|
||||
@ -18,8 +16,7 @@ export const StyledHighlight = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return {
|
||||
template: '<story />',
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
// Replace vue3 with vue if you are using Storybook for Vue 2
|
||||
import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
@ -24,8 +22,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return {
|
||||
template: '<story />',
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
// Replace vue3 with vue if you are using Storybook for Vue 2
|
||||
import type { Meta, StoryObj } from '@storybook/vue3';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
import MyComponent from './MyComponent.vue';
|
||||
@ -24,8 +22,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return {
|
||||
template: '<story />',
|
||||
|
@ -2,7 +2,6 @@
|
||||
// MyComponent.stories.js
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
export default {
|
||||
|
@ -2,9 +2,7 @@
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
export default {
|
||||
|
@ -2,7 +2,6 @@
|
||||
// MyComponent.stories.js
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
export default {
|
||||
@ -16,8 +15,7 @@ export const StyledHighlight = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return story();
|
||||
},
|
||||
|
@ -2,9 +2,7 @@
|
||||
// MyComponent.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
|
||||
import { useChannel } from '@storybook/preview-api';
|
||||
|
||||
import { HIGHLIGHT } from '@storybook/addon-highlight';
|
||||
|
||||
export default {
|
||||
@ -18,8 +16,7 @@ export const StyledHighlight: Story = {
|
||||
emit(HIGHLIGHT, {
|
||||
elements: ['h2', 'a', '.storybook-button'],
|
||||
color: 'blue',
|
||||
// 👇 Specify the style of the highlighted elements acccepted values are: 'double', 'solid', 'dotted', 'dashed'
|
||||
style: 'double',
|
||||
style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double'
|
||||
});
|
||||
return story();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user