Skip to content

Commit 4f8b407

Browse files
committed
feat(nx-dev): add course preview component
1 parent 5dcec84 commit 4f8b407

File tree

7 files changed

+91
-11
lines changed

7 files changed

+91
-11
lines changed

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ Have a more decent button-like widget that you can place below sections of a tut
299299
{% video-link link="https://youtu.be/OQ-Zc5tcxJE?t=64" /%}
300300
```
301301

302+
#### Course video embed
303+
304+
This is for embedding a video just like with the Youtube component, but in addition to have a link to a Nx Course (nx.dev/courses) video to improve the discoverability of these courses.
305+
306+
```markdown
307+
{% course-video src="https://youtu.be/3hW53b1IJ84" courseTitle="From PNPM Workspaces to Distributed CI" courseUrl="/courses/pnpm-nx-next/lessons-01-nx-init" title="Initialize Nx in Your Project with nx init" /%}
308+
```
309+
302310
#### Project Details View
303311

304312
Embed a Project Details View that is identical what is shown in Nx Console or `nx show project myproject --web`

docs/shared/migration/adding-to-monorepo.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ an existing NPM/Yarn or PNPM-based monorepo setup, you can easily add Nx to get
2121
This is a low-impact operation because all that needs to be done is to install the `nx` package at the root level and
2222
add an `nx.json` for configuring caching and task pipelines.
2323

24-
{% youtube
25-
src="https://www.youtube.com/embed/ngdoUQBvAjo"
26-
title="Add Nx to a PNPM workspaces monorepo"
27-
width="100%" /%}
24+
{% course-video src="https://youtu.be/3hW53b1IJ84" courseTitle="From PNPM Workspaces to Distributed CI" courseUrl="/courses/pnpm-nx-next/lessons-01-nx-init" title="Initialize Nx in Your Project with nx init" /%}
2825

2926
## Installing Nx
3027

nx-dev/nx-dev/styles/main.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,24 @@ pre,
5252
iframe[src*='youtube'] {
5353
aspect-ratio: 16 / 9;
5454
}
55-
.prose iframe,
56-
.prose img {
55+
56+
.prose iframe:not(.not-prose):not(.not-prose *),
57+
.prose img:not(.not-prose):not(.not-prose *) {
5758
display: block;
5859
margin: 2rem auto;
5960
}
60-
.prose iframe {
61+
62+
.prose iframe:not(.not-prose):not(.not-prose *) {
6163
width: 100%;
6264
max-width: 560px;
6365
}
64-
.prose img {
66+
67+
.prose img:not(.not-prose):not(.not-prose *) {
6568
width: max-content;
6669
}
6770

68-
.prose iframe[src^="https://staging.nx.app"],
69-
.prose iframe[src^="https://nx.app"]
71+
.prose iframe:not(.not-prose):not(.not-prose *)[src^="https://staging.nx.app"],
72+
.prose iframe:not(.not-prose):not(.not-prose *)[src^="https://nx.app"]
7073
{
7174
height: 80vh;
7275
max-width: 100%;

nx-dev/ui-common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * from './lib/tweet';
1717
export * from './lib/typography';
1818
export * from './lib/github-star-widget';
1919
export * from './lib/youtube.component';
20+
export * from './lib/course-video';
2021
export * from './lib/x-icon';
2122
export * from './lib/discord-icon';
2223
export * from './lib/trusted-by';
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { ButtonLink } from './button';
2+
import { YouTube } from './youtube.component';
3+
4+
export interface CourseVideoProps {
5+
/**
6+
* The YouTube video URL
7+
*/
8+
src: string;
9+
courseTitle: string;
10+
courseUrl: string;
11+
}
12+
13+
export function CourseVideo({
14+
src: videoUrl,
15+
courseTitle,
16+
courseUrl,
17+
}: CourseVideoProps): JSX.Element {
18+
return (
19+
<div className="not-prose mx-auto max-w-4xl">
20+
<div className="overflow-hidden rounded-xl bg-slate-50 shadow-sm ring-1 ring-slate-900/5 dark:bg-slate-800/50 dark:ring-slate-700/50">
21+
<div className="aspect-video w-full">
22+
<YouTube
23+
src={videoUrl}
24+
title={courseTitle}
25+
width="100%"
26+
disableRoundedCorners={true}
27+
/>
28+
</div>
29+
<div className="px-6 py-4">
30+
<div className="flex flex-col items-center gap-3 sm:flex-row sm:items-center sm:justify-between">
31+
<h3 className="text-center text-xl font-medium text-slate-900 sm:text-left dark:text-white">
32+
{courseTitle}
33+
</h3>
34+
<ButtonLink
35+
href={courseUrl}
36+
variant="primary"
37+
size="small"
38+
title={`Watch the full "${courseTitle}" course`}
39+
className="whitespace-nowrap"
40+
>
41+
Watch full course
42+
</ButtonLink>
43+
</div>
44+
</div>
45+
</div>
46+
</div>
47+
);
48+
}

nx-dev/ui-markdoc/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import { Tab, Tabs } from './lib/tags/tabs.component';
3939
import { tab, tabs } from './lib/tags/tabs.schema';
4040
import { Tweet, tweet } from '@nx/nx-dev/ui-common';
4141
import { YouTube, youtube } from '@nx/nx-dev/ui-common';
42+
import { CourseVideo } from '@nx/nx-dev/ui-common';
43+
import { courseVideo } from './lib/tags/course-video.schema';
4244
import { VideoLink, videoLink } from './lib/tags/video-link.component';
4345
// import { SvgAnimation, svgAnimation } from './lib/tags/svg-animation.component';
4446
import { Pill } from './lib/tags/pill.component';
@@ -91,6 +93,7 @@ export const getMarkdocCustomConfig = (
9193
toc: tableOfContents,
9294
tweet,
9395
youtube,
96+
'course-video': courseVideo,
9497
'video-link': videoLink,
9598
metrics,
9699
// 'svg-animation': svgAnimation,
@@ -123,6 +126,7 @@ export const getMarkdocCustomConfig = (
123126
Testimonial,
124127
Tweet,
125128
YouTube,
129+
CourseVideo,
126130
VideoLink,
127131
VideoPlayer,
128132
Metrics,
@@ -176,4 +180,4 @@ export const renderMarkdown: (
176180
};
177181
};
178182

179-
export { Metrics, VideoLink, GithubRepository };
183+
export { Metrics, VideoLink, GithubRepository, CourseVideo };
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Schema } from '@markdoc/markdoc';
2+
3+
export const courseVideo: Schema = {
4+
render: 'CourseVideo',
5+
attributes: {
6+
src: {
7+
type: 'String',
8+
required: true,
9+
},
10+
courseTitle: {
11+
type: 'String',
12+
required: true,
13+
},
14+
courseUrl: {
15+
type: 'String',
16+
required: true,
17+
},
18+
},
19+
};

0 commit comments

Comments
 (0)