Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3231822

Browse files
committed
Wrap details tag around embeds
1 parent c2c6a7b commit 3231822

File tree

1 file changed

+70
-26
lines changed

1 file changed

+70
-26
lines changed

src/components/Markdown.tsx

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,51 @@ import { CodePen, Gist, Tweet, YouTube, CodeSandbox } from 'mdx-embed'
66
function Repl({ id }: { id: string }) {
77
return (
88
<>
9-
<iframe
10-
title={`repl-${id}`}
11-
height="400px"
12-
width="100%"
13-
src={`https://repl.it/${id}?lite=true`}
14-
scrolling="no"
15-
frameBorder="no"
16-
allowFullScreen={true}
17-
sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"
18-
/>
9+
<details>
10+
<summary>Show Repl</summary>
11+
<iframe
12+
title={`repl-${id}`}
13+
height="400px"
14+
width="100%"
15+
src={`https://repl.it/${id}?lite=true`}
16+
scrolling="no"
17+
frameBorder="no"
18+
allowFullScreen={true}
19+
sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"
20+
/>
21+
</details>
1922
</>
2023
)
2124
}
2225

2326
function Glitch({ id }: { id: string }) {
2427
return (
25-
<div
26-
className="glitch-embed-wrap"
27-
style={{ height: '420px', width: '100%' }}
28-
>
29-
<iframe
30-
src={`https://glitch.com/embed/#!/embed/${id}`}
31-
title="probable-stellar-gull on Glitch"
32-
allow="geolocation; microphone; camera; midi; vr; encrypted-media"
33-
style={{ height: '100%', width: '100%', border: 0 }}
34-
></iframe>
35-
</div>
28+
<details>
29+
<summary>Show Glitch</summary>
30+
<div
31+
className="glitch-embed-wrap"
32+
style={{ height: '420px', width: '100%' }}
33+
>
34+
<iframe
35+
src={`https://glitch.com/embed/#!/embed/${id}`}
36+
title="probable-stellar-gull on Glitch"
37+
allow="geolocation; microphone; camera; midi; vr; encrypted-media"
38+
style={{ height: '100%', width: '100%', border: 0 }}
39+
></iframe>
40+
</div>
41+
</details>
42+
)
43+
}
44+
45+
function Video({ id }: { id: string }) {
46+
return (
47+
<details>
48+
<summary>Show Video</summary>
49+
<video controls>
50+
<source src={id} type="video/mp4" />
51+
Your browser does not support the video tag.
52+
</video>
53+
</details>
3654
)
3755
}
3856

@@ -56,22 +74,48 @@ export default function Markdown(props: {
5674
component: Pre,
5775
},
5876
CodePen: {
59-
component: ({ id }: { id: string }) => <CodePen codePenId={id} />,
77+
component: ({ id }: { id: string }) => (
78+
<details>
79+
<summary>Show CodePen</summary>
80+
<CodePen codePenId={id} />
81+
</details>
82+
),
6083
},
6184
Gist: {
62-
component: ({ id }: { id: string }) => <Gist gistLink={id} />,
85+
component: ({ id }: { id: string }) => (
86+
<details>
87+
<summary>Show GitHub Gist</summary>
88+
<Gist gistLink={id} />
89+
</details>
90+
),
6391
},
6492
Tweet: {
65-
component: ({ id }: { id: string }) => <Tweet tweetLink={id} />,
93+
component: ({ id }: { id: string }) => (
94+
<details>
95+
<summary>Show Tweet</summary>
96+
<Tweet tweetLink={id} />
97+
</details>
98+
),
6699
},
67100
YouTube: {
68-
component: ({ id }: { id: string }) => <YouTube youTubeId={id} />,
101+
component: ({ id }: { id: string }) => (
102+
<details>
103+
<summary>Show YouTube video</summary>
104+
<YouTube youTubeId={id} />
105+
</details>
106+
),
69107
},
70108
CodeSandbox: {
71109
component: ({ id }: { id: string }) => (
72-
<CodeSandbox codeSandboxId={id} />
110+
<details>
111+
<summary>Show CodeSandbox</summary>
112+
<CodeSandbox codeSandboxId={id} />
113+
</details>
73114
),
74115
},
116+
Video: {
117+
component: Video,
118+
},
75119
Repl: {
76120
component: Repl,
77121
},

0 commit comments

Comments
 (0)