Skip to content
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

[ButtonBase] Add a TouchRippleProps property #10470

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
1 change: 1 addition & 0 deletions pages/api/button-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ It contains a load of style reset and some focus/ripple logic.
| <span class="prop-name">focusRipple</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If `true`, the base button will have a keyboard focus ripple. `disableRipple` must also be `false`. |
| <span class="prop-name">keyboardFocusedClassName</span> | <span class="prop-type">string | | The CSS class applied while the component is keyboard focused. |
| <span class="prop-name">onKeyboardFocus</span> | <span class="prop-type">func | | Callback fired when the component is focused with a keyboard. We trigger a `onFocus` callback too. |
| <span class="prop-name">TouchRippleProps</span> | <span class="prop-type">object | | Properties applied to the `TouchRipple` element. |

Any other properties supplied will be [spread to the root element](/guides/api#spread).

Expand Down
2 changes: 2 additions & 0 deletions src/ButtonBase/ButtonBase.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { StandardProps } from '..';
import { TouchRippleProps } from './TouchRipple';

export interface ButtonBaseProps
extends StandardProps<
Expand All @@ -13,6 +14,7 @@ export interface ButtonBaseProps
focusRipple?: boolean;
keyboardFocusedClassName?: string;
onKeyboardFocus?: React.FocusEventHandler<any>;
TouchRippleProps?: Partial<TouchRippleProps>;
}

export type ButtonBaseClassKey = 'root' | 'disabled';
Expand Down
7 changes: 6 additions & 1 deletion src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class ButtonBase extends React.Component {
onTouchMove,
onTouchStart,
tabIndex,
TouchRippleProps,
type,
...other
} = this.props;
Expand Down Expand Up @@ -279,7 +280,7 @@ class ButtonBase extends React.Component {
>
{children}
{!disableRipple && !disabled ? (
<TouchRipple innerRef={this.onRippleRef} center={centerRipple} />
<TouchRipple innerRef={this.onRippleRef} center={centerRipple} {...TouchRippleProps} />
) : null}
</ComponentProp>
);
Expand Down Expand Up @@ -388,6 +389,10 @@ ButtonBase.propTypes = {
* @ignore
*/
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* Properties applied to the `TouchRipple` element.
*/
TouchRippleProps: PropTypes.object,
/**
* @ignore
*/
Expand Down