Files
react-test/packages/mui-material/src/Box/Box.spec.tsx
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

48 lines
1.3 KiB
TypeScript

import { Box as SystemBox, BoxProps as SystemBoxProps, createBox } from '@mui/system';
import { expectType } from '@mui/types';
import Box, { BoxProps as MaterialBoxProps } from '@mui/material/Box';
import { createTheme } from '@mui/material/styles';
function ThemeValuesCanBeSpread() {
<Box
sx={(theme) => ({
...theme.typography.body1,
color: theme.palette.primary.main,
})}
/>;
<Box
sx={(theme) => ({
...theme.mixins.toolbar,
color: theme.palette.primary.main,
})}
/>;
<Box
sx={(theme) => ({
...theme.mixins.toolbar,
color: 'primary.main',
})}
/>;
}
// Compatibility with Material UI's Box
const defaultTheme = createTheme({});
const CustomBox = createBox({ defaultTheme });
expectType<typeof Box, typeof CustomBox>(CustomBox);
// @ts-expect-error System's Box has different type than Material UI's Box
expectType<typeof SystemBox, typeof CustomBox>(CustomBox);
function ColorTest() {
<Box
color={(theme) => theme.vars.palette.common.black}
sx={(theme) => ({ backgroundColor: theme.vars.palette.background.default })}
/>;
}
function ComponentTest() {
return <span />;
}
expectType<SystemBoxProps['component'], MaterialBoxProps['component']>('span');
expectType<SystemBoxProps['component'], MaterialBoxProps['component']>(ComponentTest);