-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Docs: Updates documentation and examples for Highlight #23830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0b2a48
Updates documentation and examples for Highlight
jonniebigodes c7bffac
Initial feedback addressed
jonniebigodes b358aa2
Cleanup snippets
jonniebigodes 6932bd7
Adds missing import to addon docs
jonniebigodes f84d6e3
Merge branch 'next' into chore_docs_update_highlight
jonniebigodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ```ts | ||
| // MyComponent.stories.ts | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/angular'; | ||
| import { componentWrapperDecorator } from '@storybook/angular'; | ||
| import { useChannel } from '@storybook/preview-api'; | ||
| import { HIGHLIGHT, RESET_HIGHLIGHT } from '@storybook/addon-highlight'; | ||
|
|
||
| import { MyComponent } from './MyComponent.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, { | ||
| elements: ['header', 'section', 'footer'], | ||
| }); | ||
| return story; | ||
| }), | ||
| ], | ||
| }; | ||
| ``` |
27 changes: 11 additions & 16 deletions
27
docs/snippets/angular/component-story-highlight-addon.ts.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,29 @@ | ||
| ```ts | ||
| // Card.stories.ts | ||
| // MyComponent.stories.ts | ||
|
|
||
| import { componentWrapperDecorator } from '@storybook/angular'; | ||
| import type { Meta, StoryObj } from '@storybook/angular'; | ||
| import { componentWrapperDecorator } from '@storybook/angular'; | ||
| import { useChannel } from '@storybook/preview-api'; | ||
| import { HIGHLIGHT, RESET_HIGHLIGHT } from '@storybook/addon-highlight'; | ||
| import { Card } from './card.component'; | ||
| import { HIGHLIGHT } from '@storybook/addon-highlight'; | ||
|
|
||
| const meta: Meta<Card> = { | ||
| /* 👇 The title prop is optional. | ||
| * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading | ||
| * to learn how to generate automatic titles | ||
| */ | ||
| title: 'Card', | ||
| component: Card, | ||
| import { MyComponent } from './MyComponent.component'; | ||
|
|
||
| const meta: Meta<MyComponent> = { | ||
| component: MyComponent, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<Card>; | ||
| type Story = StoryObj<MyComponent>; | ||
|
|
||
| export const Default: Story = (args) => ({ | ||
| template: '<app-card></app-card>', | ||
| export const Highlighted: Story = { | ||
| decorators: [ | ||
| componentWrapperDecorator((story) => { | ||
| const emit = useChannel({}); | ||
| emit(HIGHLIGHT, { | ||
| elements: ['.title', '.subtitle'], | ||
| elements: ['h2', 'a', '.storybook-button'], | ||
| }); | ||
| return story; | ||
| }), | ||
| ], | ||
| }); | ||
| }; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ```ts | ||
| // 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'; | ||
|
|
||
| const meta: Meta<MyComponent> = { | ||
| component: MyComponent, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<MyComponent>; | ||
|
|
||
| export const StyledHighlight: Story = { | ||
| decorators: [ | ||
| componentWrapperDecorator((story) => { | ||
| const emit = useChannel({}); | ||
| emit(HIGHLIGHT, { | ||
| elements: ['h2', 'a', '.storybook-button'], | ||
| color: 'blue', | ||
| style: 'double', // 'dotted' | 'dashed' | 'solid' | 'double' | ||
| }); | ||
| return story; | ||
| }), | ||
| ], | ||
| }; | ||
| ``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.