-
Notifications
You must be signed in to change notification settings - Fork 168
Playground
This Component can be accessed by both the public and NUS Staff. It exists in a separate link which does not require any user authentication.
It mainly consists of four parts:
-
ControlBar
: Component to control settings for the Source Academy Playground and the REPL editor. -
Markdown
: Component where one can view the related information to Source Academy (and potentially the information related to the Source Chapter) -
Editor
: The Main Code Editor for the playground. -
ReplInput
: The Editor for Source's REPL
Props | |
---|---|
editorSessionId | mandatory |
editorWidth | mandatory |
editorValue | mandatory |
execTime | mandatory |
breakpoints | mandatory |
highlightedLines | mandatory |
isEditorAutorun | mandatory |
isRunning | mandatory |
isDebugging | mandatory |
enableDebugging | mandatory |
newCursorPosition | mandatory |
output | mandatory |
queryString | mandatory |
replValue | mandatory |
sharedbAceIsInviting | mandatory |
sharedbAceInitValue | mandatory |
sideContentHeight | mandatory |
sourceChapter | mandatory |
sourceVariant | mandatory |
websocketStatus | mandatory |
externalLibraryName | mandatory |
usingSubst | mandatory |
Related file(s): ./components/Playground.tsx
, ./containers/PlaygroundContainer.ts
It mainly consists of two sets of buttons.
-
editorButtons
: Buttons to toggle theEditor
settings. -
replButtons
: Buttons to toggle theReplInput
settings.
For the Editor
, there are six main buttons:
-
AutorunButtons
: To toggle auto-run on or off. -
ShareButton
: To Share code with other users via a generated URL Link. -
ChapterSelect
To Select thesourceChapter
and load its associated libraries -
ExternalLibrarySelect
To Select theexternalLibraryName
and load the associated external library. -
SessionButtons
: To allow for collaborative editing between users. -
ExecutionTime
: To limit the amount of time needed for execution.
The toggle is mainly done by the function handleToggleEditorAutorun
, which is passed into a Switch
. When the Switch
is clicked, it toggles the isEditorAutorun
flag and changes the icon of the RunButton
.
Props | |
---|---|
isDebugging | mandatory |
isEditorAutorun | mandatory |
isRunning | mandatory |
The queryString
is passed into the ShareButton
and based on the Code from the Editor
, the queryString gets composed into a sharable link given the queryString
information.
Props | |
---|---|
queryString | optional |
The user can changed the sourceChapter
and / or the sourceVariant
using this button. This is mainly done using the handleChapterSelect
function, where it changes the sourceChapter
and the sourceVariant
of the Editor
based on the GUI Input given.
The Source Chapter and Source Variant should be saved within the localStorage
.
Props | |
---|---|
sourceChapter | mandatory |
sourceVariant | mandatory |
The user can changed the externalLibraryName
using this button. This is mainly done using the handleExternalSelect
function, where it changes the externalLibraryName
of the Editor
based on the GUI Input given.
The External Library Name should be saved within the localStorage
.
Props | |
---|---|
externalLibraryName | mandatory |
To allow for Collaborative Editing for Editor
code between users. A user can invite, join or leave depending on the state of the host's web session.
Props | |
---|---|
editorSessionId | mandatory |
editorValue | mandatory |
websocketStatus | mandatory |
Note: websocketStatus has mainly 2 configurations. 0 for offline and 1 for online.
In the event that programs that longer than 1000 milliseconds, the user is able to change the execTime
using the ExecutionTime
component. Do note that the units for execTime
is in milliseconds. So 1000 milliseconds = 1 second.
Props | |
---|---|
execTime | mandatory |
For the ReplInput
, there are two main buttons:
-
EvalButton
: To Evaluate what was given in theReplInput
. -
ClearButton
: To Clear the entireREPL
history.
The ReplInput
code gets run when the user clicks on this component. This can also be done using the shortcut Shift + Enter
Props | |
---|---|
isRunning | mandatory |
When the user clicks on the ClearButton
, the REPL History gets cleared using the handleReplOutputClear
function.
It consists of two sections.
-
SideContent
: Dependent on thesourceChapter
and thesourceVariant
of the Playground. -
Markdown
: Component where one can view the related information to Source Academy
It consists of multiple SideContentTab
. THe following SideContentTab
s are:
-
Introduction
: Always Present regardless ofsourceChapter
andsourceVariant
. Inspector
ListVisualizer
EnvVisualizer
VideoDisplay
FaceapiDisplay
Props | |
---|---|
content | mandatory |
openLinksInNewWindow | mandatory |
The Main Component where users get to edit and run their code. To learn more about js-slang
: visit the link here
The Code Editor used here is AceEditor
and ShareAce
for Collaborative Editing.
Props | |
---|---|
content | mandatory |
breakpoints | mandatory |
editorSessionId | mandatory |
editorValue | mandatory |
highlightedLines | mandatory |
isEditorAutorun | mandatory |
newCursorPosition | mandatory |
sharedbAceInitValue | mandatory |
sharedbAceIsInviting | mandatory |
sourceChapter | mandatory |
externalLibraryName | mandatory |
sourceVariant | mandatory |
The Main Component for REPL
.
Props | |
---|---|
replValue | mandatory |
sourceChapter | mandatory |
sourceVariant | mandatory |
usingSubst | mandatory |