Commit f442140
Redesign IDE (#21)
* Add button for playground at Navbar
No functionality.
* Make first NavbarGroup's align left explicit
* Change playground icon
* Add routes to Playground
* Update test snapshots
* Fix bad test for Playground component
Oops
* Add react-ace for IDE
* Try passing props into playground
* Load a preset "Hello World" onto the ace editor.
Changes:
- Changed `Playground` component to a statefull one (extends `React.Component)
- add property `playgroundCode` to IApplicationState (bad practice,
change to a slice of the state instead)
- add interface `IPlaygroundProps` to denote the properties passed to
Playground
* Remove unused onChange()
* Add stored state for playground editor text
Once again, this is a WIP. Text typed into the playground editor will
stay in the playground (or rather, appear again) after leaving and
coming back.
Changes:
- added of action, actionCreator (updatePlaygroundCode)
- added a reducer under application's `reducer` function
Possible problems:
- Location of reducer
- Location of playgroundCode stored (as in previous commit)
* Change initialValue prop to editorValue
* Made playground actions a separate file
* Modify actions and dispatch call
* Change redux import statement
* Add IPlaygroundState to IState in index reducer
* Add playground reducer
* Remove playgroundCode from IApplicationState
* Fix type errors
Made a compromise by including an IPlaygroundState as part of IApplicationProps
* Re-disable console.logs (tslint)
* Fix missing imports for react-ace mode, theme
* Add playground CSS
* Add JSDoc style comments for playground
* Fix some tests
* Fix semantics of mapStateToProps for ApplicationContainer
* Do trivial formatting
* Add interpreter toolchain as 'slang'
This is a copy over of the current state of `./frontend/src/toolchain` at
source-academy/source-academy2 67d9184. It includes only source chapter 1, a new
specification (see [PR 6 at the
source-academy/source-academy2](source-academy/source-academy2#6)
repository).
* Add react-saga and react types to yarn
The react types were added as a result of the `yarn add` command.
* Add saga to middleware list
* Segregate actionTypes from actions
* Fix reducer actionType import
* Remove actionType import from action/index
* Fix fatal bug with defineVariable calls
* Fix missing imports
Some imports of slang are already provided as additional dependencies to other
modules, e.g. acorn is already a dependency of webpack
* Add tests for slang
* Remove unused type definitions
* Lint typescript files of slang
* Add interruption actionType
* Add sagas WIP
For ny's reference
* Add more interpreter actions
* Change to older version of saga
* Add notification file
* Change es target to es2016
This was the target in sourceacademy-2 as well. Without this, there was
a problem with casting an `IterableIterator` to `yield*`, that expected
an array.
* Revert "Remove unused type definitions"
This reverts commit e18f2ae.
"Oops" - @ningyuansg
* Fix some slang errors
* Make 16/05 code review changes
Changes not made:
- Change of `Playground` component to an `SFC`
* Fix test snapshot (name of onChange for ReactAce)
Due to 7ac707c.
* Revert Playground as SFC, make Editor container
* Make Playground stateless
This is done by abstracting out the ace editor into its own component
, `Editor`, and its own container to handle redux calls,
`EditorContainer`.
* Add test and fix export type
Export of `Editor` changed to a default export, like the other
components. A test has been added for the `Editor` component. Snapshot
changes pending.
* Fix type errors according to tslint
* Change object methods to use es6 shorthand
* Fix more linting errors for interpreter.ts
* Disable `no-empty` rule.
Rationale: A no-op function is much easier to see as `() => {}` as
compared to `() => undefined` or even `() =>`. In addition, this syntax
is used by parts of the interpreter as well.
* Add `max-classes-per-file` exception for interpreter files
Splitting the exports would cause futher refactoring in other parts of
the interpreter codebase
* Fix linting errors in parser, rules/braces...
* Fix tslint errors in `parser`
Exception was added for multiple class exports.
* Format interpreter.ts
* Fix tslint errors in rules/*
* Fix tslint errors for rttc.ts
* Fix tslint errors for node.ts
* Fix tslint errors for types.ts
* Fix stdlib/list, stdlib/misc and scheudler tslint
An additional change is the use of a line disable in `parser.ts` instead
of an entire file disable.
* Fix `saga` not being run after store creation
* Fix Editor test (tslint errors)
1. Missing comma in object props
2. Syntax error and missing object comprehension in creating Editor
* Add properties context, output to IPlaygroundState
1. context is of type slang.Context. This holds the 'environment' for the slang
interpreter
2. Output is a string array that will hold the stdout/stderr (display, error
calls) of a program run in the editor. For repl programs, it will also hold
the return value of the program. Each element of an array is a historical
output.
* Add button to call on handleEvalEditor
This change allows the newly added button to call upon the
handleEvalEditor callback, whose reducer is not defined (yet)
* Add mapDispatchToProps for EditorContainer
Note that the intersection type is used with `Pick<T>` in order to
define `DispatchProps`, this might not be ideal. Input on this issue
would be appreciated.
* Fix 'ace is undefined' error
* Add Output SFC
* Add output tests, did yarn format
* Add 'run' button to EditorContainer
* Change Editor snapshot to include button
* Wire saga interpreter success to output SFC
* Fix wrong file extension '.tsx' -> '.ts'
'Oops' - ny
* Move state definitions into their own file
Fixes #7
* Add type for interpreter outputs
In addition, tslint rule `interface-over-type-literal` was disabled, due to the need
for many types (that would not be extended)
* Fix #11, using bindActionCreators
* Add flexboxgrid dependency
* Line Editor and Output up side to side
* Refactor and modularise playground as IDE
* Change Output to Repl
This is to allow for the incoming repl, which will produce outputs as
well.
* Implement multiple Outputs in Repl (history)
* Fix class playground not taking up all of parent
* Make use of slang's toString to format values
Previously, undefined would print as '' (empty string).
* Make flexbox tags relative to current component
* Make IPlaygroundState properties readonly
Fixes #14
* Add ReplInput (not wired to saga)
* Replace TextArea with AceEditor
Also change theme to dark background so we can debug better.
* Move IDE buton to a separate Control component
This is contained within the IDE component
* Add property replValue to IPlaygroundState
replValue, like editorValue, will store the contents of repl. It is used to
allow the contents of the repl to persist through route changes. It is also the
target for evaluation.
* Make repl read from state.playground.replValue
* Add evalRepl
* Update Control snapshot with eval button
* Add action UPDATE_REPL_VALUE
* Implement persistent repl content across routes
* Did yarn format
* Add action clear repl
Also removed unnecessarily verbose typings
* Make eval button clear the replValue
* Fix repl context resetting every eval
TODO: Editor run needs to update playground context
* Add keyboard shortcut for REPL
* Fix formatting for repl shortcut
* Errors are loosely represented as string 'error'
* Fix yarn format git hooks passing for unformatted
Previously, if the staged files are not formatted according to prettier, running
the pre-commit hook would change the file formatting, and then return an exit
code 0, allowing the commit to go through. However, the changes made by prettier
are not staged.
Now, the pre-commit hook will fail, so that only prettier-passed files can be
committed.
* Add ParseError in slang
* Improve error messages to specify type of error
* Improve CSS for repl output
* Fix many error messages not printing on new lines
Thank you stackoverflow
* Fix editor not changing playground.context
* Change ParseError to a function, parseError
* Simplify REPL Output Component creation
Turns out there's a 2-arity `map` that provides index
* Rename playground css to ide
* Change Playground to IDE in ide.css
No visible change in effect. Regardless, this will probably be
refactored once SCSS is introduced
* Change "ClEAR_REPL" to "CLEAR_REPL_INPUT"
This is to differenciate between the clearing of repl input and output
* Add button and actions to clear REPL output
- Button added
- Action and reducer added
* Make the clear button wipe the REPL context
* Revert "Make clear button wipe the REPL context"
I realised that source academy does not clear the context, and that
clearing only the output is in line with most command-line applications
and REPLs.
This reverts commit 4bd3c44.
* Remove duplicate EditorContainer
Was received from merging master into the branch
* Fix button row in playground overflowing to right
Would cause tiny bit of empty space on the right of the page, slightly outside
the viewport.
* Fix padding issues with ReplInput
* Remove the Playground title
* Increase font size of ace-editor (12 -> 14)
* Make IDE content responsive with viewport height
* Replace css with scss
Resolves #5.
* Make all the stuff partials
* Fix playground width being tied to viewport height
* Fix playground overflowing out of viewport
* Make .pt-card child of .Repl
* Make Repl scrollable
* Make run button clearReplOutput, remove default
* Add dark theme for Application
This includes a dark background, and adding the `pt-dark` class to
enable dark themes for all Blueprint components. Note that a relative
path to blueprint was used for the background color, to be changed in
the next commit.
* Output code typed in ReplInput as Output
* Use array method concat, reorder definitions
Readability changes.
* Change import for scss file in node_modules
This is becase ["The `~` notation is webpack-specific"](facebook/create-react-app#2859) and we should use `node_modules` to refer to the sass file instead.
* Rename IDE/Control to IDE/ReplControl
Skipped checks
* Change internals of ReplControl
from the names and functionality of `Control` to `ReplControl`.
Skipped checks
* Add ReplControlContainer to main Repl component
* Add run button to IDE/Editor
* Fix layout and tests
* No verify commit, tests fails
* Fix failing tests
Okay, so slang's display needs access to the store in order to call dispatch, so
that the display can be output'd in realtime. In the previous commit, this was
achieved by importing the instantiated store from src/index.tsx into
src/slang/stdlib/misc.ts.
This works when the full server is running, but fails with the tests, because
mockContext calls createContext, which imports stdlib/misc, which tries to
import store. But because it's just a test, and store doesn't exist, the test
fails.
* Make run button interrupt execution
* Make eval interrupt execution, remove notifs
Next, change display so that if playground.output array is empty, initialise.
* Fix display not working after a clear
* Make buttons minimal
* Fix Eval button crashing site when Output[] empty
This is because the Output SFC tries to access an undefined output.consoleLogs.
output.consoleLogs is undefined after an Eval button click, because
EVAL_INTERPRETER_(SUCCESS|ERRORS) will try to access the last element of
playground.outputs, but the last element after playground.outputs is always a
CodeOutput for Eval button presses; and CodeOutput doesn't have a consoleLogs
property, so EVAL_INTERPRETER_(SUCCESS|ERRORS) copies over undefined as the new
ResultOutput or ErrorOutput's consoleLog property.
* Refactor display interactions with react/redux
* Fix react-ace editor overflowing
* Fix Application not taking up full height
* Make REPL input same length as output cards
* Increment repl input min line
* Change react-ace theme
* Change background and navbar colors
* Make margin changes
* Make IDE and background colors more consistent
* Add color palette
* Nest all output in code tags
* Use new colors in cards
* Decrease minLines to 1
* Fix alignment for button groups
* Add editor border radius
* Remove faint border around code tags
* Make REPL scroll only Outputs, not buttons
* Fix firefox overflow issue with REPL
* Add different colours for each output type
* Make editor parent Resizable
* Fix repl input being hidden
This probably caused by not using `col-number-xs` for the repl-parent anymore,
due to the resizing.
* Align REPL input with editor bottom
* Re-add fix for Firefox
* Disable resize for directions other than right
* Add persistent state for resizable editor width
Note that handleEditorChange has been modified to
handleEditorValueChange, to be clearer when comapring to
handleEditorWidthChange.
* Fix white color when scrolling beyond page
* Put eval, clear buttons in control group
* Fix repl output not wrapping
* Make IDE component contain Resizable
Note that this make the IDE/index component stateful, handling the
editor width.
* Change editorWidth to percentage
This means that the change in width (in pixels) would need to be
converted to a percentage change (in the component) and the string must
be converted, added to the percentage change, then parsed again. A
possble optimization is keeping the number as a float (which would
involve one parse when passing it as a prop). However, I find it
semantically cleaner to keep the `editorWidth` as a string that expresses
a percentage, as compared to an `editorWidthPercentage` that holds a
number.
* Remove duplicate Editor
* Move run button to the left
* Add maxWidth for Resizable editor-parent
This is set to be the same as the default minWidth, 10px.
* Modify updateEditorWidth to changeEditorWidth
* Fix extra space between 2 pre elements
* Add in library select button
Missed it out in the previous merge commit, as I deleted the IDE/Control component #oops
* Add minor format change1 parent a5aae47 commit f442140
File tree
38 files changed
+849
-340
lines changed- src
- actions
- components
- IDE
- __tests__
- __snapshots__
- __tests__
- __snapshots__
- containers/IDE
- reducers
- sagas
- styles
38 files changed
+849
-340
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | | - | |
16 | | - | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | | - | |
19 | | - | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| 37 | + | |
33 | 38 | | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | | - | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
20 | 49 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
29 | 71 | | |
30 | 72 | | |
31 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
31 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
34 | 48 | | |
35 | 49 | | |
36 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
40 | | - | |
| 58 | + | |
| 59 | + | |
41 | 60 | | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
45 | 64 | | |
46 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
47 | 70 | | |
48 | 71 | | |
49 | 72 | | |
50 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
51 | 76 | | |
52 | 77 | | |
53 | 78 | | |
| |||
0 commit comments