Skip to content

Commit 2742c42

Browse files
committed
Refactor CSE default text to own component
1 parent ce8cd21 commit 2742c42

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
@@ -353,63 +353,7 @@ class SideContentCseMachineBase extends React.Component<CseMachineProps, State>
353353
this.state.visualization
354354
)
355355
) : (
356-
<div
357-
id="cse-machine-default-text"
358-
className={Classes.RUNNING_TEXT}
359-
data-testid="cse-machine-default-text"
360-
>
361-
{this.isJava() ? (
362-
<span>
363-
The CSEC machine generates control, stash, environment and class model diagrams
364-
adapted from the notation introduced in{' '}
365-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
366-
<i>
367-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter
368-
3, Section 2
369-
</i>
370-
</a>
371-
{'. '}
372-
You have chosen the sublanguage{' '}
373-
<a href={`${Links.sourceDocs}java_csec/`} rel="noopener noreferrer" target="_blank">
374-
<i>Java CSEC</i>
375-
</a>
376-
</span>
377-
) : (
378-
<span>
379-
The CSE machine generates control, stash and environment model diagrams following a
380-
notation introduced in{' '}
381-
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
382-
<i>
383-
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter
384-
3, Section 2
385-
</i>
386-
</a>
387-
</span>
388-
)}
389-
.
390-
<br />
391-
<br /> On this tab, the REPL will be hidden from view, so do check that your code has no
392-
errors before running the stepper. You may use this tool by running your program and
393-
then dragging the slider above to see the state of the control, stash and environment at
394-
different stages in the evaluation of your program. Clicking on the fast-forward button
395-
(double chevron) will take you to the next breakpoint in your program
396-
<br />
397-
<br />
398-
<Divider />
399-
Some useful keyboard shortcuts:
400-
<br />
401-
<br />
402-
a: Move to the first step
403-
<br />
404-
e: Move to the last step
405-
<br />
406-
f: Move to the next step
407-
<br />
408-
b: Move to the previous step
409-
<br />
410-
<br />
411-
Note that these shortcuts are only active when the browser focus is on this tab.
412-
</div>
356+
<CseMachineDefaultText isJava={this.isJava()} />
413357
)}
414358
<ButtonGroup
415359
vertical={true}
@@ -602,4 +546,66 @@ const makeCseMachineTabFrom = (location: NonStoryWorkspaceLocation): SideContent
602546
id: SideContentType.cseMachine
603547
});
604548

549+
const CseMachineDefaultText: React.FC<{ isJava: boolean }> = ({ isJava }) => {
550+
return (
551+
<div
552+
id="cse-machine-default-text"
553+
className={Classes.RUNNING_TEXT}
554+
data-testid="cse-machine-default-text"
555+
>
556+
{isJava ? (
557+
<span>
558+
The CSEC machine generates control, stash, environment and class model diagrams adapted
559+
from the notation introduced in{' '}
560+
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
561+
<i>
562+
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
563+
Section 2
564+
</i>
565+
</a>
566+
{'. '}
567+
You have chosen the sublanguage{' '}
568+
<a href={`${Links.sourceDocs}java_csec/`} rel="noopener noreferrer" target="_blank">
569+
<i>Java CSEC</i>
570+
</a>
571+
</span>
572+
) : (
573+
<span>
574+
The CSE machine generates control, stash and environment model diagrams following a
575+
notation introduced in{' '}
576+
<a href={Links.textbookChapter3_2} rel="noopener noreferrer" target="_blank">
577+
<i>
578+
Structure and Interpretation of Computer Programs, JavaScript Edition, Chapter 3,
579+
Section 2
580+
</i>
581+
</a>
582+
</span>
583+
)}
584+
.
585+
<br />
586+
<br /> On this tab, the REPL will be hidden from view, so do check that your code has no
587+
errors before running the stepper. You may use this tool by running your program and then
588+
dragging the slider above to see the state of the control, stash and environment at different
589+
stages in the evaluation of your program. Clicking on the fast-forward button (double chevron)
590+
will take you to the next breakpoint in your program
591+
<br />
592+
<br />
593+
<Divider />
594+
Some useful keyboard shortcuts:
595+
<br />
596+
<br />
597+
a: Move to the first step
598+
<br />
599+
e: Move to the last step
600+
<br />
601+
f: Move to the next step
602+
<br />
603+
b: Move to the previous step
604+
<br />
605+
<br />
606+
Note that these shortcuts are only active when the browser focus is on this tab.
607+
</div>
608+
);
609+
};
610+
605611
export default makeCseMachineTabFrom;

0 commit comments

Comments
 (0)