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

[NativeSelectInput] Support CSS theme variables #34975

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/mui-material/src/NativeSelect/NativeSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export const nativeSelectSelectStyles = ({ ownerState, theme }) => ({
cursor: 'pointer',
'&:focus': {
// Show that it's not an text input
backgroundColor:
theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',
...(theme.vars
? { backgroundColor: `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.05)` }
: {
backgroundColor:
theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',
}),
borderRadius: 0, // Reset Chrome style
},
// Remove IE11 arrow
Expand All @@ -43,7 +47,7 @@ export const nativeSelectSelectStyles = ({ ownerState, theme }) => ({
height: 'auto',
},
'&:not([multiple]) option, &:not([multiple]) optgroup': {
backgroundColor: theme.palette.background.paper,
backgroundColor: (theme.vars || theme).palette.background.paper,
},
// Bump specificity to allow extending custom inputs
'&&&': {
Expand All @@ -56,9 +60,9 @@ export const nativeSelectSelectStyles = ({ ownerState, theme }) => ({
},
}),
...(ownerState.variant === 'outlined' && {
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
'&:focus': {
borderRadius: theme.shape.borderRadius, // Reset the reset for Chrome style
borderRadius: (theme.vars || theme).shape.borderRadius, // Reset the reset for Chrome style
},
'&&&': {
paddingRight: 32,
Expand Down Expand Up @@ -88,9 +92,9 @@ export const nativeSelectIconStyles = ({ ownerState, theme }) => ({
right: 0,
top: 'calc(50% - .5em)', // Center vertically, height is 1em
pointerEvents: 'none', // Don't block pointer events on the select under the icon.
color: theme.palette.action.active,
color: (theme.vars || theme).palette.action.active,
[`&.${nativeSelectClasses.disabled}`]: {
color: theme.palette.action.disabled,
color: (theme.vars || theme).palette.action.disabled,
},
...(ownerState.open && {
transform: 'rotate(180deg)',
Expand Down