Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "SpinButton: Add getClassNAmes prop to allow complete customization of the component",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather nervous of this change. A better approach would be to avoid the getClassNames approach and use the 6.0 getStyles functional approach. We found that getClassNames required us to come up with every possible permutation of areas and states, whereas a function of state can produce a given set of area classes.

See the ghdocs/styling.md file for more description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzearing this is another case where we need something that lets us completely override the styling in the 5.0 timeframe for Office Online.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just move it to getStyles in the 5.0 branch?

"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,20 @@ export class SpinButton extends BaseComponent<ISpinButtonProps, ISpinButtonState
keyboardSpinDirection
} = this.state;

const classNames = getClassNames(
getStyles(theme!, customStyles),
!!disabled,
!!isFocused,
keyboardSpinDirection,
labelPosition
);
const classNames = this.props.getClassNames ?
this.props.getClassNames(
theme!,
!!disabled,
!!isFocused,
keyboardSpinDirection,
labelPosition
) : getClassNames(
getStyles(theme!, customStyles),
!!disabled,
!!isFocused,
keyboardSpinDirection,
labelPosition
);

return (
<div className={ classNames.root }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import { Position } from '../../utilities/positioning';
import { IIconProps } from '../../Icon';
import { ITheme, IStyle } from '../../Styling';
import { ISpinButtonClassNames } from './SpinButton.classNames';
import { KeyboardSpinDirection } from './SpinButton';
import { IButtonStyles } from '../../Button';

export interface ISpinButton {
Expand Down Expand Up @@ -133,6 +135,18 @@ export interface ISpinButtonProps {
*/
styles?: Partial<ISpinButtonStyles>;

/**
* Custom function for providing the classNames for the spinbutton. Can be used to provide
* all styles for the component instead of applying them on top of the default styles.
*/
getClassNames?: (
theme: ITheme,
disabled: boolean,
isFocused: boolean,
keyboardSpinDirection: KeyboardSpinDirection,
labelPosition?: Position
) => ISpinButtonClassNames;

/**
* Custom styles for the upArrow button.
*
Expand Down