Skip to content

Commit bd69513

Browse files
committed
refactor(ui): use viewTransition for revealing the sidebar content
1 parent e8a653d commit bd69513

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/routers/app/hx-router.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.get("/sidebar-organizations", checkUserAuthed, async (c) => {
1414

1515
// DO NOT USE THIS PARAMETER FOR AUTH
1616
// THIS IS PURELY BEING USED FOR STYLING
17-
const workspace = c.req.query("current_workspace") || "";
17+
const style_workspace = c.req.query("style_current_workspace") || "";
1818

1919
const relationships = await db.query.usersToTenants.findMany({
2020
where: (fields, { eq }) => eq(fields.userId, user.id),
@@ -23,7 +23,7 @@ app.get("/sidebar-organizations", checkUserAuthed, async (c) => {
2323

2424
const tenants = relationships.map((r) => r.tenant);
2525

26-
return c.html(<SidebarOrganizations workspace={workspace} tenants={tenants} />);
26+
return c.html(<SidebarOrganizations workspace={style_workspace} tenants={tenants} />);
2727
});
2828

2929
export default app;
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import type { FC, PropsWithChildren } from "hono/jsx";
2-
import { User } from "lucia";
2+
import type { User } from "lucia";
33

44
export interface AppContainerProps {
55
user: User;
66
workspace: string;
77
mainClass?: string;
88
}
99

10-
export const AppContainer: FC<PropsWithChildren<AppContainerProps>> = (props) => {
11-
const { user, children, mainClass } = props;
12-
10+
export const AppContainer: FC<PropsWithChildren<AppContainerProps>> = ({ user, children, mainClass, workspace }) => {
1311
return (
1412
<div class="flex flex-col md:grid md:grid-cols-4 lg:grid-cols-5 min-h-full">
1513
<aside class="h-[250px] border-b flex flex-col bg-gray-100 dark:bg-gray-800 md:h-auto md:col-span-1 md:border-r md:border-b-0">
1614
<div class="flex-grow p-2">
1715
<p class="pb-2">Hello {user.username}!</p>
1816
<p class="pb-2 border-b">Your organizations</p>
19-
<SidebarFetcher {...props} />
17+
<SidebarFetcher workspace={workspace} />
2018
<span class="border-t" />
2119
</div>
2220
<div class="p-2">
@@ -28,11 +26,10 @@ export const AppContainer: FC<PropsWithChildren<AppContainerProps>> = (props) =>
2826
);
2927
};
3028

31-
const SidebarFetcher: FC<Pick<AppContainerProps, "user" | "workspace">> = ({ user, workspace }) => {
32-
return (
33-
<div
34-
hx-trigger="load"
35-
hx-get={["/app/hx/sidebar-organizations", workspace.length > 0 ? `?current_workspace=${workspace}` : ""].join("")}
36-
></div>
37-
);
29+
const SidebarFetcher: FC<{ workspace: string }> = ({ workspace }) => {
30+
const params = new URLSearchParams();
31+
params.append("style_current_workspace", workspace);
32+
33+
const getUrl = `/app/hx/sidebar-organizations?${params.toString()}`;
34+
return <div hx-get={getUrl} hx-trigger="load" hx-swap="innerHTML transition:true" />;
3835
};

0 commit comments

Comments
 (0)