Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor SubHeader and BaseStandardSectionDialog components for improved layout and usability

Bill Yangd5ae3d7fd5a5
diff --git a/client/src/app/[site]/components/SubHeader/SubHeader.tsx b/client/src/app/[site]/components/SubHeader/SubHeader.tsx
index 92410f19d..a2416d4c6 100644
--- a/client/src/app/[site]/components/SubHeader/SubHeader.tsx
+++ b/client/src/app/[site]/components/SubHeader/SubHeader.tsx
@@ -3,20 +3,11 @@ import { Filters } from "./Filters/Filters";
import { Button } from "@/components/ui/button";
import { FilterParameter, goBack, goForward, useStore } from "@/lib/store";
-import { ChevronLeft, ChevronRight, Menu } from "lucide-react";
+import { ChevronLeft, ChevronRight } from "lucide-react";
import { DateTime } from "luxon";
-import { VisuallyHidden } from "radix-ui";
import { DateSelector } from "../../../../components/DateSelector/DateSelector";
import { Time } from "../../../../components/DateSelector/types";
-import {
- Sheet,
- SheetContent,
- SheetHeader,
- SheetTitle,
- SheetTrigger,
-} from "../../../../components/ui/sheet";
-import { Sidebar } from "../Sidebar/Sidebar";
import { MobileSidebar } from "../../../../components/MobileSidebar";
const canGoForward = (time: Time) => {
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
index 34cbe95ad..ddb463636 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
@@ -59,11 +59,11 @@ export function BaseStandardSectionDialog({
<DialogTrigger asChild>
<Button variant="outline">View All</Button>
</DialogTrigger>
- <DialogContent className="max-w-[90vw] w-[1000px]">
+ <DialogContent className="max-h-[95vh] max-w-[95vw] w-[600px]">
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
- <div className="flex flex-col gap-2">
+ <div className="flex flex-col gap-2 max-h-[85vh]">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-neutral-400" />
<Input
@@ -78,12 +78,12 @@ export function BaseStandardSectionDialog({
<div>{title}</div>
<div>{countLabel || "Sessions"}</div>
</div>
- <div className="flex flex-col gap-2 max-h-[85vh] overflow-x-hidden">
+ <div className="flex flex-col gap-2 overflow-x-hidden">
{filteredData.length > 0 ? (
filteredData.map((e) => (
<div
key={getKey(e)}
- className="relative flex items-center mr-3 cursor-pointer hover:bg-neutral-850"
+ className="relative flex items-center mr-1 cursor-pointer hover:bg-neutral-850"
onClick={() =>
addFilter({
parameter: filterParameter,
diff --git a/client/src/components/MobileSidebar.tsx b/client/src/components/MobileSidebar.tsx
index f38c19266..c95ccf5fb 100644
--- a/client/src/components/MobileSidebar.tsx
+++ b/client/src/components/MobileSidebar.tsx
@@ -27,7 +27,7 @@ export function MobileSidebar() {
<SheetTitle>Frogstats Sidebar</SheetTitle>
</SheetHeader>
</VisuallyHidden.Root>
- <SheetContent side="left" className="p-0 w-[223px]">
+ <SheetContent side="left" className="p-0 w-[223px]" showClose={false}>
<Sidebar />
</SheetContent>
</Sheet>
diff --git a/client/src/components/ui/sheet.tsx b/client/src/components/ui/sheet.tsx
index b0d82f22a..ed0ed29d4 100644
--- a/client/src/components/ui/sheet.tsx
+++ b/client/src/components/ui/sheet.tsx
@@ -55,23 +55,30 @@ interface SheetContentProps
const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
- SheetContentProps
->(({ side = "right", className, children, ...props }, ref) => (
- <SheetPortal>
- <SheetOverlay />
- <SheetPrimitive.Content
- ref={ref}
- className={cn(sheetVariants({ side }), className)}
- {...props}
- >
- <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-neutral-100 dark:ring-offset-neutral-950 dark:focus:ring-neutral-300 dark:data-[state=open]:bg-neutral-800">
- <X className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
- {children}
- </SheetPrimitive.Content>
- </SheetPortal>
-));
+ SheetContentProps & { showClose?: boolean }
+>(
+ (
+ { side = "right", className, children, showClose = true, ...props },
+ ref
+ ) => (
+ <SheetPortal>
+ <SheetOverlay />
+ <SheetPrimitive.Content
+ ref={ref}
+ className={cn(sheetVariants({ side }), className)}
+ {...props}
+ >
+ {showClose && (
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-neutral-100 dark:ring-offset-neutral-950 dark:focus:ring-neutral-300 dark:data-[state=open]:bg-neutral-800">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ )}
+ {children}
+ </SheetPrimitive.Content>
+ </SheetPortal>
+ )
+);
SheetContent.displayName = SheetPrimitive.Content.displayName;
const SheetHeader = ({