playwright-director 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -10
- package/dist/Tutorial.d.ts.map +1 -1
- package/dist/Tutorial.js +1 -1
- package/dist/Tutorial.js.map +1 -1
- package/dist/init.js +11 -1
- package/dist/init.js.map +1 -1
- package/dist/site/build-site.d.ts +6 -0
- package/dist/site/build-site.d.ts.map +1 -1
- package/dist/site/build-site.js +13 -2
- package/dist/site/build-site.js.map +1 -1
- package/dist/site/embed.d.ts +9 -0
- package/dist/site/embed.d.ts.map +1 -1
- package/dist/site/embed.js +7 -3
- package/dist/site/embed.js.map +1 -1
- package/dist/site/generate-manifest.d.ts +2 -0
- package/dist/site/generate-manifest.d.ts.map +1 -1
- package/dist/site/generate-manifest.js +57 -16
- package/dist/site/generate-manifest.js.map +1 -1
- package/dist/site/scaffold.d.ts +6 -0
- package/dist/site/scaffold.d.ts.map +1 -1
- package/dist/site/scaffold.js +54 -8
- package/dist/site/scaffold.js.map +1 -1
- package/dist/site/scan-tutorials.d.ts +2 -0
- package/dist/site/scan-tutorials.d.ts.map +1 -1
- package/dist/site/scan-tutorials.js +3 -1
- package/dist/site/scan-tutorials.js.map +1 -1
- package/dist/site/seo.d.ts +22 -0
- package/dist/site/seo.d.ts.map +1 -0
- package/dist/site/seo.js +91 -0
- package/dist/site/seo.js.map +1 -0
- package/dist/site/strings.d.ts +19 -0
- package/dist/site/strings.d.ts.map +1 -1
- package/dist/site/strings.js +57 -3
- package/dist/site/strings.js.map +1 -1
- package/dist/site/tokens.d.ts +28 -0
- package/dist/site/tokens.d.ts.map +1 -0
- package/dist/site/tokens.js +38 -0
- package/dist/site/tokens.js.map +1 -0
- package/dist/site/types.d.ts +57 -12
- package/dist/site/types.d.ts.map +1 -1
- package/dist/timeline.d.ts +7 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +5 -1
- package/dist/timeline.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/embed-v1.schema.json +5 -0
- package/skills/tutorialize/SKILL.md +7 -2
- package/skills/tutorialize/agent.md +4 -0
- package/skills/tutorialize/references/api.md +1 -0
- package/skills/tutorialize/references/site.md +158 -0
- package/templates/site/public/widget.js +16 -11
- package/templates/site/src/components/Emphasis.astro +8 -0
- package/templates/site/src/components/HomeLangs.astro +20 -0
- package/templates/site/src/components/LangSwitch.astro +20 -0
- package/templates/site/src/components/Lightbox.astro +50 -0
- package/templates/site/src/components/PrevNext.astro +40 -0
- package/templates/site/src/components/Seo.astro +42 -0
- package/templates/site/src/components/StepGuide.astro +115 -0
- package/templates/site/src/components/StepStrip.astro +33 -0
- package/templates/site/src/components/ThemeSwitcher.astro +22 -0
- package/templates/site/src/components/VariantFilter.astro +36 -0
- package/templates/site/src/components/VideoCard.astro +1 -103
- package/templates/site/src/components/VideoLinks.astro +19 -0
- package/templates/site/src/components/VideoModal.astro +66 -153
- package/templates/site/src/components/VideoPlayer.astro +43 -0
- package/templates/site/src/i18n.ts +8 -3
- package/templates/site/src/layouts/Shell.astro +46 -0
- package/templates/site/src/lib/filter.ts +24 -0
- package/templates/site/src/lib/site.ts +127 -0
- package/templates/site/src/pages/[lang]/index.astro +6 -6
- package/templates/site/src/pages/[slug].astro +5 -850
- package/templates/site/src/pages/index.astro +2 -2
- package/templates/site/src/styles/components.css +919 -0
- package/templates/site/src/styles/user.css +1 -0
- package/templates/themes/academy/CourseNav.astro +56 -0
- package/templates/themes/academy/Home.astro +139 -0
- package/templates/themes/academy/Layout.astro +48 -0
- package/templates/themes/academy/VideoPage.astro +75 -0
- package/templates/themes/academy/theme.css +979 -0
- package/templates/themes/classic/Home.astro +58 -0
- package/templates/themes/classic/Layout.astro +46 -0
- package/templates/themes/classic/VideoPage.astro +47 -0
- package/templates/themes/classic/theme.css +289 -0
- package/templates/site/src/components/TutorialsHome.astro +0 -169
- package/templates/site/src/layouts/Base.astro +0 -61
- package/templates/site/src/styles/tutorials.css +0 -303
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Site Reference — the tutorial gallery (`build-site`)
|
|
2
|
+
|
|
3
|
+
`npx playwright-director build-site` turns the recordings (videos, timelines, step screenshots) into a
|
|
4
|
+
static Astro site: a home page per language, one page per video, SEO files, and the in-app widget data.
|
|
5
|
+
Config: `tutorial-site.config.js` at the project root (`--config=` for another path).
|
|
6
|
+
|
|
7
|
+
Read this before you edit a site config, add a theme override, or wire tutorials to the app and docs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Minimal config
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
/** @type {import('playwright-director/site').SiteConfig} */
|
|
15
|
+
export default {
|
|
16
|
+
title: 'My App — Help',
|
|
17
|
+
input: 'tutorials/', // videos in <input>/videos, timelines in <input>/output
|
|
18
|
+
output: 'tutorial-site-dist/',
|
|
19
|
+
baseUrl: 'https://help.myapp.com/', // full URL = SEO on; a path ('/help/') = no absolute URLs
|
|
20
|
+
lang: 'fr,en,ar' // first = default language, served at /; the others at /<lang>/
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`baseUrl` must be a **full URL** to get canonical, hreflang, og:*, VideoObject JSON-LD, `sitemap.xml`,
|
|
25
|
+
`robots.txt` (host root only) and `links.json`. A bare path only sets the base path.
|
|
26
|
+
|
|
27
|
+
## 2. All options
|
|
28
|
+
|
|
29
|
+
| Option | Default | What it does |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `title` | *required* | Header + `<title>` |
|
|
32
|
+
| `logo` | — | Image path, copied to the site |
|
|
33
|
+
| `theme` | `'academy'` | `'academy'` (editorial: hero, sections, course sidebar) or `'classic'` (card carousel) |
|
|
34
|
+
| `tokens` | theme values | Design tokens → CSS variables (§4). Unknown names fail the build |
|
|
35
|
+
| `googleFonts` | theme fonts | `['Manrope:wght@400;600']`; `false` = load none |
|
|
36
|
+
| `css` | — | Extra stylesheet, loaded after the theme |
|
|
37
|
+
| `overrides` | — | Folder copied over the site `src/` — replaces any page, component or theme file (§4) |
|
|
38
|
+
| `appUrl` | — | App origin: resolves `links.app` paths; header button + call-to-action. `{lang}` is replaced |
|
|
39
|
+
| `docsUrl` | — | Docs origin for `links.docs` paths; `{lang}` is replaced by the tutorial language |
|
|
40
|
+
| `cta` | `true` | Académie "your turn" panel (needs an app link) |
|
|
41
|
+
| `themeSwitcher` | — | `{ Académie: '/help/', Classic: '/help/classic/' }` — links between builds |
|
|
42
|
+
| `input` / `output` | *required* | Recordings dir / built site dir |
|
|
43
|
+
| `timelines` / `videos` | `<input>/output`, `<input>/videos` | Override when `TUTORIAL_OUTPUT_DIR` differs |
|
|
44
|
+
| `baseUrl` | *required* | Full URL or path (§1) |
|
|
45
|
+
| `cors` | `'*'` | `_headers` Access-Control-Allow-Origin (widget on another origin); `false` = no file |
|
|
46
|
+
| `lang` | *required* | One language or a comma list (§6) |
|
|
47
|
+
| `strings` | built-in en/fr/ar | UI text overrides per language: `{ fr: { ctaButton: 'Essayer' } }` |
|
|
48
|
+
| `primaryColor` / `font` | — | Pre-0.6 spellings of `tokens.primary` / `tokens.fontBody` |
|
|
49
|
+
| `tutorials.categories` | from `@feature:` tags | Sections in display order (§3) |
|
|
50
|
+
| `tutorials.featured` | first video | Slug of the Académie "start here" video |
|
|
51
|
+
| `tutorials.premium` | `[]` | Slugs with a PRO badge |
|
|
52
|
+
| `tutorials.links` | test `links` | Per-slug `{ app, docs }`, over the test's |
|
|
53
|
+
| `tutorials.ui.heroTitle` | `title` | `*word*` marks emphasis (italic). String or `{ fr, en }` |
|
|
54
|
+
| `tutorials.ui.heroSubtitle` | "Video tutorials" | String or per language |
|
|
55
|
+
| `tutorials.stepsLayout` | `'text'` | Video page step guide: `'text'` \| `'cards'` \| `'full'` \| `'none'` |
|
|
56
|
+
| `tutorials.showStrip` | `true` | Thumbnail strip above the step guide |
|
|
57
|
+
|
|
58
|
+
## 3. Sections and order
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
tutorials: {
|
|
62
|
+
featured: 'onboarding',
|
|
63
|
+
premium: ['bank-reconciliation'],
|
|
64
|
+
categories: {
|
|
65
|
+
start: {
|
|
66
|
+
label: { fr: 'Premiers pas', en: 'Getting started' },
|
|
67
|
+
blurb: { fr: 'Créer son compte et sa première facture.', en: 'Account and first invoice.' },
|
|
68
|
+
items: ['onboarding', 'first-invoice'] // slugs, in reading order
|
|
69
|
+
},
|
|
70
|
+
billing: { label: 'Facturation', items: ['credit-note', 'recurring'] }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Sections show in key order; videos in `items` order, then unlisted ones in scan order.
|
|
76
|
+
- `items` wins over the timeline `@feature:` tag. A slug = the test name without `.<lang>` / `-<variant>`,
|
|
77
|
+
so one entry covers every language and variant (`items`, `premium`, `featured`, `links` alike).
|
|
78
|
+
- Empty sections are dropped. Section stats ("3 videos · ~4 min") are computed.
|
|
79
|
+
|
|
80
|
+
## 4. Look: tokens → css → overrides
|
|
81
|
+
|
|
82
|
+
Use the lightest layer that does the job:
|
|
83
|
+
|
|
84
|
+
1. **`tokens`** — colors, radius, shadow, fonts:
|
|
85
|
+
`primary onPrimary accent bg surface text muted border pro radius shadow shadowHover fontBody fontDisplay`
|
|
86
|
+
→ `--pd-*` variables, written as `html:root { … }` so they beat the theme defaults.
|
|
87
|
+
Keep `primary` at 4.5:1 or more against `onPrimary` and `surface` (WCAG AA — the e2e suite runs axe).
|
|
88
|
+
2. **`css`** — any rule, loaded last. Target the stable classes (`.video-card`, `.ac-card`,
|
|
89
|
+
`.step-row`, `.video-modal`, …) or set `--pd-*` variables.
|
|
90
|
+
3. **`overrides`** — a folder mirroring the site `src/`: `overrides/theme/Home.astro` replaces the
|
|
91
|
+
theme's home page; `overrides/components/VideoLinks.astro` replaces a shared component. Last resort:
|
|
92
|
+
overridden files do not get package updates.
|
|
93
|
+
|
|
94
|
+
Copy order (later wins): `templates/site` → `templates/themes/<theme>` (as `src/theme/`) → `overrides`
|
|
95
|
+
→ generated data (`src/data/*.json`, `styles/user.css`, `public/*`).
|
|
96
|
+
|
|
97
|
+
## 5. Links to the app and the docs (cross-linking)
|
|
98
|
+
|
|
99
|
+
Declare them in the test — they are stored in the timeline and need no rebuild of the config:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const tutorial = new Tutorial(page, {
|
|
103
|
+
title: t('invoice.create'),
|
|
104
|
+
links: { app: '/invoices/new', docs: '/guides/invoices/' }, // paths on appUrl / docsUrl, or full URLs
|
|
105
|
+
// …
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Video pages show "Open in the app" / "Read the docs" buttons; the Académie call-to-action uses the
|
|
110
|
+
video's app link, else `appUrl`.
|
|
111
|
+
- `links.json` (site root, full `baseUrl` only) maps each docs URL to its tutorials
|
|
112
|
+
(`slug, lang, url, title, poster, durationSeconds`), so the docs site can render "watch the video" cards.
|
|
113
|
+
- The widget payloads (`embed/<slug>.json`) carry `links` too.
|
|
114
|
+
|
|
115
|
+
## 6. Languages
|
|
116
|
+
|
|
117
|
+
- `lang: 'fr,en,ar'`: `/` = fr home, `/en/`, `/ar/` = the others; ar/he/fa/ur pages are RTL.
|
|
118
|
+
- Record one spec per language with `TUTORIAL_LANG=xx` (`api.md` §1). Each home lists every tutorial
|
|
119
|
+
once, in its language when recorded, else in its first recorded language — a missing translation
|
|
120
|
+
never hides a tutorial.
|
|
121
|
+
- UI strings: built-in en/fr/ar; `strings` adds or overrides keys. A new language starts from English.
|
|
122
|
+
Plurals: a `<key>_<category>` entry (`sectionStats_one`) is picked by `Intl.PluralRules`.
|
|
123
|
+
|
|
124
|
+
## 7. CLI
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npx playwright-director build-site # ./tutorial-site.config.js
|
|
128
|
+
npx playwright-director build-site --config=help.js
|
|
129
|
+
npx playwright-director build-site --theme=classic # override config.theme
|
|
130
|
+
npx playwright-director build-site --base=/help/ # override baseUrl's path
|
|
131
|
+
npx playwright-director build-site --output=dist/help/ # override output
|
|
132
|
+
npx playwright-director build-site --only=onboarding # only these slugs (all languages/variants)
|
|
133
|
+
npx playwright-director build-site -y # never prompt (CI; automatic without a TTY)
|
|
134
|
+
npx playwright-director build-site --dev # astro dev with live reload, no build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Two themes from one config: build twice with `--theme` + `--base` + `--output`, and set
|
|
138
|
+
`themeSwitcher` so each build links to the other.
|
|
139
|
+
|
|
140
|
+
## 8. Output
|
|
141
|
+
|
|
142
|
+
| Path | Content |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `index.html`, `<lang>/index.html` | Home per language |
|
|
145
|
+
| `<id>/index.html` | Video page (player + chapters, steps, prev/next, course sidebar) |
|
|
146
|
+
| `videos/` | Videos, posters, step screenshots |
|
|
147
|
+
| `sitemap.xml`, `robots.txt`, `links.json` | SEO + docs cross-links (full `baseUrl` only) |
|
|
148
|
+
| `embed/*.json`, `widget.js`, `client.js` | In-app help widget + headless data API |
|
|
149
|
+
| `_headers` | CORS + cache rules (Cloudflare Pages / Netlify) |
|
|
150
|
+
|
|
151
|
+
## 9. Checklist
|
|
152
|
+
|
|
153
|
+
- [ ] `baseUrl` is a full URL in production (SEO files and JSON-LD need it)
|
|
154
|
+
- [ ] Every recorded slug is in a section's `items` (or has a meaningful `@feature:` tag)
|
|
155
|
+
- [ ] `featured` names an existing slug
|
|
156
|
+
- [ ] Tests that show an app screen set `links.app`; tests with a docs page set `links.docs`
|
|
157
|
+
- [ ] Customization uses tokens first, `css` second, `overrides` last
|
|
158
|
+
- [ ] `--only` builds are for checking a page — deploy a full build
|
|
@@ -41,17 +41,18 @@
|
|
|
41
41
|
en: {
|
|
42
42
|
close: 'Close', tutorial: 'Tutorial', loading: 'Loading…', unavailable: 'Tutorial unavailable',
|
|
43
43
|
steps: 'Steps', step: 'Step {n}', playFrom: 'Play from {time}', screenshot: 'Screenshot',
|
|
44
|
-
openFull: 'Open full tutorial', duration: 'Duration'
|
|
44
|
+
openFull: 'Open full tutorial', duration: 'Duration', openInApp: 'Open in the app', readDocs: 'Read the documentation'
|
|
45
45
|
},
|
|
46
46
|
fr: {
|
|
47
47
|
close: 'Fermer', tutorial: 'Tutoriel', loading: 'Chargement…', unavailable: 'Tutoriel indisponible',
|
|
48
48
|
steps: 'Étapes', step: 'Étape {n}', playFrom: 'Lire à partir de {time}', screenshot: 'Capture d’écran',
|
|
49
|
-
openFull: 'Ouvrir le tutoriel complet', duration: 'Durée'
|
|
49
|
+
openFull: 'Ouvrir le tutoriel complet', duration: 'Durée', openInApp: 'Ouvrir dans l’application',
|
|
50
|
+
readDocs: 'Lire la documentation'
|
|
50
51
|
},
|
|
51
52
|
ar: {
|
|
52
53
|
close: 'إغلاق', tutorial: 'درس', loading: 'جارٍ التحميل…', unavailable: 'الدرس غير متاح',
|
|
53
54
|
steps: 'الخطوات', step: 'الخطوة {n}', playFrom: 'تشغيل من {time}', screenshot: 'لقطة الشاشة',
|
|
54
|
-
openFull: 'فتح الدرس كاملاً', duration: 'المدة'
|
|
55
|
+
openFull: 'فتح الدرس كاملاً', duration: 'المدة', openInApp: 'فتح في التطبيق', readDocs: 'قراءة التوثيق'
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
var RTL_LANGS = ['ar', 'he', 'fa', 'ur'];
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
|
|
95
96
|
var CSS = [
|
|
96
97
|
// `all: initial` isolates the widget; font-family is re-inherited so it uses the app's font.
|
|
97
|
-
':host { all: initial; font-family: inherit; --pd-accent: var(--playwright-director-accent, #
|
|
98
|
+
':host { all: initial; font-family: inherit; --pd-accent: var(--playwright-director-accent, #4f46e5); --pd-surface: #fff;',
|
|
98
99
|
' --pd-text: #0f172a; --pd-muted: #64748b; --pd-border: #e2e8f0; --pd-radius: 12px;',
|
|
99
100
|
' --pd-focus-ring: 0 0 0 3px color-mix(in srgb, var(--pd-accent) 45%, transparent); }',
|
|
100
101
|
'* { box-sizing: border-box; margin: 0; padding: 0; }',
|
|
@@ -144,7 +145,7 @@
|
|
|
144
145
|
'.shot img { width: 100%; display: block; border-radius: calc(var(--pd-radius) / 2); border: 1px solid var(--pd-border); }',
|
|
145
146
|
'.context { color: var(--pd-muted); font-style: italic; font-size: 0.88rem;',
|
|
146
147
|
' border-inline-start: 3px solid var(--pd-accent); padding-inline-start: 0.75rem; }',
|
|
147
|
-
'.foot { padding: 0.5rem 1.25rem; border-top: 1px solid var(--pd-border);
|
|
148
|
+
'.foot { padding: 0.5rem 1.25rem; border-top: 1px solid var(--pd-border); display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 1.25rem; }',
|
|
148
149
|
'.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--pd-accent);',
|
|
149
150
|
' font-size: 0.9rem; font-weight: 600; text-decoration: none; border-radius: 4px; }',
|
|
150
151
|
'.foot a:hover { text-decoration: underline; }',
|
|
@@ -362,12 +363,16 @@
|
|
|
362
363
|
dialog.appendChild(body);
|
|
363
364
|
|
|
364
365
|
var foot = el('footer', 'foot');
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
366
|
+
var links = data.links || {};
|
|
367
|
+
[[links.app, 'openInApp'], [links.docs, 'readDocs'], [data.page, 'openFull']].forEach(function (pair) {
|
|
368
|
+
if (!pair[0]) return;
|
|
369
|
+
var link = document.createElement('a');
|
|
370
|
+
link.href = pair[0];
|
|
371
|
+
link.target = '_blank';
|
|
372
|
+
link.rel = 'noopener';
|
|
373
|
+
link.textContent = tr(lang, pair[1]) + ' ↗';
|
|
374
|
+
foot.appendChild(link);
|
|
375
|
+
});
|
|
371
376
|
dialog.appendChild(foot);
|
|
372
377
|
}
|
|
373
378
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Links to the home page of every recorded language (hidden when there is only one).
|
|
3
|
+
import { t, LANG_NAMES } from '../i18n';
|
|
4
|
+
import { homeOf, recordedLangs } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
lang: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { lang } = Astro.props;
|
|
11
|
+
const langs = recordedLangs();
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{langs.length > 1 && (
|
|
15
|
+
<nav class="variant-filter" aria-label={t(lang, 'language')}>
|
|
16
|
+
{langs.map((l) => (
|
|
17
|
+
<a class:list={['variant-btn', { active: l === lang }]} href={homeOf(l)} lang={l} hreflang={l} aria-current={l === lang ? 'page' : undefined}>{LANG_NAMES[l] ?? l}</a>
|
|
18
|
+
))}
|
|
19
|
+
</nav>
|
|
20
|
+
)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Links to the same tutorial in its other recorded languages (hidden when there is only one).
|
|
3
|
+
import { t, LANG_NAMES } from '../i18n';
|
|
4
|
+
import { translationsOf, videoHref, type Video } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
video: Video;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { video } = Astro.props;
|
|
11
|
+
const translations = translationsOf(video);
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{translations.length > 1 && (
|
|
15
|
+
<nav class="lang-switch" aria-label={t(video.lang, 'language')}>
|
|
16
|
+
{translations.map((v) => (
|
|
17
|
+
<a href={videoHref(v)} lang={v.lang} hreflang={v.lang} aria-current={v.id === video.id ? 'page' : undefined}>{LANG_NAMES[v.lang!] ?? v.lang}</a>
|
|
18
|
+
))}
|
|
19
|
+
</nav>
|
|
20
|
+
)}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Full-size screenshot viewer for .step-frame / .step-thumb buttons, with the step's number, title and text.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<div class="lightbox" id="step-lightbox" hidden>
|
|
6
|
+
<figure class="lightbox-figure">
|
|
7
|
+
<img alt="" />
|
|
8
|
+
<figcaption class="lightbox-caption" hidden>
|
|
9
|
+
<span class="lightbox-num"></span>
|
|
10
|
+
<span class="lightbox-copy">
|
|
11
|
+
<strong class="lightbox-title"></strong>
|
|
12
|
+
<span class="lightbox-text"></span>
|
|
13
|
+
</span>
|
|
14
|
+
</figcaption>
|
|
15
|
+
</figure>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
const lightbox = document.getElementById('step-lightbox');
|
|
20
|
+
if (lightbox) {
|
|
21
|
+
const img = lightbox.querySelector('img')!;
|
|
22
|
+
const caption = lightbox.querySelector<HTMLElement>('.lightbox-caption')!;
|
|
23
|
+
const num = lightbox.querySelector<HTMLElement>('.lightbox-num')!;
|
|
24
|
+
const title = lightbox.querySelector<HTMLElement>('.lightbox-title')!;
|
|
25
|
+
const text = lightbox.querySelector<HTMLElement>('.lightbox-text')!;
|
|
26
|
+
|
|
27
|
+
const open = (source: HTMLElement) => {
|
|
28
|
+
img.src = source.dataset.full || '';
|
|
29
|
+
num.textContent = source.dataset.num || '';
|
|
30
|
+
title.textContent = source.dataset.title || '';
|
|
31
|
+
text.textContent = source.dataset.text || '';
|
|
32
|
+
caption.hidden = !(source.dataset.title || source.dataset.text);
|
|
33
|
+
lightbox.hidden = false;
|
|
34
|
+
document.body.style.overflow = 'hidden';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
document.querySelectorAll<HTMLElement>('.step-thumb, .step-frame').forEach((thumb) => {
|
|
38
|
+
thumb.addEventListener('click', () => open(thumb));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const close = () => {
|
|
42
|
+
lightbox.hidden = true;
|
|
43
|
+
document.body.style.overflow = '';
|
|
44
|
+
};
|
|
45
|
+
lightbox.addEventListener('click', close);
|
|
46
|
+
document.addEventListener('keydown', (e) => {
|
|
47
|
+
if (e.key === 'Escape' && !lightbox.hidden) close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Previous / next tutorial links; `nextLabel` announces a section change ("Next section: …").
|
|
3
|
+
import { t } from '../i18n';
|
|
4
|
+
import { videoHref, type Video } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
prev: Video | null;
|
|
8
|
+
next: Video | null;
|
|
9
|
+
lang?: string;
|
|
10
|
+
prevLabel?: string;
|
|
11
|
+
nextLabel?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { prev, next, lang: L, prevLabel, nextLabel } = Astro.props;
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<nav class="video-nav-row" aria-label={t(L, 'navigation')}>
|
|
18
|
+
<div class="nav-prev">
|
|
19
|
+
{prev && (
|
|
20
|
+
<a href={videoHref(prev)} class="nav-link nav-link-prev">
|
|
21
|
+
<span class="nav-arrow" aria-hidden="true">‹</span>
|
|
22
|
+
<span class="nav-text">
|
|
23
|
+
{prevLabel && <span class="nav-label">{prevLabel}</span>}
|
|
24
|
+
<span class="nav-title">{prev.title}</span>
|
|
25
|
+
</span>
|
|
26
|
+
</a>
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
<div class="nav-next">
|
|
30
|
+
{next && (
|
|
31
|
+
<a href={videoHref(next)} class="nav-link nav-link-next">
|
|
32
|
+
<span class="nav-text">
|
|
33
|
+
{nextLabel && <span class="nav-label">{nextLabel}</span>}
|
|
34
|
+
<span class="nav-title">{next.title}</span>
|
|
35
|
+
</span>
|
|
36
|
+
<span class="nav-arrow" aria-hidden="true">›</span>
|
|
37
|
+
</a>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
</nav>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <head> tags for search engines and link previews. Absolute URLs (canonical, hreflang, og:*)
|
|
3
|
+
// need a full `baseUrl`; with a path-only baseUrl only the relative-safe tags are written.
|
|
4
|
+
import { config } from '../lib/site';
|
|
5
|
+
import { siteLang } from '../i18n';
|
|
6
|
+
|
|
7
|
+
export interface SeoProps {
|
|
8
|
+
/** Base-path-included paths, e.g. `/help/look/` */
|
|
9
|
+
alternates?: { lang: string; href: string }[];
|
|
10
|
+
/** Path of the preview image */
|
|
11
|
+
image?: string;
|
|
12
|
+
/** Path of the video file (og:video) */
|
|
13
|
+
video?: string;
|
|
14
|
+
type?: 'website' | 'video.other';
|
|
15
|
+
jsonLd?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Props extends SeoProps {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
lang: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { title, description, lang, alternates = [], image, video, type = 'website', jsonLd } = Astro.props;
|
|
25
|
+
const origin = config.siteUrl ? new URL(config.siteUrl).origin : undefined;
|
|
26
|
+
const abs = (path?: string) => (origin && path ? new URL(path, origin).href : undefined);
|
|
27
|
+
const canonical = abs(Astro.url.pathname);
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
{canonical && <link rel="canonical" href={canonical} />}
|
|
31
|
+
{origin && alternates.length > 1 && alternates.map((a) => <link rel="alternate" hreflang={a.lang} href={abs(a.href)} />)}
|
|
32
|
+
{origin && alternates.length > 1 && <link rel="alternate" hreflang="x-default" href={abs(alternates.find((a) => a.lang === siteLang)?.href ?? alternates[0].href)} />}
|
|
33
|
+
<meta property="og:type" content={type} />
|
|
34
|
+
<meta property="og:title" content={title} />
|
|
35
|
+
<meta property="og:description" content={description} />
|
|
36
|
+
<meta property="og:site_name" content={config.title} />
|
|
37
|
+
<meta property="og:locale" content={lang} />
|
|
38
|
+
{canonical && <meta property="og:url" content={canonical} />}
|
|
39
|
+
{abs(image) && <meta property="og:image" content={abs(image)} />}
|
|
40
|
+
{abs(video) && <meta property="og:video" content={abs(video)} />}
|
|
41
|
+
<meta name="twitter:card" content={image ? 'summary_large_image' : 'summary'} />
|
|
42
|
+
{jsonLd && <script type="application/ld+json" set:html={JSON.stringify(jsonLd).replace(/</g, '\\u003c')} />}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Step-by-step guide in the configured layout (SiteConfig.tutorials.stepsLayout).
|
|
3
|
+
// Each numbered step carries data-at, so VideoPlayer marks the playing one.
|
|
4
|
+
import { t } from '../i18n';
|
|
5
|
+
import { media, mmss, type NumberedStep } from '../lib/site';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
steps: NumberedStep[];
|
|
9
|
+
layout: 'text' | 'cards' | 'full' | 'none';
|
|
10
|
+
lang?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { steps: numbered, layout, lang: L } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{layout === 'full' && numbered.length > 0 && (
|
|
17
|
+
<section class="steps-guide">
|
|
18
|
+
{numbered.map((s) => (
|
|
19
|
+
s.context ? (
|
|
20
|
+
<p class="step-context">{s.text}</p>
|
|
21
|
+
) : (
|
|
22
|
+
<div class="step-block" data-at={s.at}>
|
|
23
|
+
<div class="step-header">
|
|
24
|
+
<span class="step-number">{s.num}</span>
|
|
25
|
+
<div class="step-copy">
|
|
26
|
+
{s.title && <h2 class="step-title">{s.title}</h2>}
|
|
27
|
+
{s.text && <p class="step-text">{s.text}</p>}
|
|
28
|
+
</div>
|
|
29
|
+
{s.at !== undefined && <button class="step-time" data-at={s.at} aria-label={t(L, 'playFrom', { time: mmss(s.at) })}>▶ {mmss(s.at)}</button>}
|
|
30
|
+
</div>
|
|
31
|
+
{s.image && (
|
|
32
|
+
<img
|
|
33
|
+
class="step-shot"
|
|
34
|
+
src={media(s.image)}
|
|
35
|
+
alt={s.title || t(L, 'step', { n: s.num! })}
|
|
36
|
+
loading={s.num === 1 ? 'eager' : 'lazy'}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
))}
|
|
42
|
+
</section>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
{layout === 'cards' && numbered.length > 0 && (
|
|
46
|
+
<section class="steps-cards">
|
|
47
|
+
{numbered.map((s) => (
|
|
48
|
+
s.context ? (
|
|
49
|
+
<p class="step-context">{s.text}</p>
|
|
50
|
+
) : (
|
|
51
|
+
<div class="step-card" data-at={s.at}>
|
|
52
|
+
<span class="step-number">{s.num}</span>
|
|
53
|
+
<div class="step-copy">
|
|
54
|
+
{s.title && <h2 class="step-title">{s.title}</h2>}
|
|
55
|
+
{s.text && <p class="step-text">{s.text}</p>}
|
|
56
|
+
</div>
|
|
57
|
+
{s.at !== undefined && <button class="step-time" data-at={s.at} aria-label={t(L, 'playFrom', { time: mmss(s.at) })}>▶ {mmss(s.at)}</button>}
|
|
58
|
+
{s.image && (
|
|
59
|
+
<button
|
|
60
|
+
class="step-thumb"
|
|
61
|
+
data-full={media(s.image)}
|
|
62
|
+
data-num={s.num}
|
|
63
|
+
data-title={s.title || ''}
|
|
64
|
+
data-text={s.text || ''}
|
|
65
|
+
aria-label={t(L, 'enlarge', { n: s.num! })}
|
|
66
|
+
>
|
|
67
|
+
<img src={media(s.image)} alt={s.title || t(L, 'step', { n: s.num! })} loading="lazy" />
|
|
68
|
+
<span class="step-zoom">⤢</span>
|
|
69
|
+
</button>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
))}
|
|
74
|
+
</section>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{layout === 'text' && numbered.length > 0 && (
|
|
78
|
+
<section class="steps-text">
|
|
79
|
+
{numbered.map((s) => (
|
|
80
|
+
s.context ? (
|
|
81
|
+
<p class="step-context">{s.text}</p>
|
|
82
|
+
) : (
|
|
83
|
+
<div class:list={['step-row', { 'has-shot': !!s.image }]} data-at={s.at}>
|
|
84
|
+
<div class="step-row-top">
|
|
85
|
+
<button class="step-row-head" aria-expanded="false" disabled={!s.image}>
|
|
86
|
+
<span class="step-number">{s.num}</span>
|
|
87
|
+
<span class="step-copy">
|
|
88
|
+
{s.title && <span class="step-title">{s.title}</span>}
|
|
89
|
+
{s.text && <span class="step-text">{s.text}</span>}
|
|
90
|
+
</span>
|
|
91
|
+
{s.image && <span class="step-chevron">▾</span>}
|
|
92
|
+
</button>
|
|
93
|
+
{s.at !== undefined && <button class="step-time" data-at={s.at} aria-label={t(L, 'playFrom', { time: mmss(s.at) })}>▶ {mmss(s.at)}</button>}
|
|
94
|
+
</div>
|
|
95
|
+
{s.image && (
|
|
96
|
+
<div class="step-reveal">
|
|
97
|
+
<img src={media(s.image)} alt={s.title || t(L, 'step', { n: s.num! })} loading="lazy" />
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
))}
|
|
103
|
+
</section>
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
<script>
|
|
107
|
+
// Text layout: click a step to reveal its screenshot
|
|
108
|
+
document.querySelectorAll<HTMLElement>('.step-row.has-shot .step-row-head').forEach((head) => {
|
|
109
|
+
head.addEventListener('click', () => {
|
|
110
|
+
const row = head.closest('.step-row')!;
|
|
111
|
+
const open = row.classList.toggle('open');
|
|
112
|
+
head.setAttribute('aria-expanded', String(open));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Horizontal thumbnail strip; a thumbnail opens its screenshot in the Lightbox.
|
|
3
|
+
import { t } from '../i18n';
|
|
4
|
+
import { media, type NumberedStep } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
steps: NumberedStep[];
|
|
8
|
+
lang?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { steps, lang: L } = Astro.props;
|
|
12
|
+
const shots = steps.filter((s) => s.image);
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{shots.length > 0 && (
|
|
16
|
+
<div class="steps-section">
|
|
17
|
+
<div class="step-strip">
|
|
18
|
+
{shots.map((s) => (
|
|
19
|
+
<button
|
|
20
|
+
class="step-frame"
|
|
21
|
+
data-full={media(s.image!)}
|
|
22
|
+
data-num={s.num}
|
|
23
|
+
data-title={s.title || ''}
|
|
24
|
+
data-text={s.text || ''}
|
|
25
|
+
aria-label={`${t(L, 'step', { n: s.num! })}${s.title ? `: ${s.title}` : ''}`}
|
|
26
|
+
>
|
|
27
|
+
<img src={media(s.image!)} alt={s.title || t(L, 'step', { n: s.num! })} loading={s.num === 1 ? 'eager' : 'lazy'} />
|
|
28
|
+
<span class="step-num">{s.num}</span>
|
|
29
|
+
</button>
|
|
30
|
+
))}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
)}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Links between builds of the same gallery in different themes (config `themeSwitcher`: label → URL).
|
|
3
|
+
// The entry pointing at this build's base path is the current one.
|
|
4
|
+
import { config, base } from '../lib/site';
|
|
5
|
+
import { t } from '../i18n';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
lang?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const entries = Object.entries((config.themeSwitcher ?? {}) as Record<string, string>);
|
|
12
|
+
const pathOf = (href: string) => new URL(href, 'http://site').pathname.replace(/\/?$/, '/');
|
|
13
|
+
const here = `${base}/`;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{entries.length > 1 && (
|
|
17
|
+
<nav class="theme-switcher" aria-label={t(Astro.props.lang, 'theme')}>
|
|
18
|
+
{entries.map(([label, href]) => (
|
|
19
|
+
<a href={href} aria-current={pathOf(href) === here ? 'page' : undefined}>{label}</a>
|
|
20
|
+
))}
|
|
21
|
+
</nav>
|
|
22
|
+
)}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Desktop / mobile / … filter — only shown when at least one video was recorded in a variant.
|
|
3
|
+
// Hides non-matching `[data-variant]` cards and the `.category` sections left empty.
|
|
4
|
+
import { t } from '../i18n';
|
|
5
|
+
import type { Video } from '../lib/site';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
videos: Video[];
|
|
9
|
+
lang: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { videos, lang } = Astro.props;
|
|
13
|
+
const variants: string[] = [...new Set(videos.map((v) => v.variant ?? ''))];
|
|
14
|
+
const label = (v: string) => (v === '' ? t(lang, 'desktop') : v.charAt(0).toUpperCase() + v.slice(1));
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
{variants.some((v) => v !== '') && (
|
|
18
|
+
<nav class="variant-filter" aria-label={t(lang, 'filterVariant')}>
|
|
19
|
+
<button class="variant-btn active" data-variant="all">{t(lang, 'all')}</button>
|
|
20
|
+
{variants.sort().map((v) => (
|
|
21
|
+
<button class="variant-btn" data-variant={v}>{label(v)}</button>
|
|
22
|
+
))}
|
|
23
|
+
</nav>
|
|
24
|
+
)}
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import { setFilter } from '../lib/filter';
|
|
28
|
+
|
|
29
|
+
const bar = document.querySelector('button[data-variant]')?.closest('.variant-filter');
|
|
30
|
+
bar?.addEventListener('click', (e) => {
|
|
31
|
+
const btn = (e.target as HTMLElement).closest<HTMLElement>('.variant-btn');
|
|
32
|
+
if (!btn) return;
|
|
33
|
+
bar.querySelectorAll('.variant-btn').forEach((b) => b.classList.toggle('active', b === btn));
|
|
34
|
+
setFilter({ variant: btn.dataset.variant! });
|
|
35
|
+
});
|
|
36
|
+
</script>
|