This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
feat(docs): add usage example with Tooltip for the actionable elements #1636
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
68c2771
-added button with tooltip usage example
9d77408
-added menu and toolbar examples with tooltip
021ab6a
-changed links to the tooltip docs page
45e1faf
simplified toolbar example
d30b881
-changed examples titles
1506357
-changed examples for toolbar
8420bd5
Merge branch 'master' into docs/add-actionable-examples
mnajdova b0022e9
Merge branch 'master' into docs/add-actionable-examples
mnajdova f2250a8
Merge branch 'master' into docs/add-actionable-examples
mnajdova bda16a1
-addressed comments
12abc6f
-added screener steps
da3942c
-fixed screener steps
c6aae6f
-changed toolbar example steps
649d093
Merge branch 'master' into docs/add-actionable-examples
mnajdova 743c57f
-changed changelog entry
eba8e24
-removed toolbar with tooltip steps
2992691
-created Toolbar example with tooltip steps
884e373
-added toolbar class name in the steps
60622e5
-added label behavior for the toolbar items
5e2b332
Merge branch 'master' into docs/add-actionable-examples
mnajdova 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
11 changes: 11 additions & 0 deletions
11
docs/src/examples/components/Button/Usage/ButtonExampleWithTooltip.shorthand.steps.ts
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,11 @@ | ||
| import { Button } from '@stardust-ui/react' | ||
|
|
||
| const config: ScreenerTestsConfig = { | ||
| themes: ['teams', 'teamsDark', 'teamsHighContrast'], | ||
| steps: [ | ||
| builder => builder.hover(`.${Button.className}`).snapshot('Shows tooltip'), | ||
| builder => builder.hover('body'), // we need the mouse to be moved out of the button for the next test | ||
| ], | ||
| } | ||
|
|
||
| export default config |
11 changes: 11 additions & 0 deletions
11
docs/src/examples/components/Button/Usage/ButtonExampleWithTooltip.shorthand.tsx
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,11 @@ | ||
| import * as React from 'react' | ||
| import { Button, Tooltip } from '@stardust-ui/react' | ||
|
|
||
| const ButtonExampleWithTooltip = () => ( | ||
| <Tooltip | ||
| trigger={<Button content="Button with tooltip" />} | ||
| content="This is an actionable element." | ||
| /> | ||
| ) | ||
|
|
||
| export default ButtonExampleWithTooltip |
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
21 changes: 21 additions & 0 deletions
21
docs/src/examples/components/Menu/Usages/MenuExampleWithTooltip.shorthand.steps.ts
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,21 @@ | ||
| import { Menu } from '@stardust-ui/react' | ||
|
|
||
| const selectors = { | ||
| menu: `.${Menu.className}`, | ||
| item: (itemIndex: number) => `.${Menu.className} li:nth-child(${itemIndex}) a`, | ||
| } | ||
|
|
||
| const config: ScreenerTestsConfig = { | ||
| themes: ['teams', 'teamsDark', 'teamsHighContrast'], | ||
| steps: [ | ||
| (builder, keys) => | ||
| builder | ||
| .hover(selectors.item(1)) | ||
| .snapshot('Hovers 1st item (show tooltip)') | ||
| .click(selectors.item(1)) | ||
| .keys(selectors.item(1), keys.rightArrow) | ||
| .snapshot('Navigates to next item (shows tooltip)'), | ||
| ], | ||
| } | ||
|
|
||
| export default config |
32 changes: 32 additions & 0 deletions
32
docs/src/examples/components/Menu/Usages/MenuExampleWithTooltip.shorthand.tsx
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,32 @@ | ||
| import * as React from 'react' | ||
| import { Menu, Tooltip } from '@stardust-ui/react' | ||
|
|
||
| const items = [ | ||
| { key: 'editorials', content: 'Editorials', tooltip: 'Click for opening Editorials' }, | ||
| { key: 'review', content: 'Reviews', tooltip: 'Click for opening Reviews' }, | ||
| { key: 'events', content: 'Upcoming Events', tooltip: 'Click for opening Upcoming Events' }, | ||
| ] | ||
|
|
||
| const MenuExampleWithTooltip = () => ( | ||
| <Menu | ||
| defaultActiveIndex={0} | ||
| items={items.map(item => render => | ||
| render( | ||
| /* what to render */ | ||
| item, | ||
|
|
||
| /* how to render */ | ||
| (MenuItem, props) => { | ||
| const { tooltip = '', ...rest } = props || {} | ||
| return ( | ||
| <Tooltip content={tooltip}> | ||
| <MenuItem {...rest} /> | ||
| </Tooltip> | ||
| ) | ||
| }, | ||
| ), | ||
| )} | ||
| /> | ||
| ) | ||
|
|
||
| export default MenuExampleWithTooltip |
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
21 changes: 21 additions & 0 deletions
21
docs/src/examples/components/Toolbar/Usage/ToolbarExampleWithTooltip.shorthand.steps.ts
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,21 @@ | ||
| import { Toolbar } from '@stardust-ui/react' | ||
|
|
||
| const selectors = { | ||
| item: (itemIndex: number) => | ||
| `.${Toolbar.className} .${Toolbar.Item.className}:nth-child(${itemIndex})`, | ||
| } | ||
|
|
||
| const config: ScreenerTestsConfig = { | ||
| themes: ['teams', 'teamsDark', 'teamsHighContrast'], | ||
| steps: [ | ||
| (builder, keys) => | ||
| builder | ||
| .hover(selectors.item(1)) | ||
| .snapshot('Hovers 1st item (show tooltip)') | ||
| .click(selectors.item(1)) | ||
| .keys(selectors.item(1), keys.rightArrow) | ||
| .snapshot('Navigates to next item (shows tooltip)'), | ||
| ], | ||
| } | ||
|
|
||
| export default config |
82 changes: 82 additions & 0 deletions
82
docs/src/examples/components/Toolbar/Usage/ToolbarExampleWithTooltip.shorthand.tsx
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,82 @@ | ||
| import * as React from 'react' | ||
| import * as _ from 'lodash' | ||
| import { | ||
| Toolbar, | ||
| Tooltip, | ||
| ToolbarItemShorthandKinds, | ||
| tooltipAsLabelBehavior, | ||
| } from '@stardust-ui/react' | ||
| import { useBooleanKnob } from '@stardust-ui/docs-components' | ||
|
|
||
| const ToolbarExampleShorthand = () => { | ||
| const [isBold, setBold] = useBooleanKnob({ name: 'bold', initialValue: true }) | ||
| const [isItalic, setItalic] = useBooleanKnob({ name: 'isItalic', initialValue: false }) | ||
|
|
||
| const [moreMenuOpen, setMoreMenuOpen] = useBooleanKnob({ | ||
| name: 'moreMenuOpen', | ||
| initialValue: false, | ||
| }) | ||
|
|
||
| return ( | ||
| <Toolbar | ||
| items={[ | ||
| { | ||
| key: 'bold', | ||
| kind: 'toggle' as ToolbarItemShorthandKinds, | ||
| active: isBold, | ||
| tooltip: 'Bold', | ||
| icon: { name: 'bold', outline: true }, | ||
| onClick: () => setBold(!isBold), | ||
| }, | ||
| { | ||
| key: 'italic', | ||
| kind: 'toggle' as ToolbarItemShorthandKinds, | ||
| active: isItalic, | ||
| tooltip: 'Italic', | ||
| icon: { name: 'italic', outline: true }, | ||
| onClick: () => setItalic(!isItalic), | ||
| }, | ||
| { key: 'divider1', kind: 'divider' as ToolbarItemShorthandKinds }, | ||
| { | ||
| key: 'more', | ||
| icon: { name: 'more', outline: true }, | ||
| active: moreMenuOpen, | ||
| tooltip: 'More options', | ||
| menu: [ | ||
| { | ||
| content: 'Quote', | ||
| icon: 'quote', | ||
| }, | ||
| { | ||
| content: 'Code snippet', | ||
| icon: 'code-snippet', | ||
| }, | ||
| ], | ||
| menuOpen: moreMenuOpen, | ||
| onMenuOpenChange: (e, { menuOpen }) => setMoreMenuOpen(menuOpen), | ||
| }, | ||
| ].map(item => | ||
| _.isNil(item.tooltip) | ||
| ? item | ||
| : render => | ||
| render( | ||
| item, | ||
| // rendering Tooltip for the Toolbar Item | ||
| (ToolbarItem, props) => { | ||
| const { tooltip, ...rest } = props | ||
| // Adding tooltipAsLabelBehavior as the ToolbarItems contains only icon | ||
| return ( | ||
| <Tooltip | ||
| trigger={<ToolbarItem {...rest} />} | ||
| accessibility={tooltipAsLabelBehavior} | ||
| content={tooltip} | ||
| /> | ||
| ) | ||
| }, | ||
| ), | ||
| )} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default ToolbarExampleShorthand | ||
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,21 @@ | ||
| import * as React from 'react' | ||
| import { Link } from 'react-router-dom' | ||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
|
||
| const Usage = () => ( | ||
| <ExampleSection title="Usage"> | ||
| <ComponentExample | ||
| title="With tooltips" | ||
| description={ | ||
| <> | ||
| {'The items inside the Toolbar, as actionable elements, should be rendered with '} | ||
| <Link to="/components/tooltip">tooltip</Link> | ||
| </> | ||
| } | ||
| examplePath="components/Toolbar/Usage/ToolbarExampleWithTooltip" | ||
| /> | ||
| </ExampleSection> | ||
| ) | ||
|
|
||
| export default Usage |
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
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
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.