Skip to content

Commit

Permalink
feat: add buttonRef prop
Browse files Browse the repository at this point in the history
  • Loading branch information
wmui51 committed Aug 24, 2023
1 parent 701c5cb commit 92ce3a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/button/src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ButtonPresenter from "./presenters/ButtonPresenter";

const Button = (props) => {
const {
buttonRef,
disabled,
icon,
link,
Expand Down Expand Up @@ -54,6 +55,7 @@ const Button = (props) => {
onMouseUp: handleMouseUp,
}) => (
<ButtonPresenter
buttonRef={buttonRef}
disabled={disabled}
hasFocus={hasFocus}
hasHover={hasHover}
Expand Down Expand Up @@ -89,12 +91,16 @@ Button.defaultProps = {
};

Button.propTypes = {
/**
* A callback ref that gets passed to the HTML button
*/
buttonRef: PropTypes.func,
/**
* Prevents user interaction with the button
*/
disabled: PropTypes.bool,
/**
* A @hig/icon element
* A @weave-design/icon element
*/
icon: PropTypes.node,
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/button/src/presenters/ButtonPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

const ButtonPresenter = (props) => {
const {
buttonRef,
disabled,
hasFocus,
hasHover,
Expand Down Expand Up @@ -61,6 +62,7 @@ const ButtonPresenter = (props) => {
return (
<Wrapper
{...otherProps}
ref={buttonRef}
className={cx(css(cssStyles.button), className)}
href={href}
tabIndex={tabIndex}
Expand Down Expand Up @@ -97,6 +99,7 @@ const ButtonPresenter = (props) => {
ButtonPresenter.displayName = "ButtonPresenter";

ButtonPresenter.propTypes = {
buttonRef: PropTypes.func,
disabled: PropTypes.bool,
hasFocus: PropTypes.bool,
hasHover: PropTypes.bool,
Expand Down

0 comments on commit 92ce3a4

Please sign in to comment.