From 357cc504bde949d5be4645af69e551b5aecff648 Mon Sep 17 00:00:00 2001 From: Ahmad Abdolsaheb Date: Mon, 23 Jun 2025 18:40:13 +0300 Subject: [PATCH] Test adding transcript tabs to lectures (#60948) --- client/i18n/locales/english/translations.json | 1 + .../components/challenge-transcript.tsx | 13 ++- .../src/templates/Challenges/generic/show.css | 9 ++ .../src/templates/Challenges/generic/show.tsx | 83 ++++++++++++++++--- 4 files changed, 95 insertions(+), 11 deletions(-) diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index 0f891d0e415..5b7c2edd728 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -419,6 +419,7 @@ "answered-mcq": "You have unanswered questions and/or incorrect answers.", "explanation": "Explanation", "transcript": "Transcript", + "video": "Video", "solution-link": "Solution Link", "source-code-link": "Source Code Link", "ms-link": "Microsoft Link", diff --git a/client/src/templates/Challenges/components/challenge-transcript.tsx b/client/src/templates/Challenges/components/challenge-transcript.tsx index 782f013dd80..cc3ad08c406 100644 --- a/client/src/templates/Challenges/components/challenge-transcript.tsx +++ b/client/src/templates/Challenges/components/challenge-transcript.tsx @@ -8,10 +8,12 @@ import './challenge-transcript.css'; interface ChallengeTranscriptProps { transcript: string; + showTranscriptTabs?: boolean; } function ChallengeTranscript({ - transcript + transcript, + showTranscriptTabs }: ChallengeTranscriptProps): JSX.Element { const { t } = useTranslation(); @@ -26,6 +28,15 @@ function ChallengeTranscript({ setIsOpen(!isOpen); } + if (showTranscriptTabs) + return ( + <> + + + + + ); + return ( <>
diff --git a/client/src/templates/Challenges/generic/show.css b/client/src/templates/Challenges/generic/show.css index 7c4f7d49b38..1b7bd088fb3 100644 --- a/client/src/templates/Challenges/generic/show.css +++ b/client/src/templates/Challenges/generic/show.css @@ -31,3 +31,12 @@ input[type='checkbox']:checked::before { audio { background-color: aqua; } + +.transcript-tabs button[aria-selected='false'] { + color: var(--secondary-color); + background-color: transparent; +} + +.transcript-tabs button[aria-selected='false']:hover { + background-color: var(--quaternary-background); +} diff --git a/client/src/templates/Challenges/generic/show.tsx b/client/src/templates/Challenges/generic/show.tsx index f8058e9db0f..d981a6f714a 100644 --- a/client/src/templates/Challenges/generic/show.tsx +++ b/client/src/templates/Challenges/generic/show.tsx @@ -3,10 +3,21 @@ import React, { useEffect, useRef, useState } from 'react'; import Helmet from 'react-helmet'; import { useTranslation } from 'react-i18next'; import { connect } from 'react-redux'; -import { Container, Col, Row, Button, Spacer } from '@freecodecamp/ui'; +import { + Container, + Col, + Row, + Button, + Spacer, + Tabs, + TabsContent, + TabsTrigger, + TabsList +} from '@freecodecamp/ui'; import { isEqual } from 'lodash'; import store from 'store'; import { YouTubeEvent } from 'react-youtube'; +import { useFeatureIsOn } from '@growthbook/growthbook-react'; // Local Utilities import LearnLayout from '../../../components/layouts/learn'; @@ -104,6 +115,11 @@ const ShowGeneric = ({ const { t } = useTranslation(); const container = useRef(null); + // just test on this particular block + const transcriptTabsFlagIsOn = useFeatureIsOn('transcript-tabs'); + const showTranscriptTabs = + block === 'lecture-html-fundamentals' && transcriptTabsFlagIsOn; + const blockNameTitle = `${t( `intro:${superBlock}.blocks.${block}.title` )} - ${title}`; @@ -127,6 +143,11 @@ const ShowGeneric = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + const tabs = { + transcript: 'transcript', + video: 'video' + } as const; + // video const [videoIsLoaded, setVideoIsLoaded] = useState(false); @@ -228,7 +249,54 @@ const ShowGeneric = ({ )} - {videoId && ( + {showTranscriptTabs && ( + + + + {t('learn.transcript')} + + + {t('learn.video')} + + + + {transcript && ( + + )} + + + + {videoId && ( + <> + + + + )} + + + )} + {videoId && !showTranscriptTabs && ( <> } - {transcript && } - + {transcript && !showTranscriptTabs && ( + + )} {instructions && ( <> )} - {assignments.length > 0 && ( )} - {questions.length > 0 && ( )} - {explanation ? ( ) : null} - {!hasAnsweredMcqCorrectly && (

{t('learn.answered-mcq')}

)} - -