Skip to content

Commit 039218e

Browse files
committed
added get started view
1 parent 37f3463 commit 039218e

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

src/components/NavBar/navbar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import logo from "../../static/logo.svg";
1616
const links = [
1717
{
1818
title: "Getting Started",
19-
link: "/getting-started",
19+
link: "/",
2020
},
2121
{
2222
title: "Demo",
@@ -36,14 +36,14 @@ export default function NavBar() {
3636
const history = useHistory();
3737
const { pathname } = history.location;
3838
const [openDrawer, setOpenDrawer] = useState(false);
39-
const [active, setActive] = useState("/getting-started");
39+
const [active, setActive] = useState("/");
4040

4141
const handleDrawer = () => {
4242
setOpenDrawer(() => !openDrawer);
4343
};
4444
useEffect(() => {
45-
if (pathname.includes("getting-started" || pathname === "/")) {
46-
setActive("/getting-started");
45+
if (pathname === "/") {
46+
setActive("/");
4747
}
4848
if (pathname.includes("demo")) {
4949
setActive("/demo");

src/pages/home/home.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { useState, useReducer } from "react";
2+
import Cell from "../../Cell";
3+
import { reducer } from "../../reducer";
4+
import { downLoad_notebook, load_notebook } from "../../utils";
5+
import Header from "../../components/header/header";
6+
7+
const defaultState = {
8+
cells: [{ id: "cell_1", input: "", output: "", type: "code" }],
9+
};
10+
11+
export default function Home() {
12+
const [state, dispatch] = useReducer(reducer, defaultState);
13+
const [currentCell, setCurrentCell] = useState(null);
14+
const [activeCell, setActiveCell] = useState(1);
15+
const load = () => load_notebook(dispatch);
16+
const download = (name) => downLoad_notebook(state, name);
17+
return (
18+
<div>
19+
<Header download={download} load={load} />
20+
{state.cells.map((cell, index) => {
21+
return (
22+
<Cell
23+
key={cell.id}
24+
cell={cell}
25+
dispatch={dispatch}
26+
currentCell={currentCell}
27+
setCurrentCell={setCurrentCell}
28+
cellId={index + 1}
29+
activeCell={activeCell}
30+
setActiveCell={setActiveCell}
31+
/>
32+
);
33+
})}
34+
</div>
35+
);
36+
}

src/routes/routes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Route, Switch } from "react-router-dom";
33

44
const Demo = lazy(() => import("../pages/demo/demo"));
55
const About = lazy(() => import("../pages/about/about"));
6+
const Home = lazy(() => import("../pages/home/home"));
67

78
export default function Routes() {
89
return (
910
<Suspense fallback={<div>loading</div>}>
1011
<Switch>
12+
<Route exact component={Home} path="/" />
1113
<Route exact component={Demo} path="/demo" />
1214
<Route exact component={About} path="/about" />
1315
</Switch>

0 commit comments

Comments
 (0)