-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Refactor: Button #6134
Labels
Comments
Closing down #3308 and moving the new button experiment to here. |
This was referenced Dec 27, 2018
Closed
This was referenced Mar 6, 2019
2 tasks
2 tasks
This is covered via button convergence, not needed anymore Check out the new button here: https://github.com/microsoft/fluentui/tree/master/packages/react-button |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Component Details
The implementation of the
Button
component currently existing in theoffice-ui-fabric-react
package has become more complex and its api more confusing as time has gone by. In an effort to simplify the api we are rewritingButton
into a new component that's easier to use and easier to maintain.In tandem with these efforts, we are taking this opportunity to use all of the latest developments in the new
Button
component, including:Steps
ContextualMenu
from newButton
(Button: Separating MenuButton and SplitButton as variants to decouple ContextualMenu from Button #8291)Button
more modularButton
to size auditor (Button: Adding experimental Button to test-bundles so that size-auditor can tell us about changes in baseline #8898, Adding @uifabric/experiments as a dependency in test-bundles to prevent potential breaks. #8985)menu
prop optional (first mentioned in Slots: Refactor and add options structure for more rendering options. #8754 and done in Button: Making all MenuButton props optional #8975)Alt+Down
menu behavior inSplitButton
(SplitButton: Adding ability to use Alt+Down key combination from first focus stop and cleaning up API #9136)getNativeProps
get the correct set of native props (Button: Getting anchor native props if href prop is specified #9456)focus
method (Button: Adding focus tests for Button, MenuButton and SplitButton. #9490)BaseButton
toActionable
and strip down functionality, then haveButton
extend fromActionable
(first mentioned in Button: Changing style of all variants to be Fluent by default and removing use of palette in favor of semantic slots #8963.) (Button: Renaming BaseButton to Actionable, extending Button from Actionable and removing content and icon from Actionable types #9436)extendComponent
(waiting on Foundation: Extend Component #8331 and mentioned in Button: Creating ActionButton variant and cleaning styling #8645)text
,iconProps
, etc) (mentioned in Button: Creating ActionButton variant and cleaning styling #8645) (Button: Migration for text, iconProps, menuProps and split deprecated props #9354)Upgrade Plan
Part of upgrading usage of the old
Button
component to the new one is having a compelling story of how to transition current users seamlessly. In order to do that we need to establish what are we going to do with all existing exports.Below is a list of all existing exports under the current
Button
(except the ones tha come from example files) and the actions we're taking for each one:ActionButton
getStyles
ActionButtonTokens
ActionButton
ActionButton
ActionButton
variantBaseButton
IButtonClassNames
BaseButtonStyles
andBaseButtonTokens
BaseButton
ButtonGlobalClassNames
BaseButtonStyles
andBaseButtonTokens
BaseButton
getBaseButtonClassNames
BaseButtonStyles
andBaseButtonTokens
BaseButton
getStyles
BaseButtonStyles
andBaseButtonTokens
BaseButton
IBaseButtonProps
BaseButton
IBaseButtonState
BaseButton
BaseButton
BaseButton
variantButton
Button
Button
Button
IButton
API Review
section belowButton
IButtonProps
API Review
section belowButton
ElementType
IButtonProps
Button
ButtonType
Button
IButtonStyles
IButtonSlots
andIButtonTokens
ButtonThemes
standardStyles
Button.styles.ts
ButtonThemes
primaryStyles
Button.styles.ts
CommandBarButton
getStyles
CommandBarButtonTokens
CommandBarButton
CommandBarButton
CommandBarButton
variantCommandButton
CommandButton
CommandButton
variantCompoundButton
getStyles
CompoundButtonStyles
andCompoundButtonTokens
CompoundButton
CompoundButton
CompoundButton
variantDefaultButton
getStyles
Button.styles.ts
DefaultButton
DefaultButton
DefaultButton
variantIconButton
getStyles
IconButtonTokens
IconButton
IconButton
IconButton
variantMessageBarButton
getStyles
MessageBarButtonTokens
MessageBarButton
MessageBarButton
MessageBarButton
variantPrimaryButton
PrimaryButton
PrimaryButton
variantSplitButton
ISplitButtonClassNames
SplitButton
variantSplitButton
getClassNames
SplitButtonStyles
andSplitButtonTokens
SplitButton
getStyles
SplitButtonStyles
andSplitButtonTokens
Fluent style parity between old and new Button
For every example, the
Buttons
above are the oldButtons
and theButtons
below are the new ones.Base Buttons:
Default and Primary Buttons:
Menu Buttons:
Split Buttons:
Slightly different to fix some visual bugs in these buttons:
Action Buttons:
CommandBar Buttons:
Compound Buttons:
Icon Buttons:
Slightly different to fix some visual bugs in these buttons:
MessageBar Buttons:
API Review
As part of the migration from the old
Button
approach currently in theoffice-ui-fabric-react
package to the new one currently in theexperiments
package, there needs to be a functional parity between the two components. This is so taht we can have a compelling story when promoting the newButton
.Below is a mapping between the properties of the old
Button
and the actions we took for each one to transition them to the newButton
component:IButtonProps
href
Button
component as part ofIButtonProps
primary
Button
component as part ofIButtonProps
disabled
Button
component as part ofIButtonProps
ariaLabel
Button
component as part ofIButtonProps
checked
Button
component as part ofIButtonProps
allowDisabledFocus
Button
component as part ofIButtonProps
keytipProps
Button
component as part ofIButtonProps
uniqueId
Button
component as part ofIButtonProps
componentRef
Button
component as part ofIBaseProps
styles
Button
component as part ofIBaseProps
theme
Button
component as part ofIBaseProps
className
Button
component as part ofIBaseProps
text
Button
component ascontent
slot inIButtonSlots
iconProps
Button
component asicon
slot inIButtonSlots
menuProps
Button
component asmenu
slot inIButtonSlots
menuIconProps
Button
component asmenuIcon
slot inIButtonSlots
onAfterMenuDismiss
Button
component asonMenuDismiss
inIButtonViewProps
onRenderChildren
root
orstack
slotsonRenderIcon
icon
slotonRenderText
content
slotonRenderMenuIcon
menuIcon
slotmenuAs
menu
slotonMenuClick
MenuButton
variant asonClick
inIMenuButtonProps
split
Button
variantSplitButton
primaryDisabled
SplitButton
variant asprimaryActionDisabled
inISplitMenuButtonProps
splitButtonAriaLabel
SplitButton
variant assecondaryAriaLabel
inISplitMenuButtonProps
buttonType
rootProps
onRenderMenu
menuAs
toggled
checked
description
secondaryText
ariaHidden
getClassNames
getSplitButtonClassNames
secondaryText
toggle
onRenderDescription
secondaryText
is being deprecatedonRenderAriaDescription
secondaryText
is being deprecatedariaDescription
secondaryText
is being deprecatedpersistMenu
Button
data
Button
menuTriggerKeyCode
IButton
focus
Button
component as part ofIButton
dismissMenu
Button
openMenu
Button
Component Documentation
Imports
TBD
Exports/ Component Breakdown
TBD
Intended Package
Initially in
@uifabric/experiments
while we drive the changes to have the correct api, but with the intention of moving it tooffice-ui-fabric-react
after that is done.Code mockup/example
TBD
Button Types
Button
IButtonSlots
root
IHTMLElementSlot<Button>
stack
IStackSlot
Button
.content
ITextSlot
Button
.icon
IIconSlot
Button
.IButtonProps
href
string
primary
boolean
false
Button
should be emphasized.circular
boolean
false
Button
should be circular. In general, circularButtons
should not specify the menu and container slots.disabled
boolean
false
Button
is disabled.onClick
(ev: React.MouseEvent<HTMLElement>) => void
Button
is clicked.IButtonViewProps
IButtonTokens
backgroundColor
strong
backgroundColorHovered
string
backgroundColorPressed
string
color
string
colorFocused
string
colorHovered
string
colorPressed
string
borderColor
string
borderColorHovered
string
borderColorPressed
string
iconColor
string
iconColorHovered
string
iconColorPressed
string
outlineColor
string
borderRadius
number
|string
borderWidth
number
|string
contentPadding
number
|string
contentPaddingFocused
number
|string
textFamily
string
textSize
number
|string
textWeight
IFontWeight
width
number
|string
height
number
|string
iconSize
number
|string
iconWeight
number
lineHeight
number
|string
minWidth
number
|string
minHeight
number
|string
backgroundClip
IRawStyleBase['backgroundClip']
MenuButton
IMenuButtonSlots
root
IHTMLElementSlot<div>
button
IButtonSlot
menu
IContextualMenuSlot
MenuButton
.menuIcon
IIconSlot
MenuButton
.IMenuButtonProps
defaultExpanded
boolean
MenuButton
. If you want theMenuButton
to maintain its own state, use this. Otherwise, refer toexpanded
.expanded
boolean
defaultExpanded
MenuButton
is in an expanded state.onKeyDown
(ev: React.KeyboardEvent<HTMLElement>) => void
MenuButton
.IMenuButtonViewProps
onMenuDismiss
() => void
MenuButton
's contextual menu has been closed (removed from the DOM).menuTarget
HTMLElement
|undefined
undefined
IMenuButtonTokens
SplitButton
ISplitButtonSlots
root
IStackSlot
menuButton
IMenuButtonSlot
splitDivider
IHTMLSlot
SplitButton
.ISplitButtonProps
primaryActionDisabled
boolean
false
SplitButton
is disabled.ISplitButtonViewProps
onSecondaryActionClick
(ev: React.MouseEvent<HTMLElement>) => void
SplitButton
is disabled.ISplitButtonTokens
Bundle Size Improvements
Old Button (Stat: 564.5KB, Parsed: 175.3KB, Gzipped: 47.35KB):
New Button (Stat: 325.08KB, Parsed: 88.83KB, Gzipped: 26.6KB):
Perf Comparison
The scenarios render the components 5000 times. Each scenario is run 10 times to get an average number and account for variants.
DefaultButton:
210.41% worse than old Button.
24.26% better after Stack removal.
PrimaryButton:
196.32% worse than old Button.
23.18% better after Stack removal.
MenuButton:
235.64% worse than old Button.
12.00% better after Stack removal.
SplitButton:
225.26% worse than old Button.
25.12% better after Stack removal.
Design Assets
Component Ownership
office-ui-fabric-react
.Deadlines
After 7.0 release.
Promotion Checklist
The text was updated successfully, but these errors were encountered: