-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16d079a
commit 9f048b9
Showing
12 changed files
with
84 additions
and
39 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
4 changes: 1 addition & 3 deletions
4
packages/react-button/src/components/Button/Button.stories.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
5 changes: 1 addition & 4 deletions
5
packages/react-button/src/components/Button/ButtonBlock.stories.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
5 changes: 1 addition & 4 deletions
5
packages/react-button/src/components/Button/ButtonCircular.stories.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
4 changes: 1 addition & 3 deletions
4
packages/react-button/src/components/Button/ButtonDefault.stories.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
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
5 changes: 1 addition & 4 deletions
5
packages/react-button/src/components/Button/ButtonEmphasis.stories.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
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
5 changes: 1 addition & 4 deletions
5
packages/react-button/src/components/Button/ButtonWithIcon.stories.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
5 changes: 1 addition & 4 deletions
5
packages/react-button/src/components/Button/ButtonWithLongText.stories.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
66 changes: 66 additions & 0 deletions
66
packages/react-menu/src/stories/MenuMemoizedMenuItems.stories.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import * as React from 'react'; | ||
import { | ||
Menu, | ||
MenuTrigger, | ||
MenuList, | ||
MenuItemCheckbox, | ||
MenuPopover, | ||
MenuItemCheckboxProps, | ||
// https://github.com/microsoft/fluentui/pull/18695#issuecomment-868432982 | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
} from '@fluentui/react-menu'; // codesandbox-dependecy: @fluentui/react-button ^9.0.0-alpha | ||
|
||
// https://github.com/microsoft/fluentui/pull/18695#issuecomment-868432982 | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import { Button } from '@fluentui/react-button'; | ||
import { Edit20Regular as EditIcon } from '@fluentui/react-icons'; | ||
|
||
const MemoCheckbox = React.memo((props: MenuItemCheckboxProps) => { | ||
// use icons in the memo because JSX will always create a new object | ||
// possible to memoize icons but it can be overkill | ||
return ( | ||
<MenuItemCheckbox icon={<EditIcon />} name={props.name} value={props.value}> | ||
{props.children} | ||
</MenuItemCheckbox> | ||
); | ||
}); | ||
|
||
export const MemoizedMenuItems = () => { | ||
return ( | ||
<Menu> | ||
<MenuTrigger> | ||
<Button>Toggle menu</Button> | ||
</MenuTrigger> | ||
<MenuPopover> | ||
<MenuList> | ||
<MemoCheckbox name="font" value="segoe"> | ||
Segoe | ||
</MemoCheckbox> | ||
<MemoCheckbox name="font" value="calibri"> | ||
Calibri | ||
</MemoCheckbox> | ||
<MemoCheckbox name="font" value="arial"> | ||
Arial | ||
</MemoCheckbox> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
); | ||
}; | ||
|
||
MemoizedMenuItems.parameters = { | ||
docs: { | ||
description: { | ||
story: [ | ||
'⚠️ _Reredering menu items is a cheap operation and React philosophy encourages rerenders._', | ||
'_Memoization is not free, so use it only when there are concrete benefits to doing so._', | ||
'', | ||
'Memoized menu items can be created using [React.memo](https://reactjs.org/docs/react-api.html#reactmemo)', | ||
'to optimize rerenders of menu items if their props have not changed. Can be useful for selectable items,', | ||
'since each selection will rerender all items in the menu by default.', | ||
].join('\n'), | ||
}, | ||
}, | ||
}; |
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