Skip to content

Commit

Permalink
[material-ui][Backdrop] Convert to support CSS extraction (#41581)
Browse files Browse the repository at this point in the history
  • Loading branch information
aacevski authored Mar 21, 2024
1 parent 3322cbb commit 479ec18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client';
import SimpleBackdrop from '../../../../../../docs/data/material/components/backdrop/SimpleBackdrop';

export default function Backdrop() {
return (
<section>
<h2> Simple Backdrop</h2>
<div className="demo-container">
<SimpleBackdrop />
</div>
</section>
);
}
20 changes: 13 additions & 7 deletions packages/mui-material/src/Backdrop/Backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import styled from '../styles/styled';
import useThemeProps from '../styles/useThemeProps';
import { styled, createUseThemeProps } from '../zero-styled';
import useSlot from '../utils/useSlot';
import Fade from '../Fade';
import { getBackdropUtilityClass } from './backdropClasses';

const useThemeProps = createUseThemeProps('MuiBackdrop');

const useUtilityClasses = (ownerState) => {
const { classes, invisible } = ownerState;

Expand All @@ -27,7 +28,7 @@ const BackdropRoot = styled('div', {

return [styles.root, ownerState.invisible && styles.invisible];
},
})(({ ownerState }) => ({
})({
position: 'fixed',
display: 'flex',
alignItems: 'center',
Expand All @@ -38,10 +39,15 @@ const BackdropRoot = styled('div', {
left: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
WebkitTapHighlightColor: 'transparent',
...(ownerState.invisible && {
backgroundColor: 'transparent',
}),
}));
variants: [
{
props: { invisible: true },
style: {
backgroundColor: 'transparent',
},
},
],
});

const Backdrop = React.forwardRef(function Backdrop(inProps, ref) {
const props = useThemeProps({ props: inProps, name: 'MuiBackdrop' });
Expand Down

0 comments on commit 479ec18

Please sign in to comment.