tangled
alpha
login
or
join now
olaren.dev
/
washing-machine
0
fork
atom
washes u
0
fork
atom
overview
issues
pulls
pipelines
feat: proper routing between pages
olaren.dev
1 month ago
5e86d483
27c93a75
+52
-22
4 changed files
expand all
collapse all
unified
split
src
Home.tsx
Wash.tsx
components
Layout.tsx
index.tsx
+17
-20
src/Home.tsx
···
16
16
};
17
17
18
18
return (
19
19
-
<div class="max-w-xl w-full p-5">
20
20
-
<h1 class="text-3xl font-bold mb-10">Washing Machine</h1>
21
21
-
<form class="flex-row" on:submit={onSubmit}>
22
22
-
<label for="handle" class="text-neutral-500 text-sm">
23
23
-
Handle
24
24
-
</label>
25
25
-
<div class="flex text-xl">
26
26
-
<input
27
27
-
name="handle"
28
28
-
required
29
29
-
autofocus
30
30
-
class="bg-slate-300 p-2 w-full"
31
31
-
type="search"
32
32
-
/>
33
33
-
<button class="bg-slate-800 text-neutral-200 py-2 px-4" type="submit">
34
34
-
Wash
35
35
-
</button>
36
36
-
</div>
37
37
-
</form>
38
38
-
</div>
19
19
+
<form class="flex-row" on:submit={onSubmit}>
20
20
+
<label for="handle" class="text-neutral-500 text-sm">
21
21
+
Handle
22
22
+
</label>
23
23
+
<div class="flex text-xl">
24
24
+
<input
25
25
+
name="handle"
26
26
+
required
27
27
+
autofocus
28
28
+
class="bg-slate-300 p-2 w-full"
29
29
+
type="search"
30
30
+
/>
31
31
+
<button class="bg-slate-800 text-neutral-200 py-2 px-4" type="submit">
32
32
+
Wash
33
33
+
</button>
34
34
+
</div>
35
35
+
</form>
39
36
);
40
37
};
41
38
+15
src/Wash.tsx
···
1
1
+
// @ts-types="solid-js"
2
2
+
import { Component } from "solid-js";
3
3
+
import { useParams } from "@solidjs/router";
4
4
+
5
5
+
const Wash: Component = () => {
6
6
+
const params = useParams();
7
7
+
8
8
+
return (
9
9
+
<div>
10
10
+
<p>Washing {params.handle} :3</p>
11
11
+
</div>
12
12
+
);
13
13
+
};
14
14
+
15
15
+
export default Wash;
+16
src/components/Layout.tsx
···
1
1
+
// @ts-types="solid-js"
2
2
+
import { Component } from "solid-js";
3
3
+
import { A, RouteSectionProps } from "@solidjs/router";
4
4
+
5
5
+
const Layout: Component<RouteSectionProps> = (props) => {
6
6
+
return (
7
7
+
<div class="max-w-xl w-full p-5">
8
8
+
<A href="/">
9
9
+
<h1 class="text-3xl font-bold mb-10">Washing Machine</h1>
10
10
+
</A>
11
11
+
{props.children}
12
12
+
</div>
13
13
+
);
14
14
+
};
15
15
+
16
16
+
export default Layout;
+4
-2
src/index.tsx
···
5
5
6
6
import Home from "./Home.tsx";
7
7
import { Route, Router } from "@solidjs/router";
8
8
+
import Wash from "./Wash.tsx";
9
9
+
import Layout from "./components/Layout.tsx";
8
10
9
11
const root = document.getElementById("root");
10
12
···
16
18
17
19
render(
18
20
() => (
19
19
-
<Router>
21
21
+
<Router root={Layout}>
20
22
<Route path="/" component={Home} />
21
21
-
<Route path="/wash/:handle" component={() => <p>:3</p>} />
23
23
+
<Route path="/wash/:handle" component={Wash} />
22
24
</Router>
23
25
),
24
26
root!,