Skip to content

Commit 48b5eef

Browse files
authored
[docs-infra] Display "View as Markdown" only on Material UI (#46861)
1 parent fe8ec9e commit 48b5eef

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

packages/mui-docs/src/ComponentLinkHeader/ComponentLinkHeader.tsx

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Chip from '@mui/material/Chip';
44
import Tooltip from '@mui/material/Tooltip';
55
import ChatRounded from '@mui/icons-material/ChatRounded';
66
import GitHubIcon from '@mui/icons-material/GitHub';
7-
import SvgIcon from '@mui/material/SvgIcon';
87
import { styled } from '@mui/material/styles';
98
import { MarkdownHeaders } from '@mui/internal-markdown';
9+
import MarkdownIcon from '../svgIcons/MarkdownIcon';
1010
import SketchIcon from '../svgIcons/SketchIcon';
1111
import FigmaIcon from '../svgIcons/FigmaIcon';
1212
import BundleSizeIcon from '../svgIcons/BundleSizeIcon';
@@ -61,39 +61,24 @@ export function ComponentLinkHeader(props: ComponentLinkHeaderProps) {
6161

6262
return (
6363
<Root>
64-
<li>
65-
<Chip
66-
clickable
67-
role={undefined}
68-
component="a"
69-
size="small"
70-
variant="outlined"
71-
href={`${router.pathname}.md`}
72-
icon={
73-
<SvgIcon>
74-
<svg
75-
width="16"
76-
height="16"
77-
viewBox="0 0 24 24"
78-
fill="none"
79-
xmlns="http://www.w3.org/2000/svg"
80-
aria-hidden="true"
81-
>
82-
<title>Markdown</title>
83-
<path
84-
d="M22.269 19.385H1.731a1.73 1.73 0 0 1-1.73-1.73V6.345a1.73 1.73 0 0 1 1.73-1.73h20.538a1.73 1.73 0 0 1 1.73 1.73v11.308a1.73 1.73 0 0 1-1.73 1.731zm-16.5-3.462v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.461v7.847zM21.231 12h-2.308V8.077h-2.307V12h-2.308l3.461 4.039z"
85-
fill="currentColor"
86-
/>
87-
</svg>
88-
</SvgIcon>
89-
}
90-
data-ga-event-category="ComponentLinkHeader"
91-
data-ga-event-action="click"
92-
data-ga-event-label="Markdown"
93-
data-ga-event-split="0.1"
94-
label="View as Markdown"
95-
/>
96-
</li>
64+
{packageName === '@mui/material' && (
65+
<li>
66+
<Chip
67+
clickable
68+
role={undefined}
69+
component="a"
70+
size="small"
71+
variant="outlined"
72+
href={`${router.pathname}.md`}
73+
icon={<MarkdownIcon />}
74+
data-ga-event-category="ComponentLinkHeader"
75+
data-ga-event-action="click"
76+
data-ga-event-label="Markdown"
77+
data-ga-event-split="0.1"
78+
label="View as Markdown"
79+
/>
80+
</li>
81+
)}
9782
{headers.githubLabel ? (
9883
<li>
9984
<Chip
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from 'react';
2+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
3+
4+
export default function MarkdownIcon(props: SvgIconProps) {
5+
return (
6+
<SvgIcon {...props}>
7+
<svg
8+
width="16"
9+
height="16"
10+
viewBox="0 0 24 24"
11+
fill="none"
12+
xmlns="http://www.w3.org/2000/svg"
13+
aria-hidden="true"
14+
>
15+
<title>Markdown</title>
16+
<path
17+
d="M22.269 19.385H1.731a1.73 1.73 0 0 1-1.73-1.73V6.345a1.73 1.73 0 0 1 1.73-1.73h20.538a1.73 1.73 0 0 1 1.73 1.73v11.308a1.73 1.73 0 0 1-1.73 1.731zm-16.5-3.462v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.461v7.847zM21.231 12h-2.308V8.077h-2.307V12h-2.308l3.461 4.039z"
18+
fill="currentColor"
19+
/>
20+
</svg>
21+
</SvgIcon>
22+
);
23+
}

0 commit comments

Comments
 (0)