From f042c2fea8de469ed3b25de7d282e689f8f95ad8 Mon Sep 17 00:00:00 2001 From: Diego Andai Date: Tue, 22 Aug 2023 16:59:55 -0400 Subject: [PATCH] Experiment with active state for select styling --- .../experiments/material/button-select.tsx | 139 ++++++++++++++++++ .../mui-material/src/ButtonBase/ButtonBase.js | 7 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 docs/pages/experiments/material/button-select.tsx diff --git a/docs/pages/experiments/material/button-select.tsx b/docs/pages/experiments/material/button-select.tsx new file mode 100644 index 00000000000000..76585aacb9cb8b --- /dev/null +++ b/docs/pages/experiments/material/button-select.tsx @@ -0,0 +1,139 @@ +import * as React from 'react'; +import { Button as BaseUIButton } from '@mui/base'; +import { + Button as JoyUIButton, + CssVarsProvider as JoyCssVarsProvider, + extendTheme as joyExtendTheme, +} from '@mui/joy'; +import { + Button as MaterialUIButton, + Experimental_CssVarsProvider as MaterialUICssVarsProvider, + experimental_extendTheme as materialUIExtendTheme, +} from '@mui/material'; +import { Stack } from '@mui/system'; + +function createHandlers(name: string) { + return { + onClick: () => console.log(`${name} click`), + onMouseDown: () => console.log(`${name} mouse down`), + onMouseUp: () => console.log(`${name} mouse up`), + }; +} + +export default function App() { + return ( + + + + Enabled native button + + + + Disabled native button + + + + Native anchor + + Anchor + + + + Native div +
Button
+
+
+ + {/* + + Enabled Base UI button + Button + + + Disabled Base UI button + + Button + + + + Enabled Base UI button as div + + Button + + + + Disabled Base UI button as div + + Button + + + + + + + + Enabled Joy UI button + Button + + + Disabled Joy UI button + + Button + + + + Enabled Joy UI button as div + + Button + + + + Disabled Joy UI button as div + + Button + + + + */} + + + + + Enabled Material UI button + Button + + + Disabled Material UI button + + Button + + + + Enabled Material UI button as div + + Button + + + + Disabled Material UI button as div + + Button + + + + +
+ ); +} diff --git a/packages/mui-material/src/ButtonBase/ButtonBase.js b/packages/mui-material/src/ButtonBase/ButtonBase.js index e9a41cfcf14c87..27309d18d2de8b 100644 --- a/packages/mui-material/src/ButtonBase/ButtonBase.js +++ b/packages/mui-material/src/ButtonBase/ButtonBase.js @@ -53,12 +53,17 @@ export const ButtonBaseRoot = styled('button', { textDecoration: 'none', // So we take precedent over the style of a native element. color: 'inherit', + '&:active': { + userSelect: 'none', + }, '&::-moz-focus-inner': { borderStyle: 'none', // Remove Firefox dotted outline. }, [`&.${buttonBaseClasses.disabled}`]: { - pointerEvents: 'none', // Disable link interactions cursor: 'default', + '&:active': { + pointerEvents: 'none', // Disable link interactions + }, }, '@media print': { colorAdjust: 'exact',