Skip to content

Commit

Permalink
[#78] Use Layout Router to render layouts for each component.
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Nov 5, 2024
1 parent babf4a9 commit 29b41ea
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
16 changes: 9 additions & 7 deletions src/Router.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from "react";
import { Routes, BrowserRouter, Route } from "react-router-dom";
import Layout from "./components/Layout.jsx";
import Home from "./components/Home.jsx";
import Scripts from "./components/Scripts.jsx";
import Executions from "./components/Executions.jsx";
import NoMatch from "./components/NoMatch.jsx";
import Scripts from "./components/Scripts.jsx";
import Dagre from "./components/dagre/Dagre.jsx";
import NoMatch from "./components/NoMatch.jsx";
import Layout from "./components/Layout.jsx";

const Router = () => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="scripts" element={<Scripts />} />
<Route path="executions" element={<Executions />} />
<Route path="*" element={<NoMatch />} />
<Route element={<Layout />}>
<Route path="/" element={<Home />} />
<Route path="scripts" element={<Scripts />} />
<Route path="executions" element={<Executions />} />
<Route path="*" element={<NoMatch />} />
</Route>
<Route path="script" element={<Dagre />} />
</Routes>
</BrowserRouter>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Executions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Executions extends React.Component {
return <h3>Loading</h3>;
} else {
return (
<Layout>
<>
<h3>Executions</h3>
<Table striped bordered hover>
<thead>
Expand Down Expand Up @@ -89,7 +89,7 @@ class Executions extends React.Component {
})}
</tbody>
</Table>
</Layout>
</>
);
}
}
Expand Down
20 changes: 9 additions & 11 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import { Link } from "react-router-dom";
class Home extends React.Component {
render() {
return (
<Layout>
<Grid stackable columns={2}>
<Grid.Row>
<Grid.Column>
<h1>Welcome to SPipes editor</h1>
<br></br>
<ScriptsTree />
</Grid.Column>
</Grid.Row>
</Grid>
</Layout>
<Grid stackable columns={2}>
<Grid.Row>
<Grid.Column>
<h1>Welcome to SPipes editor</h1>
<br></br>
<ScriptsTree />
</Grid.Column>
</Grid.Row>
</Grid>
);
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { Container, Icon } from "semantic-ui-react";
import { Nav, Navbar } from "react-bootstrap";
import NavbarMenu from "./NavbarMenu";

import { Outlet } from "react-router-dom";

const Layout = ({ children }) => {
return (
<div>
<NavbarMenu />

<Container>{children}</Container>

<Container>
<Outlet />
</Container>
<div className="fixed-bottom">
<Navbar color="dark">
<Container>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NoMatch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Layout from "./Layout";

const NoMatch = () => {
return (
<Layout>
<>
<Icon name="minus circle" size="big" />
<strong>Page not found!</strong>
</Layout>
</>
);
};

Expand Down
16 changes: 7 additions & 9 deletions src/components/Scripts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { Link } from "react-router-dom";
class Scripts extends React.Component {
render() {
return (
<Layout>
<Grid stackable columns={2}>
<Grid.Row>
<Grid.Column>
<ScriptsTree />
</Grid.Column>
</Grid.Row>
</Grid>
</Layout>
<Grid stackable columns={2}>
<Grid.Row>
<Grid.Column>
<ScriptsTree />
</Grid.Column>
</Grid.Row>
</Grid>
);
}
}
Expand Down

0 comments on commit 29b41ea

Please sign in to comment.