Skip to content

Commit

Permalink
Port change to material-next ButtonBase
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Sep 13, 2023
1 parent 2252e17 commit d8d70fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/mui-material-next/src/ButtonBase/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ButtonBaseRoot = styled('button', {
slot: 'Root',
shouldForwardProp: (prop) => rootShouldForwardProp(prop) && prop !== 'touchRippleRef',
overridesResolver: (props, styles) => styles.root,
})({
})<{ ownerState: ButtonBaseOwnerState }>(({ ownerState }) => ({
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
Expand All @@ -57,7 +57,9 @@ export const ButtonBaseRoot = styled('button', {
borderRadius: 0,
padding: 0, // Remove the padding in Firefox
cursor: 'pointer',
userSelect: 'none',
'&:active': {
userSelect: 'none',
},
verticalAlign: 'middle',
MozAppearance: 'none', // Reset
WebkitAppearance: 'none', // Reset
Expand All @@ -68,13 +70,15 @@ export const ButtonBaseRoot = styled('button', {
borderStyle: 'none', // Remove Firefox dotted outline.
},
[`&.${buttonBaseClasses.disabled}`]: {
pointerEvents: 'none', // Disable link interactions
...(!ownerState.isButton && {
pointerEvents: 'none', // Disable link interactions
}),
cursor: 'default',
},
'@media print': {
colorAdjust: 'exact',
},
}) as React.ElementType<any>;
})) as React.ElementType<any>;

/**
* `ButtonBase` contains as few styles as possible.
Expand Down Expand Up @@ -156,6 +160,7 @@ const ButtonBase = React.forwardRef(function ButtonBase<
disableTouchRipple,
focusVisible,
active,
isButton: ComponentProp === 'button',
};

const classes = useUtilityClasses(ownerState);
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-material-next/src/ButtonBase/ButtonBase.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export type ButtonBaseProps<
};

export interface ButtonBaseOwnerState extends ButtonBaseProps {
/**
* If `true`, the DOM element is button.
*/
isButton: boolean;
/**
* If `true`, the button is active.
*/
Expand Down

0 comments on commit d8d70fb

Please sign in to comment.