Lesson screen: render fixed lesson figures under intro, example and steps
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,10 +106,19 @@ export interface LessonIntro {
|
|||||||
kind: 'quiz' | 'video';
|
kind: 'quiz' | 'video';
|
||||||
example: string;
|
example: string;
|
||||||
steps: string[];
|
steps: string[];
|
||||||
|
/** شکلهای ثابتِ درس (یک بار ساخته و تأییدشده؛ هیچ تولیدِ زندهای نیست). */
|
||||||
|
figures: LessonFigure[];
|
||||||
videoUrl: string;
|
videoUrl: string;
|
||||||
durationMinutes: number | null;
|
durationMinutes: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LessonFigure {
|
||||||
|
where: 'intro' | 'example' | 'step';
|
||||||
|
/** فقط برای where='step'، از صفر. */
|
||||||
|
index?: number;
|
||||||
|
diagram: DiagramSpec;
|
||||||
|
}
|
||||||
|
|
||||||
export interface QuestionOption {
|
export interface QuestionOption {
|
||||||
id: string;
|
id: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { moodFromServer } from '@/mascots/seyar';
|
|||||||
import { ErrorState, LoadingState, PrimaryButton, Screen, ScreenBody, ScreenHeader, Sep } from '@/components/ui';
|
import { ErrorState, LoadingState, PrimaryButton, Screen, ScreenBody, ScreenHeader, Sep } from '@/components/ui';
|
||||||
import { toFa } from '@/lib/format';
|
import { toFa } from '@/lib/format';
|
||||||
import { MathText } from '@/lib/MathText';
|
import { MathText } from '@/lib/MathText';
|
||||||
|
import { Diagram } from '@/diagram';
|
||||||
|
|
||||||
/** معرفیِ درس، پیش از تمرین. */
|
/** معرفیِ درس، پیش از تمرین. */
|
||||||
export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?: string }) {
|
export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?: string }) {
|
||||||
@@ -18,6 +19,10 @@ export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?:
|
|||||||
const ref = findNode(home, nodeId) ?? findNodeOfLesson(home, lessonId);
|
const ref = findNode(home, nodeId) ?? findNodeOfLesson(home, lessonId);
|
||||||
const color = ref ? unitColor(ref.unitIndex) : '#ED6956';
|
const color = ref ? unitColor(ref.unitIndex) : '#ED6956';
|
||||||
const data = intro.data;
|
const data = intro.data;
|
||||||
|
const figs = (where: 'intro' | 'example' | 'step', index?: number) =>
|
||||||
|
(data?.figures ?? [])
|
||||||
|
.filter((f) => f.where === where && (where !== 'step' || f.index === index))
|
||||||
|
.map((f, k) => <Diagram key={k} spec={f.diagram} />);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Screen>
|
<Screen>
|
||||||
@@ -47,6 +52,7 @@ export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?:
|
|||||||
<SeyarMascot char="sigma" mood="idle" size={56} />
|
<SeyarMascot char="sigma" mood="idle" size={56} />
|
||||||
<div className="flex-1 rounded-3xl rounded-tr-sm border border-line bg-white p-4 shadow-sm">
|
<div className="flex-1 rounded-3xl rounded-tr-sm border border-line bg-white p-4 shadow-sm">
|
||||||
<p className="whitespace-pre-line text-sm leading-[1.95] text-body"><MathText text={data.introText} /></p>
|
<p className="whitespace-pre-line text-sm leading-[1.95] text-body"><MathText text={data.introText} /></p>
|
||||||
|
{figs('intro')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -58,6 +64,7 @@ export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?:
|
|||||||
<section className="rounded-3xl border border-line bg-white p-4">
|
<section className="rounded-3xl border border-line bg-white p-4">
|
||||||
<h2 className="mb-2 text-xs font-black text-muted">مثال</h2>
|
<h2 className="mb-2 text-xs font-black text-muted">مثال</h2>
|
||||||
<p className="whitespace-pre-line text-sm leading-[1.95] text-ink"><MathText text={data.example} /></p>
|
<p className="whitespace-pre-line text-sm leading-[1.95] text-ink"><MathText text={data.example} /></p>
|
||||||
|
{figs('example')}
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -70,7 +77,7 @@ export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?:
|
|||||||
<span className="flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full text-xs font-black text-white" style={{ backgroundColor: color }}>
|
<span className="flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full text-xs font-black text-white" style={{ backgroundColor: color }}>
|
||||||
{toFa(i + 1)}
|
{toFa(i + 1)}
|
||||||
</span>
|
</span>
|
||||||
<span className="flex-1 whitespace-pre-line"><MathText text={step} /></span>
|
<span className="flex-1 whitespace-pre-line"><MathText text={step} />{figs('step', i)}</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
Reference in New Issue
Block a user