Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(SplitButton): Updating splitButton component to match Teams redlines #2108

Merged
merged 41 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a12a600
updating splitbutton
notandrew Nov 12, 2019
3a11b5b
putting the border on the content instead of container
notandrew Nov 13, 2019
91319cf
Merge branch 'master' into fix/splitbutton-styles
notandrew Nov 15, 2019
63a3f82
adding small button
notandrew Nov 15, 2019
b40ae4f
adding small documentation
notandrew Nov 15, 2019
bbb72db
Merge branch 'master' into fix/splitbutton-styles
notandrew Nov 18, 2019
14ea6d6
fixing styles for split button
notandrew Nov 18, 2019
161877c
updating changelog
notandrew Nov 19, 2019
f1dc15a
merge
notandrew Nov 20, 2019
86fcbb2
Merge branch 'master' into fix/splitbutton-styles
notandrew Nov 21, 2019
d32fcc1
updating button
notandrew Nov 22, 2019
3b372ba
Merge branch 'master' into fix/splitbutton-styles
notandrew Nov 22, 2019
b150d8d
fixing styles
notandrew Nov 25, 2019
5bb1d2f
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 2, 2019
ca1b853
updating focus state
notandrew Dec 4, 2019
9ef45a2
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 4, 2019
c1b5322
updating proptypes
notandrew Dec 4, 2019
564dc93
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 4, 2019
2cb4502
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 5, 2019
5eb3933
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 9, 2019
e6a51e0
updating changelog
notandrew Dec 9, 2019
cab4a43
updating small boolean to a size string
notandrew Dec 10, 2019
6946d61
fixing merge
notandrew Dec 10, 2019
995eb26
fixing border width
notandrew Dec 10, 2019
aed62a7
fixing focus state so it shows only on keyboard focus
notandrew Dec 11, 2019
00b6da0
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 12, 2019
de4b451
updating changelog
notandrew Dec 12, 2019
5361fcb
updating changelog
notandrew Dec 12, 2019
2ba338d
fixing merge
notandrew Dec 16, 2019
2b48923
updating split button's icon after fluent rename
notandrew Dec 16, 2019
88e1a75
fixing changelog
notandrew Dec 16, 2019
a8e0be7
Update docs/src/examples/components/SplitButton/Types/index.tsx
notandrew Dec 17, 2019
8cbe27b
Update CHANGELOG.md
notandrew Dec 17, 2019
e555eae
udpating size to SizeValue
notandrew Dec 17, 2019
4c1ae34
updating size to SizeValue
notandrew Dec 17, 2019
153b6db
missed a size.
notandrew Dec 17, 2019
d315862
updating changelog
notandrew Dec 18, 2019
80c6323
fixing merge
notandrew Dec 19, 2019
6d63f59
Merge branch 'master' into fix/splitbutton-styles
notandrew Dec 20, 2019
cae5a58
updating toggle button example to use proper icon
notandrew Dec 20, 2019
4b21c92
Merge branch 'master' into fix/splitbutton-styles
notandrew Jan 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Fixes
- Updating `splitButton` component to match Teams redlines @notandrew ([#2108](https://github.com/microsoft/fluent-ui-react/pull/2108))
notandrew marked this conversation as resolved.
Show resolved Hide resolved

<!--------------------------------[ v0.42.0 ]------------------------------- -->
## [v0.42.0](https://github.com/microsoft/fluent-ui-react/tree/v0.42.0) (2019-12-12)
[Compare changes](https://github.com/microsoft/fluent-ui-react/compare/v0.41.01..v0.42.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react'
import { SplitButton } from '@fluentui/react'

const SplitButtonExampleSmallShorthand = () => (
<>
<SplitButton
menu={[
{ key: 'group', content: 'New group message' },
{ key: 'channel', content: 'New channel message' },
]}
button={{
content: 'small',
'aria-roledescription': 'splitbutton',
'aria-describedby': 'instruction-message',
}}
size="small"
toggleButton={{ 'aria-label': 'expand options menu' }}
onMainButtonClick={() => alert('button was clicked')}
/>
<span aria-hidden="true" id="instruction-message" style={{ opacity: 0 }}>
to open menu, press Alt + Arrow Down
</span>
</>
)

export default SplitButtonExampleSmallShorthand
5 changes: 5 additions & 0 deletions docs/src/examples/components/SplitButton/Types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const SplitButton = () => (
description="A SplitButton can be formatted to show primary level of emphasis."
examplePath="components/SplitButton/Types/SplitButtonExamplePrimary"
/>
<ComponentExample
title="small Split Button"
notandrew marked this conversation as resolved.
Show resolved Hide resolved
description="small splitbutton"
notandrew marked this conversation as resolved.
Show resolved Hide resolved
examplePath="components/SplitButton/Types/SplitButtonExampleSmall"
/>
</ExampleSection>
)

Expand Down
12 changes: 9 additions & 3 deletions packages/react/src/components/SplitButton/SplitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { PopupProps } from '../Popup/Popup'

export interface SplitButtonSlotClassNames {
toggleButton: string
size?: string
}

export interface SplitButtonProps
Expand Down Expand Up @@ -84,6 +85,9 @@ export interface SplitButtonProps
/** A split button can be formatted to show different levels of emphasis. */
secondary?: boolean

/** A split button can be small */
size?: string
notandrew marked this conversation as resolved.
Show resolved Hide resolved

/** Shorthand for the toggle button. */
toggleButton?: ShorthandValue<ButtonProps>
}
Expand Down Expand Up @@ -118,14 +122,15 @@ class SplitButton extends AutoControlledComponent<WithAsProp<SplitButtonProps>,
onMenuItemClick: PropTypes.func,
onOpenChange: PropTypes.func,
open: PropTypes.bool,
size: PropTypes.string,
notandrew marked this conversation as resolved.
Show resolved Hide resolved
primary: customPropTypes.every([customPropTypes.disallow(['secondary']), PropTypes.bool]),
secondary: customPropTypes.every([customPropTypes.disallow(['primary']), PropTypes.bool]),
toggleButton: customPropTypes.itemShorthand,
}

static defaultProps = {
accessibility: splitButtonBehavior,
as: 'span',
as: 'div',
toggleButton: {},
}

Expand Down Expand Up @@ -174,7 +179,7 @@ class SplitButton extends AutoControlledComponent<WithAsProp<SplitButtonProps>,
const { button, disabled, menu, primary, secondary, toggleButton } = this.props
const trigger = Button.create(button, {
defaultProps: () => ({
styles: styles.button,
styles: styles.menuButton,
primary,
secondary,
disabled,
Expand Down Expand Up @@ -202,9 +207,10 @@ class SplitButton extends AutoControlledComponent<WithAsProp<SplitButtonProps>,
)}
{Button.create(toggleButton, {
defaultProps: () => ({
styles: styles.toggleButton,
className: SplitButton.slotClassNames.toggleButton,
disabled,
icon: 'icon-arrow-down',
icon: 'icon-menu-arrow-down',
iconOnly: true,
primary,
secondary,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,95 @@
import { ICSSInJSStyle } from '../../../types'
import getBorderFocusStyles from '../../getBorderFocusStyles'
import SplitButton from '../../../../components/SplitButton/SplitButton'
import getIconFillOrOutlineStyles from '../../getIconFillOrOutlineStyles'

const splitButtonStyles = {
button: ({ variables: v }): ICSSInJSStyle => ({
border: 0,
menuButton: ({ props: p, variables: v }): ICSSInJSStyle => ({
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
borderRightWidth: 0,
padding: v.padding,

...(p.size === 'small' && {
height: v.smallDimension,
padding: v.smallPadding,
minWidth: v.smallMinWidth,
boxShadow: v.smallBoxShadow,
}),

':focus-visible': {
'::before': { border: 0 },
'::after': { border: 0 },
borderRightWidth: 0,

':before': {
borderRightWidth: 0,
},

':after': {
borderRightWidth: 0,
},
},

':active': {
animationName: 'unset',
animationDuration: 'unset',
},
':active': { backgroundColor: v.backgroundColorActive },
}),

toggleButton: ({ props: p, variables: v, theme: { siteVariables } }): ICSSInJSStyle => ({
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
borderColor: v.borderColor,
...getIconFillOrOutlineStyles({ outline: true }),

...(p.primary && {
borderWidth: `0 0 0 ${siteVariables.borderWidth}`,
borderColor: v.borderColorPrimary,
}),

...(p.disabled && {
borderWidth: `0 0 0 ${siteVariables.borderWidth}`,
borderColor: v.borderColorDisabled,
}),

...(p.size === 'small' && {
height: v.smallDimension,
width: v.smallDimension,
minWidth: v.smallMinWidth,
boxShadow: v.smallBoxShadow,
}),

':focus-visible': {
':before': {
borderLeftWidth: 0,
},

':after': {
borderLeftWidth: 0,
},
},

':active': {
animationName: 'unset',
animationDuration: 'unset',
},
}),

root: ({ props: p, variables: v, theme: { siteVariables } }): ICSSInJSStyle => {
const { borderWidth } = siteVariables
const borderFocusStyles = getBorderFocusStyles({
siteVariables,
})

return {
border: `${borderWidth} solid ${v.borderColor}`,
borderRadius: v.borderRadius,
position: 'relative',
display: 'inline-block',

[`& .${SplitButton.slotClassNames.toggleButton}`]: {
borderRight: 0,
borderTop: 0,
borderBottom: 0,
},

':focus-within': {
boxShadow: 'none',
...(p.isFromKeyboard
? {
[`& .${SplitButton.slotClassNames.toggleButton}`]: {
color: p.primary ? v.primaryColorFocus : v.colorFocus,
backgroundColor: p.primary ? v.primaryBackgroundColorFocus : v.backgroundColorFocus,
borderColor: siteVariables.colors.white,
},

color: v.colorFocus,
backgroundColor: v.backgroundColorFocus,
...borderFocusStyles[':focus-visible'],
}
: { ':active': { backgroundColor: v.backgroundColorActive } }),
...(p.isFromKeyboard && {
// make sure focus is coming from keyboard before applying the focus styles
// otherwise focus state is applied only to the button and not the toggle
...borderFocusStyles[':focus-visible'],
}),
},
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { SiteVariablesPrepared } from '../../../types'

import { pxToRem } from '../../../../utils'

export interface SplitButtonVariables {
borderRadius: string
backgroundColorFocus: string
boxShadow: string
borderColorPrimary: string
borderColor: string
colorFocus: string
primaryBackgroundColorFocus: string
primaryColorFocus: string
borderColorDisabled: string
smallDimension: string
notandrew marked this conversation as resolved.
Show resolved Hide resolved
smallPadding: string
smallMinWidth: string
smallBoxShadow: string
padding: string
iconMargin: string
}

export default (siteVars: SiteVariablesPrepared): SplitButtonVariables => {
return {
borderRadius: siteVars.borderRadius,
backgroundColorFocus: siteVars.colors.grey[200],
boxShadow: siteVars.shadowLevel1,
borderColor: siteVars.colors.grey[200],
colorFocus: siteVars.colors.grey[750],
primaryBackgroundColorFocus: siteVars.colors.brand[800],
primaryColorFocus: siteVars.colors.white,
borderColor: siteVars.colorScheme.default.border,
borderColorPrimary: siteVars.colors.brand[500],
notandrew marked this conversation as resolved.
Show resolved Hide resolved
borderColorDisabled: siteVars.colorScheme.brand.foregroundDisabled,
smallDimension: pxToRem(24),
smallPadding: `0 ${pxToRem(8)}`,
smallMinWidth: '0',
smallBoxShadow: 'none',
padding: `0 ${pxToRem(16)}`,
iconMargin: `0 0 ${pxToRem(8)} 0`,
}
}