This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(factories): use
children
in shorthands as render props (#1951)
* feat(factories): add renderProps via `children` to shorthands * do not pass children down * use new callback * fix types * update docs * fix usage in `Dropdown` * fix warnings in tests * add changelog * improve typings * fix EditorToolbar * add link to React docs * changelog
- Loading branch information
1 parent
7d07123
commit 7498901
Showing
17 changed files
with
221 additions
and
248 deletions.
There are no files selected for viewing
This file contains 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 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 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
52 changes: 28 additions & 24 deletions
52
docs/src/examples/components/Menu/Usage/MenuExampleWithTooltip.shorthand.tsx
This file contains 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,32 +1,36 @@ | ||
import * as React from 'react' | ||
import { Menu, Tooltip } from '@fluentui/react' | ||
|
||
const itemRenderer = (MenuItem, props) => { | ||
const { tooltip = '', ...rest } = props | ||
|
||
return ( | ||
<Tooltip content={tooltip}> | ||
<MenuItem {...rest} /> | ||
</Tooltip> | ||
) | ||
} | ||
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' }, | ||
{ | ||
key: 'editorials', | ||
content: 'Editorials', | ||
tooltip: 'Click for opening Editorials', | ||
children: itemRenderer, | ||
}, | ||
{ | ||
key: 'review', | ||
content: 'Reviews', | ||
tooltip: 'Click for opening Reviews', | ||
children: itemRenderer, | ||
}, | ||
{ | ||
key: 'events', | ||
content: 'Upcoming Events', | ||
tooltip: 'Click for opening Upcoming Events', | ||
children: itemRenderer, | ||
}, | ||
] | ||
|
||
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> | ||
) | ||
}, | ||
), | ||
)} | ||
/> | ||
) | ||
const MenuExampleWithTooltip = () => <Menu defaultActiveIndex={0} items={items} /> | ||
|
||
export default MenuExampleWithTooltip |
This file contains 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 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 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 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
Oops, something went wrong.