-
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.
MenuButton: Removing legacy patterns from converged component (#18498)
* MenuButton: Removing legacy patterns from converged component. * Change files * Calling useButtonStyles at the end of useMenuButtonStyles function.
- Loading branch information
Showing
8 changed files
with
52 additions
and
110 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-button-5d563384-02a5-4c36-aa04-a80bd9d271b8.json
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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "MenuButton: Removing legacy patterns from converged component.", | ||
"packageName": "@fluentui/react-button", | ||
"email": "Humberto.Morimoto@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
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
2 changes: 1 addition & 1 deletion
2
packages/react-button/src/components/MenuButton/MenuButton.test.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
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
2 changes: 1 addition & 1 deletion
2
packages/react-button/src/components/MenuButton/useMenuButtonState.ts
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
57 changes: 18 additions & 39 deletions
57
packages/react-button/src/components/MenuButton/useMenuButtonStyles.ts
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,52 +1,31 @@ | ||
import { mergeClasses, makeStyles } from '@fluentui/react-make-styles'; | ||
import { Theme } from '@fluentui/react-theme'; | ||
import { useButtonStyles } from '../Button/useButtonStyles'; | ||
import { MenuButtonState, MenuButtonStyleSelectors, MenuButtonVariantTokens } from './MenuButton.types'; | ||
import { MenuButtonState } from './MenuButton.types'; | ||
|
||
export const makeMenuButtonTokens = (theme: Theme): MenuButtonVariantTokens => ({ | ||
base: { | ||
menuIconFontSize: '20px', | ||
menuIconHeight: '20px', | ||
menuIconWidth: '20px', | ||
const useMenuIconStyles = makeStyles({ | ||
small: { | ||
fontSize: '20px', | ||
height: '20px', | ||
width: '20px', | ||
}, | ||
medium: { | ||
fontSize: '20px', | ||
height: '20px', | ||
width: '20px', | ||
}, | ||
large: { | ||
menuIconFontSize: '24px', | ||
menuIconHeight: '24px', | ||
menuIconWidth: '24px', | ||
fontSize: '24px', | ||
height: '24px', | ||
width: '24px', | ||
}, | ||
}); | ||
|
||
const useStyles = makeStyles({ | ||
menuIcon: theme => { | ||
const menuButtonTokens = makeMenuButtonTokens(theme); | ||
|
||
return { | ||
fontSize: menuButtonTokens.base?.menuIconFontSize, | ||
height: menuButtonTokens.base?.menuIconHeight, | ||
width: menuButtonTokens.base?.menuIconWidth, | ||
}; | ||
}, | ||
menuIconLarge: theme => { | ||
const menuButtonTokens = makeMenuButtonTokens(theme); | ||
export const useMenuButtonStyles = (state: MenuButtonState): MenuButtonState => { | ||
const menuIconStyles = useMenuIconStyles(); | ||
|
||
return { | ||
fontSize: menuButtonTokens.large?.menuIconFontSize, | ||
height: menuButtonTokens.large?.menuIconHeight, | ||
width: menuButtonTokens.large?.menuIconWidth, | ||
}; | ||
}, | ||
}); | ||
state.menuIcon.className = mergeClasses(menuIconStyles[state.size], state.menuIcon.className); | ||
|
||
export const useMenuButtonStyles = (state: MenuButtonState, selectors: MenuButtonStyleSelectors) => { | ||
useButtonStyles(state); | ||
|
||
const styles = useStyles(); | ||
|
||
if (state.menuIcon) { | ||
state.menuIcon.className = mergeClasses( | ||
styles.menuIcon, | ||
selectors.size === 'large' && styles.menuIconLarge, | ||
state.menuIcon.className, | ||
); | ||
} | ||
return state; | ||
}; |