-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathDemoContentLoading.tsx
More file actions
54 lines (49 loc) · 1.5 KB
/
DemoContentLoading.tsx
File metadata and controls
54 lines (49 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use client';
import * as React from 'react';
import type { ContentLoadingProps } from '@mui/internal-docs-infra/CodeHighlighter/types';
import { Tabs } from '@/components/Tabs';
import styles from '../DemoContent.module.css';
import '../syntax.css';
export function DemoContentLoading(props: ContentLoadingProps<object>) {
const tabs = React.useMemo(
() =>
props.fileNames?.map((name) => ({
id: name || '',
name: name || '',
slug: name,
})),
[props.fileNames],
);
const onTabSelect = React.useCallback(() => {
// No-op
}, []);
return (
<div>
{Object.keys(props.extraSource || {}).map((slug) => (
<span key={slug} id={slug} className={styles.fileRefs} />
))}
<div className={styles.container}>
<div className={styles.demoSection}>{props.component}</div>
<div className={styles.codeSection}>
<div className={styles.header}>
<div className={styles.headerContainer}>
{tabs && (
<div className={styles.tabContainer}>
<Tabs
tabs={tabs}
selectedTabId={props.fileNames?.[0]}
onTabSelect={onTabSelect}
disabled={true}
/>
</div>
)}
</div>
</div>
<div className={styles.code}>
<pre className={styles.codeBlock}>{props.source}</pre>
</div>
</div>
</div>
</div>
);
}