Skip to content

Commit 7d67350

Browse files
committed
Styles
1 parent 03cfbec commit 7d67350

File tree

6 files changed

+104
-16
lines changed

6 files changed

+104
-16
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ todo.md
44
dist
55
yarn-error.log
66
site/out
7-
xmdx/public/000.mp4
8-
xmdx/public/001.mp4
7+
xmdx/public/*.mp4

xmdx/demo/cake.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Video src="001.mp4" start={0} end={40} />
1+
<Video src="r000.mp4" start={0} end={40} />
22
<Browser url="/01" zoom={0.8} />
33
<Editor
44
code="hello.md"
@@ -7,6 +7,15 @@
77
tabs={["demo/hello.md", "pages/hello.js"]}
88
/>
99

10+
```srt
11+
0.5 –> 4.5
12+
Let's start with markdown file
13+
I'm assuming we all know markdown
14+
4.5 –> 10.5
15+
there's a reason why it's so popular,
16+
the syntax is so clean
17+
```
18+
1019
---
1120

1221
<Video src="001.mp4" start={40} end={56} />

xmdx/pages/content.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ And the next step.
138138

139139
---
140140

141-
Ok, that's all. I leave you here the links to the repo of the talk. Not the slides, but the talk itself. You run yarn dev and you can watch this talk again.
141+
Ok, that's all. The talk's takeaway is: you can use MDX to build your own dialect tailored for any specific layuout.
142+
143+
I leave you here the links to the repo of the talk. Not the slides, but the talk itself. You run yarn dev and you can watch this talk again.
142144

143145
Also there's my twitter, and the components we used, most of them come from a new project I'm working on, it's called Code Hike and it focuses on code walkthroughs and tools for making it easy to explain code.
144146

xmdx/pages/index.js

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useSpring } from "use-spring"
88
import { sim } from "@code-hike/sim-user"
99
import { MDXProvider } from "@mdx-js/react"
1010
import Content from "../demo/cake.mdx"
11+
import Head from "next/head"
1112

1213
const components = {
1314
wrapper: Wrapper,
@@ -60,7 +61,20 @@ function getStepsFromMDX(children) {
6061
}
6162
})
6263

63-
console.log({ editorSteps })
64+
const captionSteps = splits.map(split => {
65+
const pre = split.find(
66+
child =>
67+
child.props.mdxType === "pre" &&
68+
child.props.children.props.className ===
69+
"language-srt"
70+
)
71+
if (!pre) return []
72+
73+
return parseSrt(pre.props.children.props.children)
74+
})
75+
76+
console.log(splits[0])
77+
console.log(captionSteps)
6478

6579
return {
6680
videoSteps,
@@ -69,9 +83,19 @@ function getStepsFromMDX(children) {
6983
}
7084
}
7185

86+
function parseSrt(srt) {
87+
const regex = /^[\d\.\:]+\s+[\-]>\s+[\d\.\:]+$/gm
88+
const times = srt.match(regex)
89+
const [, ...texts] = srt.split(regex)
90+
return times.map((time, i) => ({ time, text: texts[i] }))
91+
}
92+
7293
export default function Page() {
7394
return (
7495
<MDXProvider components={components}>
96+
<Head>
97+
<title>The X in MDX</title>
98+
</Head>
7599
<Content />
76100
</MDXProvider>
77101
)
@@ -169,13 +193,18 @@ function Talk({ videoSteps, browserSteps, editorSteps }) {
169193
ref={browserRef}
170194
/>
171195
</div>
196+
<div className={s.div4}>
197+
<pre className={s.captions}>
198+
there's a reason why it's so popular, <br />
199+
the syntax is so clean
200+
</pre>
201+
</div>
172202
<div className={s.div3}>
173203
<div className={s.video}>
174204
<div
175205
style={{
176206
height: "100%",
177207
float: "right",
178-
marginRight: -30,
179208
}}
180209
>
181210
<Video
@@ -186,7 +215,6 @@ function Talk({ videoSteps, browserSteps, editorSteps }) {
186215
style={{
187216
height: "100%",
188217
}}
189-
muted
190218
onStepChange={changeStep}
191219
onTimeChange={onTimeChange}
192220
ref={playerRef}
@@ -202,9 +230,15 @@ function Talk({ videoSteps, browserSteps, editorSteps }) {
202230
}}
203231
>
204232
<div>
205-
<span style={{ fontSize: "1.2em" }}>
233+
<a
234+
style={{
235+
fontSize: "1.2em",
236+
color: "#F19A38",
237+
}}
238+
href="https://twitter.com/pomber"
239+
>
206240
@pomber
207-
</span>
241+
</a>
208242
<div style={{ height: 5 }} />
209243
<span style={{ fontSize: "1.8em" }}>
210244
Rodrigo
@@ -214,9 +248,23 @@ function Talk({ videoSteps, browserSteps, editorSteps }) {
214248
Pombo
215249
</span>
216250
<div style={{ height: 10 }} />
217-
<span style={{ fontSize: "1.3em" }}>
218-
FOO CONF
219-
</span>
251+
<a
252+
style={{ fontSize: "1.3em", margin: 0 }}
253+
href="https://mdxjs.com/conf/"
254+
>
255+
<span
256+
children="<"
257+
style={{
258+
color: "#F19A38",
259+
fontSize: "1.2em",
260+
}}
261+
/>
262+
MDXConf
263+
<span
264+
children=" />"
265+
style={{ color: "#F19A38" }}
266+
/>
267+
</a>
220268
</div>
221269
</div>
222270
</div>

xmdx/pages/index.module.css

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
display: grid;
1919
height: 100%;
2020
grid-template-columns: repeat(7, 1fr);
21-
grid-template-rows: repeat(6, 1fr);
21+
grid-template-rows: repeat(7, 1fr);
2222
grid-column-gap: 16px;
2323
grid-row-gap: 16px;
2424
padding: 16px;
2525
box-sizing: border-box;
2626
}
2727

2828
.div1 {
29-
grid-area: 1 / 1 / 7 / 5;
29+
grid-area: 1 / 1 / 8 / 5;
3030
}
3131
.div2 {
3232
grid-area: 1 / 5 / 5 / 8;
@@ -35,6 +35,27 @@
3535
grid-area: 5 / 5 / 7 / 8;
3636
}
3737

38+
.div4 {
39+
grid-area: 7 / 5 / 8 / 8;
40+
}
41+
42+
.captions {
43+
color: #ddd;
44+
background-color: #222;
45+
border-radius: 6px;
46+
height: 100%;
47+
display: flex;
48+
align-items: center;
49+
justify-content: center;
50+
text-align: center;
51+
font-family: Ubuntu, Droid Sans, -apple-system,
52+
BlinkMacSystemFont, Segoe WPC, Segoe UI, sans-serif;
53+
box-shadow: 0 6px 12px -2px rgba(50, 50, 93, 0.25),
54+
0 3px 7px -3px rgba(0, 0, 0, 0.3);
55+
padding: 0 16px;
56+
margin: 0;
57+
}
58+
3859
.author {
3960
width: 100%;
4061
height: 100%;
@@ -58,16 +79,25 @@
5879
position: absolute;
5980
display: flex;
6081
align-items: center;
61-
text-align: right;
82+
text-align: center;
6283
font-size: 0.8em;
6384
color: #bbb;
6485
background: linear-gradient(
6586
to right,
66-
#222 34%,
87+
#222 38%,
6788
transparent 75%
6889
);
6990
color: #ddd;
7091
padding: 32px;
7192
font-family: Ubuntu, Droid Sans, -apple-system,
7293
BlinkMacSystemFont, Segoe WPC, Segoe UI, sans-serif;
7394
}
95+
96+
.details a {
97+
text-decoration: none;
98+
color: inherit;
99+
}
100+
101+
.details a:hover {
102+
text-decoration: underline;
103+
}

xmdx/public/favicon.ico

15 KB
Binary file not shown.

0 commit comments

Comments
 (0)