Skip to content

Commit dfd2547

Browse files
authored
Merge branch 'main' into feat/flat-tutorial-structure
2 parents 523d749 + 5a2a64f commit dfd2547

File tree

21 files changed

+176
-22
lines changed

21 files changed

+176
-22
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) (2024-11-12)
2+
3+
4+
### Bug Fixes
5+
6+
* hide preview container when `previews: false` ([#412](https://github.com/stackblitz/tutorialkit/issues/412)) ([b35de43](https://github.com/stackblitz/tutorialkit/commit/b35de43d437492d124af232adddd2a30ec70ec0e))
7+
8+
9+
10+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) (2024-11-05)
11+
12+
13+
### Bug Fixes
14+
15+
* **astro:** optimize CJS dependency `picomatch` ([#406](https://github.com/stackblitz/tutorialkit/issues/406)) ([17a48a6](https://github.com/stackblitz/tutorialkit/commit/17a48a6858912277942d87b8af28a601adfad8da))
16+
17+
18+
119
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) (2024-11-05)
220

321

docs/tutorialkit.dev/src/content/docs/guides/creating-content.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,15 @@ const highlighted = 'This line is highlighted';
270270

271271
You can highlight text using strings or regular expressions. For example:
272272

273-
````md
274-
```jsx "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
273+
````md title="content.md"
274+
```jsx title="code.js" "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
275275
console.log(
276276
'Hello, the words yes and yep will be marked. Also add1, add2, remove1, remove2',
277277
)
278278
```
279279
````
280280

281-
```jsx "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
281+
```jsx title="code.js" "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
282282
console.log(
283283
'Hello, the words yes and yep will be marked. Also add1, add2, remove1, remove2',
284284
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
type: lesson
3+
title: Layout change all off
4+
previews: false
5+
terminal: false
6+
editor: false
7+
---
8+
9+
# Navigation test - Layout change all off
10+
11+
This page should not show previw, editor or terminal.

e2e/src/content/tutorial/tests/navigation/meta.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ lessons:
55
- page-one
66
- page-two
77
- page-three
8+
- layout-change-all-off
89
- layout-change-from
910
- layout-change-to
1011
mainCommand: ''

e2e/test/navigation.test.ts

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test as base, expect } from '@playwright/test';
2+
3+
const test = base.extend<{ menu: { navigate: (name: { from: string; to: string }) => Promise<void> } }>({
4+
menu: async ({ page }, use) => {
5+
async function navigate({ from, to }: { from: string; to: string }) {
6+
// navigation select can take a while to hydrate on page load, click until responsive
7+
await expect(async () => {
8+
const button = page.getByRole('button', { name: `Tests / Navigation / ${from}` });
9+
await button.click();
10+
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 });
11+
}).toPass();
12+
13+
await page.getByRole('region', { name: 'Navigation' }).getByRole('link', { name: to }).click();
14+
15+
await expect(page.getByRole('heading', { level: 1, name: `Navigation test - ${to}` })).toBeVisible();
16+
}
17+
18+
await use({ navigate });
19+
},
20+
});
221

322
const BASE_URL = '/tests/navigation';
423

@@ -20,17 +39,10 @@ test('user can navigate between lessons using nav bar links', async ({ page }) =
2039
}
2140
});
2241

23-
test('user can navigate between lessons using breadcrumbs', async ({ page }) => {
42+
test('user can navigate between lessons using breadcrumbs', async ({ page, menu }) => {
2443
await page.goto(`${BASE_URL}/page-one`);
2544

26-
// navigation select can take a while to hydrate on page load, click until responsive
27-
await expect(async () => {
28-
const button = page.getByRole('button', { name: 'Tests / Navigation / Page one' });
29-
await button.click();
30-
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 });
31-
}).toPass();
32-
33-
await page.getByRole('region', { name: 'Navigation' }).getByRole('link', { name: 'Page three' }).click();
45+
await menu.navigate({ from: 'Page one', to: 'Page three' });
3446

3547
await expect(page.getByRole('heading', { level: 1, name: 'Navigation test - Page three' })).toBeVisible();
3648
});
@@ -56,3 +68,26 @@ test("user should see metadata's layout changes after navigation (#318)", async
5668
useInnerText: true,
5769
});
5870
});
71+
72+
test('user should not see preview on lessons that disable it (#405)', async ({ page, menu }) => {
73+
await page.goto(`${BASE_URL}/layout-change-from`);
74+
75+
// first page should have preview visible
76+
await expect(page.getByRole('heading', { level: 1, name: 'Navigation test - Layout change from' })).toBeVisible();
77+
78+
const preview = page.frameLocator('[title="Custom preview"]');
79+
await expect(preview.getByText('Index page')).toBeVisible();
80+
81+
await menu.navigate({ from: 'Layout change from', to: 'Layout change all off' });
82+
83+
// preview should not be visible
84+
await expect(page.locator('iframe[title="Custom preview"]')).not.toBeVisible();
85+
86+
// navigate back and check preview is visible once again
87+
await menu.navigate({ from: 'Layout change all off', to: 'Layout change from' });
88+
89+
{
90+
const preview = page.frameLocator('[title="Custom preview"]');
91+
await expect(preview.getByText('Index page')).toBeVisible();
92+
}
93+
});

packages/astro/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/astro" (2024-11-12)
2+
3+
4+
### Bug Fixes
5+
6+
* hide preview container when `previews: false` ([#412](https://github.com/stackblitz/tutorialkit/issues/412)) ([b35de43](https://github.com/stackblitz/tutorialkit/commit/b35de43d437492d124af232adddd2a30ec70ec0e))
7+
8+
9+
10+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/astro" (2024-11-05)
11+
12+
13+
### Bug Fixes
14+
15+
* **astro:** optimize CJS dependency `picomatch` ([#406](https://github.com/stackblitz/tutorialkit/issues/406)) ([17a48a6](https://github.com/stackblitz/tutorialkit/commit/17a48a6858912277942d87b8af28a601adfad8da))
16+
17+
18+
119
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/astro" (2024-11-05)
220

321

packages/astro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/astro",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "TutorialKit integration for Astro (https://astro.build)",
55
"author": "StackBlitz Inc.",
66
"type": "module",

packages/astro/src/default/pages/[...slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ meta.description ??= 'A TutorialKit interactive lesson';
2424

2525
<Layout title={title} meta={meta}>
2626
<PageLoadingIndicator />
27-
<div id="previews-container"></div>
27+
<div id="previews-container" style="display: none;"></div>
2828
<main class="max-w-full flex flex-col h-full overflow-hidden" data-swap-root>
2929
<TopBarWrapper logoLink={logoLink ?? '/'} openInStackBlitz={lesson.data.openInStackBlitz} />
3030
<MainContainer lesson={lesson} navList={navList} />

packages/astro/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,18 @@ export default function createPlugin({
8787
vite: {
8888
optimizeDeps: {
8989
entries: ['!**/src/(content|templates)/**'],
90-
include: process.env.TUTORIALKIT_DEV ? [] : ['@tutorialkit/react'],
90+
include: process.env.TUTORIALKIT_DEV
91+
? []
92+
: [
93+
'@tutorialkit/react',
94+
95+
/**
96+
* The `picomatch` is CJS dependency used by `@tutorialkit/runtime`.
97+
* When used via `@tutorialkit/astro`, it's a transitive dependency that's
98+
* not automatically transformed.
99+
*/
100+
'@tutorialkit/astro > picomatch/posix.js',
101+
],
91102
},
92103
define: {
93104
__ENTERPRISE__: `${!!enterprise}`,

packages/cli/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/cli" (2024-11-12)
2+
3+
4+
5+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/cli" (2024-11-05)
6+
7+
8+
19
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/cli" (2024-11-05)
210

311

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/cli",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "Interactive tutorials powered by WebContainer API",
55
"author": "StackBlitz Inc.",
66
"type": "module",

packages/create-tutorial/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [0.0.3](https://github.com/stackblitz/tutorialkit/compare/1.2.1...0.0.3) "create-tutorial" (2024-11-12)
2+
3+
4+
5+
## [0.0.3](https://github.com/stackblitz/tutorialkit/compare/1.2.0...0.0.3) "create-tutorial" (2024-11-05)
6+
7+
8+
19
## [0.0.3](https://github.com/stackblitz/tutorialkit/compare/1.1.1...0.0.3) "create-tutorial" (2024-11-05)
210

311

packages/react/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/react" (2024-11-12)
2+
3+
4+
### Bug Fixes
5+
6+
* hide preview container when `previews: false` ([#412](https://github.com/stackblitz/tutorialkit/issues/412)) ([b35de43](https://github.com/stackblitz/tutorialkit/commit/b35de43d437492d124af232adddd2a30ec70ec0e))
7+
8+
9+
10+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/react" (2024-11-05)
11+
12+
13+
114
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/react" (2024-11-05)
215

316

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/react",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "TutorialKit's React components and utilities",
55
"author": "StackBlitz Inc.",
66
"type": "module",

packages/react/src/Panels/PreviewPanel.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ export const PreviewPanel = memo(
6262
useEffect(() => {
6363
// we update the iframes position at max fps if we have any
6464
if (hasPreviews) {
65-
return requestAnimationFrameLoop(onResize);
65+
const cancel = requestAnimationFrameLoop(onResize);
66+
67+
previewsContainer.style.display = 'block';
68+
69+
return () => {
70+
previewsContainer.style.display = 'none';
71+
cancel();
72+
};
6673
}
6774

6875
return undefined;

packages/runtime/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/runtime" (2024-11-12)
2+
3+
4+
5+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/runtime" (2024-11-05)
6+
7+
8+
19
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/runtime" (2024-11-05)
210

311

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/runtime",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "TutorialKit runtime",
55
"author": "StackBlitz Inc.",
66
"type": "module",

packages/theme/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/theme" (2024-11-12)
2+
3+
4+
5+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/theme" (2024-11-05)
6+
7+
8+
19
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/theme" (2024-11-05)
210

311

packages/theme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/theme",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "TutorialKit theme configuration",
55
"author": "StackBlitz Inc.",
66
"type": "module",

packages/types/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.2.2](https://github.com/stackblitz/tutorialkit/compare/1.2.1...1.2.2) "@tutorialkit/types" (2024-11-12)
2+
3+
4+
5+
## [1.2.1](https://github.com/stackblitz/tutorialkit/compare/1.2.0...1.2.1) "@tutorialkit/types" (2024-11-05)
6+
7+
8+
19
# [1.2.0](https://github.com/stackblitz/tutorialkit/compare/1.1.1...1.2.0) "@tutorialkit/types" (2024-11-05)
210

311

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/types",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "Types for TutorialKit",
55
"author": "StackBlitz Inc.",
66
"type": "module",

0 commit comments

Comments
 (0)