From aba1776fcd952064928c4b3e91b25c43f3cd6ee1 Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 11 Sep 2025 15:56:24 -0400 Subject: [PATCH] feat(ui): add a transcript button (#56275) Co-authored-by: Naomi the Technomancer Co-authored-by: sembauke --- .../components/challenge-transcript.css | 13 +++++++++++ .../components/challenge-transcript.tsx | 16 +++++++++++-- .../Challenges/components/scene/scene.tsx | 23 ++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/client/src/templates/Challenges/components/challenge-transcript.css b/client/src/templates/Challenges/components/challenge-transcript.css index cd8271ca593..0bc2065418d 100644 --- a/client/src/templates/Challenges/components/challenge-transcript.css +++ b/client/src/templates/Challenges/components/challenge-transcript.css @@ -1,4 +1,17 @@ .challenge-transcript-heading { cursor: pointer; font-weight: bold; + margin-top: 1.5em; +} + +#learn-app-wrapper .transcript-table { + display: table; + width: 100%; + border: 1px solid var(--gray-05); + border-collapse: collapse; +} + +#learn-app-wrapper .transcript-table td { + border: none; + text-align: start; } diff --git a/client/src/templates/Challenges/components/challenge-transcript.tsx b/client/src/templates/Challenges/components/challenge-transcript.tsx index 782f013dd80..9bc54727a84 100644 --- a/client/src/templates/Challenges/components/challenge-transcript.tsx +++ b/client/src/templates/Challenges/components/challenge-transcript.tsx @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Spacer } from '@freecodecamp/ui'; import store from 'store'; -import PrismFormatted from './prism-formatted'; import './challenge-transcript.css'; @@ -37,7 +36,20 @@ function ChallengeTranscript({ {t('learn.transcript')} - + + + {transcript + .split('\n') + .filter(line => line.trim() !== '') + .map((line, idx) => { + return ( + + + ); + })} + +
+
diff --git a/client/src/templates/Challenges/components/scene/scene.tsx b/client/src/templates/Challenges/components/scene/scene.tsx index 488e1080a29..04bab79d8e4 100644 --- a/client/src/templates/Challenges/components/scene/scene.tsx +++ b/client/src/templates/Challenges/components/scene/scene.tsx @@ -13,6 +13,7 @@ import { useTranslation } from 'react-i18next'; import { FullScene } from '../../../../redux/prop-types'; import { Loader } from '../../../../components/helpers'; import ClosedCaptionsIcon from '../../../../assets/icons/closedcaptions'; +import ChallengeTranscript from '../challenge-transcript'; import { sounds, backgrounds, characterAssets } from './scene-assets'; import Character from './character'; import { SceneSubject } from './scene-subject'; @@ -167,6 +168,25 @@ export function Scene({ setSceneIsReady(true); }; + const buildTranscript = () => { + let transcriptText = ''; + commands.forEach(command => { + if (command.character && command.dialogue && command.startTime) { + transcriptText = + transcriptText + + '\n' + + '' + + command.character + + ':' + + ' ' + + command.dialogue.text + + '\n'; + } + }); + + return transcriptText; + }; + const handlePlay = useCallback(() => { const pausedAt = pausedAtRef.current; const updateCurrentTime = () => { @@ -349,6 +369,7 @@ export function Scene({ }; }, []); + const transcriptText = buildTranscript(); return (
)}
-
+ );