Skip to content

Commit 95fd6b5

Browse files
[docs] Fix Live edit copies (#43835)
1 parent e74c659 commit 95fd6b5

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

docs/src/modules/components/TemplateFrame.js

+16-23
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ import PaletteIcon from '@mui/icons-material/PaletteOutlined';
2424
import codeSandbox from 'docs/src/modules/sandbox/CodeSandbox';
2525
import stackBlitz from 'docs/src/modules/sandbox/StackBlitz';
2626
import sourceMaterialTemplates from 'docs/src/modules/material/sourceMaterialTemplates';
27-
28-
function pascalCase(str) {
29-
return str
30-
.replace(/[^\w]+(.)/g, (_, chr) => chr.toUpperCase())
31-
.replace(/^(.)/, (_, chr) => chr.toUpperCase());
32-
}
27+
import { pascalCase } from 'docs/src/modules/utils/helpers';
3328

3429
const StyledAppBar = styled(AppBar)(({ theme }) => ({
3530
position: 'relative',
@@ -196,7 +191,7 @@ const brandingTheme = createTheme({
196191
...getThemedComponents(),
197192
});
198193

199-
function TemplateFrame({ children }) {
194+
export default function TemplateFrame({ children }) {
200195
const router = useRouter();
201196
const templateId = router.pathname.split('/').pop();
202197
const templateName = pascalCase(templateId);
@@ -262,17 +257,17 @@ function TemplateFrame({ children }) {
262257
'& > *': { flexShrink: 0 },
263258
}}
264259
>
265-
<Tooltip title="Open Template via CodeSandbox">
260+
<Tooltip title="Edit in StackBlitz">
266261
<IconButton
267262
color="primary"
268263
size="small"
269264
disableTouchRipple
270-
aria-label="CodeSandbox playground"
265+
aria-label="StackBlitz playground"
271266
data-ga-event-category="material-ui-template"
272267
data-ga-event-label={templateId}
273-
data-ga-event-action="codesandbox"
268+
data-ga-event-action="stackblitz"
274269
onClick={() =>
275-
codeSandbox
270+
stackBlitz
276271
.createMaterialTemplate({
277272
...item,
278273
files: { ...item.files, ...materialTemplates.sharedTheme?.files },
@@ -291,26 +286,26 @@ function TemplateFrame({ children }) {
291286
}
292287
return content;
293288
})
294-
.openSandbox(`/${templateName}`)
289+
.openStackBlitz(`/${templateName}`)
295290
}
296291
sx={{ alignSelf: 'center', borderRadius: 1 }}
297292
>
298-
<SvgIcon viewBox="0 0 1080 1080">
299-
<path d="M755 140.3l0.5-0.3h0.3L512 0 268.3 140h-0.3l0.8 0.4L68.6 256v512L512 1024l443.4-256V256L755 140.3z m-30 506.4v171.2L548 920.1V534.7L883.4 341v215.7l-158.4 90z m-584.4-90.6V340.8L476 534.4v385.7L300 818.5V646.7l-159.4-90.6zM511.7 280l171.1-98.3 166.3 96-336.9 194.5-337-194.6 165.7-95.7L511.7 280z" />
293+
<SvgIcon viewBox="0 0 19 28">
294+
<path d="M8.13378 16.1087H0L14.8696 0L10.8662 11.1522L19 11.1522L4.13043 27.2609L8.13378 16.1087Z" />
300295
</SvgIcon>
301296
</IconButton>
302297
</Tooltip>
303-
<Tooltip title="Open Template via StackBlitz">
298+
<Tooltip title="Edit in CodeSandbox">
304299
<IconButton
305300
color="primary"
306301
size="small"
307302
disableTouchRipple
308-
aria-label="StackBlitz playground"
303+
aria-label="CodeSandbox playground"
309304
data-ga-event-category="material-ui-template"
310305
data-ga-event-label={templateId}
311-
data-ga-event-action="stackblitz"
306+
data-ga-event-action="codesandbox"
312307
onClick={() =>
313-
stackBlitz
308+
codeSandbox
314309
.createMaterialTemplate({
315310
...item,
316311
files: { ...item.files, ...materialTemplates.sharedTheme?.files },
@@ -329,12 +324,12 @@ function TemplateFrame({ children }) {
329324
}
330325
return content;
331326
})
332-
.openStackBlitz(`/${templateName}`)
327+
.openSandbox(`/${templateName}`)
333328
}
334329
sx={{ alignSelf: 'center', borderRadius: 1 }}
335330
>
336-
<SvgIcon viewBox="0 0 19 28">
337-
<path d="M8.13378 16.1087H0L14.8696 0L10.8662 11.1522L19 11.1522L4.13043 27.2609L8.13378 16.1087Z" />
331+
<SvgIcon viewBox="0 0 1080 1080">
332+
<path d="M755 140.3l0.5-0.3h0.3L512 0 268.3 140h-0.3l0.8 0.4L68.6 256v512L512 1024l443.4-256V256L755 140.3z m-30 506.4v171.2L548 920.1V534.7L883.4 341v215.7l-158.4 90z m-584.4-90.6V340.8L476 534.4v385.7L300 818.5V646.7l-159.4-90.6zM511.7 280l171.1-98.3 166.3 96-336.9 194.5-337-194.6 165.7-95.7L511.7 280z" />
338333
</SvgIcon>
339334
</IconButton>
340335
</Tooltip>
@@ -358,5 +353,3 @@ function TemplateFrame({ children }) {
358353
</ThemeProvider>
359354
);
360355
}
361-
362-
export default TemplateFrame;

docs/src/modules/utils/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import camelCase from 'lodash/camelCase';
33
import { LANGUAGES } from 'docs/config';
44
import { Translate } from '@mui/docs/i18n';
55

6-
function pascalCase(str: string) {
6+
export function pascalCase(str: string) {
77
return upperFirst(camelCase(str));
88
}
99

0 commit comments

Comments
 (0)