Files
react-test/docs/data/joy/customization/default-theme-viewer/JoyDefaultTheme.js
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

53 lines
1.3 KiB
JavaScript

import * as React from 'react';
import { extendTheme } from '@mui/joy/styles';
import Box from '@mui/joy/Box';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import ThemeViewer, {
useItemIdsLazy,
} from 'docs/src/modules/components/ThemeViewer';
const defaultTheme = extendTheme();
export default function JoyDefaultTheme() {
const [expandPaths, setExpandPaths] = React.useState(null);
React.useEffect(() => {
let expandPath;
decodeURI(document.location.search.slice(1))
.split('&')
.forEach((param) => {
const [name, value] = param.split('=');
if (name === 'expand-path') {
expandPath = value;
}
});
if (!expandPath) {
return;
}
setExpandPaths(
expandPath
.replace('$.', '')
.split('.')
.reduce((acc, path) => {
const last = acc.length > 0 ? `${acc[acc.length - 1]}.` : '';
acc.push(last + path);
return acc;
}, []),
);
}, []);
const data = defaultTheme;
const allNodeIds = useItemIdsLazy(data);
React.useDebugValue(allNodeIds);
return (
<Box sx={{ width: '100%' }}>
<ThemeProvider theme={() => createTheme()}>
<ThemeViewer data={data} expandPaths={expandPaths} />
</ThemeProvider>
</Box>
);
}