Skip to content

Commit

Permalink
feat: enhance sidebar and layout components; implement LoadingPage fo…
Browse files Browse the repository at this point in the history
…r better user experience
  • Loading branch information
jhnnsrs committed Feb 28, 2025
1 parent 435a807 commit dfe1455
Show file tree
Hide file tree
Showing 13 changed files with 1,144 additions and 142 deletions.
5 changes: 4 additions & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ function openSecondaryWindow(path: string): void {
// HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production.
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
secondaryWindow.loadURL(process.env["ELECTRON_RENDERER_URL"] + path);

let loaded_url = process.env["ELECTRON_RENDERER_URL"] + "#" + path;
console.log("Loading URL", loaded_url);
secondaryWindow.loadURL(loaded_url);
} else {
secondaryWindow
.loadFile(join(__dirname, "../renderer/index.html"))
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.5",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-icons": "^1.3.0",
Expand All @@ -70,16 +70,16 @@
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-toolbar": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.3",
"@radix-ui/react-tooltip": "^1.1.8",
"@radix-ui/react-visually-hidden": "^1.1.0",
"@react-three/drei": "^9.108.3",
"@react-three/fiber": "^8.16.8",
Expand Down Expand Up @@ -133,7 +133,7 @@
"any-signal": "^4.1.1",
"aws4fetch": "^1.0.17",
"blurhash": "^2.0.5",
"class-variance-authority": "^0.7.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"color-2-name": "^1.4.4",
Expand Down Expand Up @@ -164,7 +164,7 @@
"input-otp": "^1.2.4",
"livekit-client": "^2.3.2",
"localforage": "^1.10.0",
"lucide-react": "^0.475.0",
"lucide-react": "^0.476.0",
"match-sorter": "^6.3.1",
"next-themes": "^0.3.0",
"prismjs": "^1.29.0",
Expand Down
25 changes: 25 additions & 0 deletions src/app/components/fallbacks/LoadingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PageLayout } from "@/components/layout/PageLayout";
import { Alert } from "@/components/ui/alert";
import { Card } from "@/components/ui/card";
import { ApolloError } from "@apollo/client/errors";

export const LoadingPage = (props) => {
return (
<div className="h-full w-full relative">
<PageLayout title="Loading">
<div className="items-center justify-center h-full w-full flex flex-col">

</div>
</PageLayout>
<div className="absolute top-0 left-0 w-full h-full backdrop-blur-sm z-50">
<div className="flex items-center justify-center h-full">
<Card className="p-4">
<div className="animate-spin w-6 h-6 border-4 border-primary border-t-transparent rounded-full" />
</Card>
</div>


</div>
</div>
);
};
7 changes: 5 additions & 2 deletions src/app/routes/DetailQueryRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React from "react";
import { useParams } from "react-router-dom";
import { DebugPage } from "../components/fallbacks/DebugPage";
import { ErrorPage } from "../components/fallbacks/ErrorPage";
import { LoadingPage } from "../components/fallbacks/LoadingPage";

export type DetailVariables = {
id: string;
Expand Down Expand Up @@ -84,7 +85,7 @@ export const asDetailQueryRoute = <T extends any>(
}
}

const { data, error, refetch, subscribeToMore } = hook({
const { data, error, refetch, loading, subscribeToMore } = hook({
variables: { id: id },
...options.queryOptions,
});
Expand All @@ -93,6 +94,9 @@ export const asDetailQueryRoute = <T extends any>(
return <ErrorPage error={error} />;
}

if (loading)
return <LoadingPage/>;

if (data) {
if (debug) {
return <DebugPage data={data} />;
Expand All @@ -107,6 +111,5 @@ export const asDetailQueryRoute = <T extends any>(
);
}

return <> Loadding ...</>;
};
};
2 changes: 1 addition & 1 deletion src/components/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const AppLayout = ({ children, navigationBar }: AppLayoutProps) => {

return (
<div className="flex flex-col h-screen sm:flex-row bg-background dark:text-white">
<div className="flex-initial flex flex-row md:flex-col mt-1 z-10 md:w-[60px] shadow shadow-xl bg-background">
<div className="flex-initial md:flex-col mt-1 z-10 md:w-[60px] shadow shadow-xl bg-background hidden md:block">
<div className="flex-initial h-12 w-12 border-b-gray-600 mt-2 mx-auto my-auto md:block hidden">
<div onClick={onClick} className="cursor-pointer">
{location.pathname == "/" ? (
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout/ModuleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ModuleLayout = ({ pane, children }: ModuleLayoutProps) => {
<ResizablePanel
defaultSize={10}
className="border-r dark:border-gray-700 bg-sidebar"
id="sidebar"
>
<ScrollArea className="flex flex-col h-full overflow-y-hidden">
{pane}
Expand All @@ -30,7 +31,7 @@ export const ModuleLayout = ({ pane, children }: ModuleLayoutProps) => {
</>
)}

<ResizablePanel defaultSize={90}>{children}</ResizablePanel>
<ResizablePanel defaultSize={90} id="module">{children}</ResizablePanel>
</ResizablePanelGroup>
);
};
12 changes: 10 additions & 2 deletions src/components/layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
ResizablePanelGroup,
} from "../ui/resizable";
import { Actionbar } from "./Actionbar";
import { Separator } from "@radix-ui/react-dropdown-menu";
import { PanelLeft } from "lucide-react";

export type PageVariant = "black" | "default";

Expand Down Expand Up @@ -63,7 +65,7 @@ export const PageLayout = ({

return (
<ResizablePanelGroup autoSaveId="page" direction="horizontal">
<ResizablePanel className="" defaultSize={80}>
<ResizablePanel className="" defaultSize={80} id="page">
<div
className={cn(
"h-full w-full flex flex-col relative",
Expand All @@ -78,7 +80,13 @@ export const PageLayout = ({
: "border-0 bg-black bg-clip-padding backdrop-filter backdrop-blur-3xl bg-opacity-20 ",
)}
>
<div className="flex flex flex-col">
<Button onClick={toggleSidebar} variant={"ghost"}>
<PanelLeft />
<span className="sr-only">Toggle Sidebar</span>
</Button>
<Separator dir="vertical" className="w-2"/>
<div className="flex-grow flex flex-col">

<h1 className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-2xl truncate">
{title}
</h1>
Expand Down
45 changes: 22 additions & 23 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils";
import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-2 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
);
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
},
);
Button.displayName = "Button";
)
}
)
Button.displayName = "Button"

export { Button, buttonVariants };
export { Button, buttonVariants }
Loading

0 comments on commit dfe1455

Please sign in to comment.