Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.

Commit e3a5bae

Browse files
authored
Demo (#26)
* js-slang version revert * Bug-fixed
1 parent 4149350 commit e3a5bae

File tree

10 files changed

+111
-62
lines changed

10 files changed

+111
-62
lines changed

package-lock.json

+23-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"@types/testing-library__react": "^9.1.3",
2222
"ace-builds": "^1.4.8",
2323
"axios": "^0.19.2",
24-
"gh-pages": "^2.2.0",
2524
"js-slang": "^0.4.30",
2625
"lz-string": "^1.4.4",
2726
"re-resizable": "^6.3.2",
2827
"react": "^16.13.1",
2928
"react-ace": "^8.1.0",
3029
"react-app-rewired": "^2.1.5",
3130
"react-dom": "^16.12.0",
31+
"react-hotkeys": "^2.0.0",
3232
"react-resizable": "^1.10.1",
3333
"react-router-dom": "^5.1.2",
3434
"react-scripts": "^3.4.0",
@@ -38,9 +38,9 @@
3838
"xmlhttprequest-ts": "^1.0.1"
3939
},
4040
"scripts": {
41+
"start": "react-app-rewired start",
4142
"predeploy": "npm run build",
4243
"deploy": "gh-pages -d build",
43-
"start": "react-app-rewired start",
4444
"build": "react-app-rewired build",
4545
"test": "react-app-rewired test",
4646
"eject": "react-scripts eject"
@@ -64,6 +64,7 @@
6464
"react-dev-utils": "10.1.0"
6565
},
6666
"devDependencies": {
67-
"@types/react-resizable": "^1.7.2"
67+
"@types/react-resizable": "^1.7.2",
68+
"gh-pages": "^2.2.0"
6869
}
6970
}

src/NavBar/NavBar.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ import Grid from "@material-ui/core/Grid";
1818
*/
1919

2020
let sourceOptions: string[] = ["Source1", "Source2", "Source3", "Source4"];
21-
let timeOptions: string[] = [
22-
"壹千",
23-
"貳千",
24-
"參千",
25-
"肆千",
26-
"伍千",
27-
"zehntausend",
28-
];
21+
let timeOptions: string[] = ["1000", "2000", "3000", "4000", "5000", "10000"];
2922

