diff --git a/docs/src/modules/components/TemplateFrame.js b/docs/src/modules/components/TemplateFrame.js index d2829105313b96..d3efda66621d17 100644 --- a/docs/src/modules/components/TemplateFrame.js +++ b/docs/src/modules/components/TemplateFrame.js @@ -24,12 +24,7 @@ import PaletteIcon from '@mui/icons-material/PaletteOutlined'; import codeSandbox from 'docs/src/modules/sandbox/CodeSandbox'; import stackBlitz from 'docs/src/modules/sandbox/StackBlitz'; import sourceMaterialTemplates from 'docs/src/modules/material/sourceMaterialTemplates'; - -function pascalCase(str) { - return str - .replace(/[^\w]+(.)/g, (_, chr) => chr.toUpperCase()) - .replace(/^(.)/, (_, chr) => chr.toUpperCase()); -} +import { pascalCase } from 'docs/src/modules/utils/helpers'; const StyledAppBar = styled(AppBar)(({ theme }) => ({ position: 'relative', @@ -196,7 +191,7 @@ const brandingTheme = createTheme({ ...getThemedComponents(), }); -function TemplateFrame({ children }) { +export default function TemplateFrame({ children }) { const router = useRouter(); const templateId = router.pathname.split('/').pop(); const templateName = pascalCase(templateId); @@ -262,17 +257,17 @@ function TemplateFrame({ children }) { '& > *': { flexShrink: 0 }, }} > - + - codeSandbox + stackBlitz .createMaterialTemplate({ ...item, files: { ...item.files, ...materialTemplates.sharedTheme?.files }, @@ -291,26 +286,26 @@ function TemplateFrame({ children }) { } return content; }) - .openSandbox(`/${templateName}`) + .openStackBlitz(`/${templateName}`) } sx={{ alignSelf: 'center', borderRadius: 1 }} > - - + + - + - stackBlitz + codeSandbox .createMaterialTemplate({ ...item, files: { ...item.files, ...materialTemplates.sharedTheme?.files }, @@ -329,12 +324,12 @@ function TemplateFrame({ children }) { } return content; }) - .openStackBlitz(`/${templateName}`) + .openSandbox(`/${templateName}`) } sx={{ alignSelf: 'center', borderRadius: 1 }} > - - + + @@ -358,5 +353,3 @@ function TemplateFrame({ children }) { ); } - -export default TemplateFrame; diff --git a/docs/src/modules/utils/helpers.ts b/docs/src/modules/utils/helpers.ts index 4f9c39a048b20c..a80a491919b191 100644 --- a/docs/src/modules/utils/helpers.ts +++ b/docs/src/modules/utils/helpers.ts @@ -3,7 +3,7 @@ import camelCase from 'lodash/camelCase'; import { LANGUAGES } from 'docs/config'; import { Translate } from '@mui/docs/i18n'; -function pascalCase(str: string) { +export function pascalCase(str: string) { return upperFirst(camelCase(str)); }