create-vanjs
Version:
🍦 Quick tool for scaffolding your first VanJS project
74 lines (70 loc) • 2.05 kB
JSX
import { Meta, Title } from "@vanjs/meta";
import { useRouteData } from "@vanjs/router";
import { getCategories } from "@/api";
export const route = {
load: async (_params) => {
return await getCategories();
},
};
export const Page = () => {
Title("Categories");
Meta({ name: "description", content: "Categories description" });
const data = useRouteData();
return [
<div class="h-screen">
<div class="p-4 m-auto">
<h1 class="text-5xl font-bold my-8">Categories</h1>
<div class="overflow-x-auto">
<table class="table">
<thead>
<tr>
<th>
<label>
<input type="checkbox" class="checkbox" />
</label>
</th>
<th>Title</th>
<th>Author</th>
<th>Details</th>
</tr>
</thead>
<tbody>
{(data || []).map((cat) => (
<tr>
<th>
<label>
<input type="checkbox" class="checkbox" />
</label>
</th>
<td>
<div class="flex items-center gap-3">
<div>
<div class="font-bold">{cat.title}</div>
</div>
</div>
</td>
<td>
<span class="badge badge-ghost badge-sm">{cat.author}</span>
</td>
<th>
<button type="button" class="btn btn-ghost btn-xs">
details
</button>
</th>
</tr>
))}
</tbody>
<tfoot>
<tr>
<th></th>
<th>Title</th>
<th>Author</th>
<th>Details</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>,
];
};