3023
const NavBar: React.FC = () => {
3124
const { state, dispatch } = useContext(SideBarContext);

src/NavBar/RunButton.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const RunButton: React.FC = () => {
2727
: 1;
2828

2929
const runTime =
30-
globalState.time === "zehntausend"
30+
globalState.time === "10000"
3131
? 10000
32-
: globalState.time === "貳千"
32+
: globalState.time === "2000"
3333
? 2000
34-
: globalState.time === "參千"
34+
: globalState.time === "3000"
3535
? 3000
36-
: globalState.time === "肆千"
36+
: globalState.time === "4000"
3737
? 4000
38-
: globalState.time === "伍千"
38+
: globalState.time === "5000"
3939
? 5000
4040
: 1000;
4141
const context: Context = createContext(source);

src/NavBar/SideBar/index.tsx

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from "react";
22

3+
import SessionControl from "./../SessionControl";
4+
35
import "./index.css";
46
import SideBarDropDownTemplate from "./SideBarDropDownTemplate";
57
/**
@@ -39,27 +41,13 @@ const SideBar: React.FC<sideBarProps> = (sideBarProps) => {
3941
/>
4042
</li>
4143
<li>
42-
<SideBarDropDownTemplate
43-
dropDownType="CHANGE_LIBRARY"
44-
options={libraryOptions}
45-
sideBarString={"library"}
46-
/>
47-
</li>
48-
<li>
49-
<SideBarDropDownTemplate
50-
dropDownType="CHANGE_LANGUAGE"
51-
options={languageOptions}
52-
sideBarString={"language"}
53-
/>
54-
</li>
55-
<li>
56-
<a href="/">TextBook</a>
44+
<a>TextBook</a>
5745
</li>
5846
<li>
59-
<a href="/">Run</a>
47+
<SessionControl />
6048
</li>
6149
<li>
62-
<a href="/">Share</a>
50+
<a>Share</a>
6351
</li>
6452
</ul>
6553
</nav>

src/Workspace/BottomBar/PhoneRunButton.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ const PhoneRunButton: React.FC = () => {
4242
} else if (result.status === "finished") {
4343
if (globalState.useStepper) {
4444
const stepperComponents: React.ReactElement[] = result.value.map(
45-
(x: any) => <div>{codify(x)}</div>
45+
(x: any) => (
46+
<div>
47+
{codify(x)
48+
.split("\n")
49+
.map((x) => (
50+
<h5>{x}</h5>
51+
))}
52+
</div>
53+
)
4654
);
47-
console.log(stepperComponents);
4855
return dispatch({
4956
type: "RUNSTEPPER",
5057
stepperComponents: stepperComponents,

src/Workspace/BottomBar/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useContext } from "react";
22
import { createStyles, Theme, makeStyles } from "@material-ui/core/styles";
33
import AppBar from "@material-ui/core/AppBar";
44
import Toolbar from "@material-ui/core/Toolbar";
@@ -9,6 +9,7 @@ import SportsEsportsIcon from "@material-ui/icons/SportsEsports";
99
import DeveloperModeIcon from "@material-ui/icons/DeveloperMode";
1010
import TextsmsIcon from "@material-ui/icons/Textsms";
1111
import PhoneRunButton from "./PhoneRunButton";
12+
import { Store } from "./../../reducers/Store";
1213

1314
interface completeNavBarProps {}
1415

@@ -37,12 +38,13 @@ const useStyles = makeStyles((theme: Theme) =>
3738
);
3839

3940
const BottomBar: React.FC<completeNavBarProps> = (completeNavBarProps) => {
41+
const { globalState } = useContext(Store);
4042
const classes = useStyles();
4143
return (
4244
<>
4345
<AppBar position="fixed" className={classes.appBar}>
4446
<Toolbar>
45-
<div className={classes.flex} />
47+
{/*<div className={classes.flex} />
4648
<Link href="#main-editor" className={classes.flex}>
4749
<IconButton className={classes.buttons}>
4850
<SportsEsportsIcon />
@@ -57,9 +59,12 @@ const BottomBar: React.FC<completeNavBarProps> = (completeNavBarProps) => {
5759
<IconButton className={classes.buttons}>
5860
<TextsmsIcon />
5961
</IconButton>
60-
</Link>
62+
</Link>*/}
6163
<div className={classes.flex} />
62-
<Link href="#repl" className={classes.flex}>
64+
<Link
65+
href={globalState.useStepper ? "#question" : "#repl"}
66+
className={classes.flex}
67+
>
6368
<Fab
6469
color="secondary"
6570
aria-label="add"

src/Workspace/Description/index.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import EnvVisualizer from "./EnvVisualizer";
1414
import Inspector from "./Inspector";
1515
import TabStyle from "./TabStyle";
1616
import AspectRatioIcon from "@material-ui/icons/AspectRatio";
17-
import RunePanel from "./Panel";
17+
import Panel from "./Panel";
1818
import { Store, IGlobalAction } from "../../reducers/Store";
1919

2020
const useStyles = makeStyles({
@@ -55,41 +55,41 @@ export default function Description() {
5555
let tabContentArr: JSX.Element[];
5656
if (globalState.source === "Source3" || globalState.source === "Source4") {
5757
tabButtonArr = [
58-
<AspectRatioIcon />,
5958
<ImportContactsIcon />,
59+
<AspectRatioIcon />,
6060
<VisibilityIcon />,
6161
<SearchIcon />,
6262
<PublicIcon />,
6363
];
6464
tabContentArr = [
65-
<RunePanel />,
6665
<IntroductionTab />,
66+
<Panel />,
6767
<ListVisualizer />,
6868
<Inspector />,
6969
<EnvVisualizer />,
7070
];
7171
} else if (globalState.source === "Source2") {
7272
tabButtonArr = [
73-
<AspectRatioIcon onClick={closeStepper} />,
7473
<ImportContactsIcon onClick={closeStepper} />,
74+
<AspectRatioIcon onClick={closeStepper} />,
7575
<VisibilityIcon onClick={closeStepper} />,
7676
<SettingsEthernetIcon onClick={toggleStepper} />,
7777
];
7878
tabContentArr = [
79-
<RunePanel />,
8079
<IntroductionTab />,
80+
<Panel />,
8181
<ListVisualizer />,
8282
<SubstVisualizer content={["function", "f(x)"]} />,
8383
];
8484
} else {
8585
tabButtonArr = [
86-
<AspectRatioIcon onClick={closeStepper} />,
8786
<ImportContactsIcon onClick={closeStepper} />,
87+
<AspectRatioIcon onClick={closeStepper} />,
8888
<SettingsEthernetIcon onClick={toggleStepper} />,
8989
];
9090
tabContentArr = [
91-
<RunePanel />,
9291
<IntroductionTab />,
92+
<Panel />,
9393
<SubstVisualizer content={["function", "f(x)"]} />,
9494
];
9595
}

src/Workspace/REPL/EvalButton.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import CardContent from "@material-ui/core/CardContent";
1616
*/
1717
interface evalButtonProps {
1818
code: string;
19+
setHistory: (x: number) => void;
1920
}
2021
const context: Context = createContext(4);
2122

@@ -33,7 +34,9 @@ const EvalButton: React.FC<evalButtonProps> = (props) => {
3334
}
3435

3536
const evaluate = async () => {
37+
//handleRun update the code to global container first
3638
handleRun();
39+
props.setHistory(globalState.replValue.length - 1);
3740
const code: string = conbineCode();
3841
return await runInContext(code, context, {
3942
scheduler: "preemptive",

0 commit comments

Comments
 (0)