Added Routes
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import type { Component } from 'solid-js';
|
||||
|
||||
import type { Component } from "solid-js";
|
||||
import AppRouter from "./routes";
|
||||
|
||||
const App: Component = () => {
|
||||
return (
|
||||
<p>Solid INIT</p>
|
||||
);
|
||||
return <AppRouter />;
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
/* @refresh reload */
|
||||
import { render } from 'solid-js/web';
|
||||
import { render } from "solid-js/web";
|
||||
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import "./index.css";
|
||||
import App from "./App";
|
||||
import { Router } from "@solidjs/router";
|
||||
|
||||
render(() => <App />, document.getElementById('main-container') as HTMLElement);
|
||||
render(
|
||||
() => (
|
||||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
),
|
||||
document.getElementById("main-container") as HTMLElement
|
||||
);
|
||||
|
||||
21
src/routes/index.tsx
Normal file
21
src/routes/index.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Route, Routes } from "@solidjs/router";
|
||||
import { Component, lazy } from "solid-js";
|
||||
|
||||
const Home = lazy(() => import("./views/home/Home"));
|
||||
const AuthLayout = lazy(() => import("./views/auth/AuthLayout"));
|
||||
const Login = lazy(() => import("./views/auth/Login"));
|
||||
const Register = lazy(() => import("./views/auth/Register"));
|
||||
|
||||
const AppRouter: Component = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />}></Route>
|
||||
<Route path="/auth" element={<AuthLayout />}>
|
||||
<Route path="/login" element={<Login />}></Route>
|
||||
<Route path="/register" element={<Register />}></Route>
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppRouter;
|
||||
13
src/routes/views/MainLayout.tsx
Normal file
13
src/routes/views/MainLayout.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
interface MainViewProps {
|
||||
// add props here
|
||||
}
|
||||
|
||||
function MainView(props: MainViewProps) {
|
||||
return (
|
||||
<div>
|
||||
<h2>MainView</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MainView;
|
||||
16
src/routes/views/auth/AuthLayout.tsx
Normal file
16
src/routes/views/auth/AuthLayout.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { Component } from "solid-js";
|
||||
import { Outlet } from "@solidjs/router";
|
||||
|
||||
const AuthLayout: Component = () => {
|
||||
return (
|
||||
<div>
|
||||
<header>Head</header>
|
||||
<div>
|
||||
<Outlet />
|
||||
</div>
|
||||
<footer>Footer</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AuthLayout;
|
||||
10
src/routes/views/auth/Login.tsx
Normal file
10
src/routes/views/auth/Login.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Component } from "solid-js";
|
||||
const Login: Component = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Login</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Login;
|
||||
10
src/routes/views/auth/Register.tsx
Normal file
10
src/routes/views/auth/Register.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Component } from "solid-js";
|
||||
const Register: Component = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Register</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Register;
|
||||
11
src/routes/views/home/Home.tsx
Normal file
11
src/routes/views/home/Home.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { Component } from "solid-js";
|
||||
|
||||
const Home: Component = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Home</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Home;
|
||||
Reference in New Issue
Block a user