Branchwell

Jotley / website / src / app / components / home / HomeTutorials.tsx

1'use client';
2
3import { useState } from 'react';
4import Walkthrough from './Walkthrough';
5import { TUTORIALS, formatTime } from './media';
6
7/** The home page's tutorials: one narrated film per device, switched with tabs (replaces the single walkthrough film). */
8export default function HomeTutorials() {
9 const [id, setId] = useState(TUTORIALS[0].id);
10 const t = TUTORIALS.find((x) => x.id === id) ?? TUTORIALS[0];
11 return (
12 <>
13 <div className="tut-tabs" role="tablist" aria-label="Choose a device">
14 {TUTORIALS.map((x) => (
15 <button
16 key={x.id}
17 type="button"
18 role="tab"
19 aria-selected={x.id === id}
20 className={x.id === id ? 'on' : ''}
21 onClick={() => setId(x.id)}
22 >
23 {x.title.replace(/^Jotley (on |for )/, '')}
24 <span>{formatTime(x.film.duration)}</span>
25 </button>
26 ))}
27 </div>
28 <Walkthrough
29 key={t.id}
30 film={t.film}
31 chapters={t.chapters}
32 label={`${t.title} tutorial, with narration and captions`}
33 startTitle={`Watch ${t.title}`}
34 chaptersLabel={`${t.title} chapters`}
35 event="tutorial"
36 location={`home-${t.id}`}
37 />
38 </>
39 );
40}