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
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
|
|
import PropTypes from 'prop-types';
|
|
import Button from '@mui/material/Button';
|
|
import { Stack } from '@mui/system';
|
|
|
|
const defaultContrastThresholdTheme = createTheme({});
|
|
|
|
const highContrastThresholdTheme = createTheme({
|
|
palette: {
|
|
contrastThreshold: 4.5,
|
|
},
|
|
});
|
|
|
|
function ContrastShowcase(props) {
|
|
const { title } = props;
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<Stack sx={{ gap: 1, alignItems: 'center' }}>
|
|
<span>
|
|
<b>{title}</b>
|
|
</span>
|
|
<span>{theme.palette.contrastThreshold}:1</span>
|
|
<Stack direction="row" sx={{ gap: 1 }}>
|
|
<Button variant="contained" color="warning">
|
|
Warning
|
|
</Button>
|
|
</Stack>
|
|
</Stack>
|
|
);
|
|
}
|
|
|
|
ContrastShowcase.propTypes = {
|
|
title: PropTypes.string.isRequired,
|
|
};
|
|
|
|
export default function ContrastThreshold() {
|
|
return (
|
|
<Stack direction="row" sx={{ gap: 4 }}>
|
|
<ThemeProvider theme={defaultContrastThresholdTheme}>
|
|
<ContrastShowcase title="Default contrast threshold" />
|
|
</ThemeProvider>
|
|
<ThemeProvider theme={highContrastThresholdTheme}>
|
|
<ContrastShowcase title="Higher contrast threshold" />
|
|
</ThemeProvider>
|
|
</Stack>
|
|
);
|
|
}
|