Skip to content

Commit a8b0a50

Browse files
committed
Refactor default text to separate component
1 parent f2aad8e commit a8b0a50

File tree

1 file changed

+63
-57
lines changed

1 file changed

+63
-57
lines changed

src/commons/sideContent/content/SideContentCseMachine.tsx

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -421,63 +421,7 @@ const SideContentCseMachineBase: React.FC<Props> = ({
421421
visualization
422422
)
423423
) : (
424-
<div
425-
id="cse-machine-default-text"
426-
className={Classes.RUNNING_TEXT}
427-
data-testid="cse-machine-default-text"
428-
>
429-
{isJava() ? (
430-
<span>
431-
The CSEC machine generates control, stash, environment and class model diagrams
432-
adapted from the notation introduced in{' '}
433-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
434-
<i>
435-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
436-
Section 2
437-
</i>
438-
</a>
439-
{'. '}
440-
You have chosen the sublanguage{' '}
441-
<a href={`${Links.sourceDocs}java_csec/`} rel="noopener noreferrer" target="_blank">
442-
<i>Java CSEC</i>
443-
</a>
444-
</span>
445-
) : (
446-
<span>
447-
The CSE machine generates control, stash and environment model diagrams following a
448-
notation introduced in{' '}
449-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
450-
<i>
451-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
452-
Section 2
453-
</i>
454-
</a>
455-
</span>
456-
)}
457-
.
458-
<br />
459-
<br /> On this tab, the REPL will be hidden from view, so do check that your code has no
460-
errors before running the stepper. You may use this tool by running your program and then
461-
dragging the slider above to see the state of the control, stash and environment at
462-
different stages in the evaluation of your program. Clicking on the fast-forward button
463-
(double chevron) will take you to the next breakpoint in your program
464-
<br />
465-
<br />
466-
<Divider />
467-
Some useful keyboard shortcuts:
468-
<br />
469-
<br />
470-
a: Move to the first step
471-
<br />
472-
e: Move to the last step
473-
<br />
474-
f: Move to the next step
475-
<br />
476-
b: Move to the previous step
477-
<br />
478-
<br />
479-
Note that these shortcuts are only active when the browser focus is on this tab.
480-
</div>
424+
<CseMachineDefaultText isJava={isJava()} />
481425
)}
482426
<ButtonGroup vertical={true} style={{ position: 'absolute', bottom: '20px', right: '20px' }}>
483427
<Button
@@ -564,4 +508,66 @@ const makeCseMachineTabFrom = (location: NonStoryWorkspaceLocation): SideContent
564508
id: SideContentType.cseMachine
565509
});
566510

511+
const CseMachineDefaultText: React.FC<{ isJava: boolean }> = ({ isJava }) => {
512+
return (
513+
<div
514+
id="cse-machine-default-text"
515+
className={Classes.RUNNING_TEXT}
516+
data-testid="cse-machine-default-text"
517+
>
518+
{isJava ? (
519+
<span>
520+
The CSEC machine generates control, stash, environment and class model diagrams adapted
521+
from the notation introduced in{' '}
522+
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
523+
<i>
524+
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
525+
Section 2
526+
</i>
527+
</a>
528+
{'. '}
529+
You have chosen the sublanguage{' '}
530+
<a href={`${Links.sourceDocs}java_csec/`} rel="noopener noreferrer" target="_blank">
531+
<i>Java CSEC</i>
532+
</a>
533+
</span>
534+
) : (
535+
<span>
536+
The CSE machine generates control, stash and environment model diagrams following a
537+
notation introduced in{' '}
538+
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
539+
<i>
540+
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
541+
Section 2
542+
</i>
543+
</a>
544+
</span>
545+
)}
546+
.
547+
<br />
548+
<br /> On this tab, the REPL will be hidden from view, so do check that your code has no
549+
errors before running the stepper. You may use this tool by running your program and then
550+
dragging the slider above to see the state of the control, stash and environment at different
551+
stages in the evaluation of your program. Clicking on the fast-forward button (double chevron)
552+
will take you to the next breakpoint in your program
553+
<br />
554+
<br />
555+
<Divider />
556+
Some useful keyboard shortcuts:
557+
<br />
558+
<br />
559+
a: Move to the first step
560+
<br />
561+
e: Move to the last step
562+
<br />
563+
f: Move to the next step
564+
<br />
565+
b: Move to the previous step
566+
<br />
567+
<br />
568+
Note that these shortcuts are only active when the browser focus is on this tab.
569+
</div>
570+
);
571+
};
572+
567573
export default makeCseMachineTabFrom;

0 commit comments

Comments
 (0)