Skip to content

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

Enhance layout responsiveness and integrate window size handling

Bill Yang0327059d3645
diff --git a/client/src/app/[site]/components/SubHeader/SubHeader.tsx b/client/src/app/[site]/components/SubHeader/SubHeader.tsx
index bc82f4495..631e90afb 100644
--- a/client/src/app/[site]/components/SubHeader/SubHeader.tsx
+++ b/client/src/app/[site]/components/SubHeader/SubHeader.tsx
@@ -9,6 +9,7 @@ import { DateTime } from "luxon";
import { DateSelector } from "../../../../components/DateSelector/DateSelector";
import { Time } from "../../../../components/DateSelector/types";
import { MobileSidebar } from "../../../../components/MobileSidebar";
+import { useWindowSize } from "@uidotdev/usehooks";
const canGoForward = (time: Time) => {
const currentDay = DateTime.now().startOf("day");
@@ -41,6 +42,41 @@ export function SubHeader({
availableFilters?: FilterParameter[];
}) {
const { time, setTime } = useStore();
+ // const { width } = useWindowSize();
+
+ // if (width && width < 768) {
+ // return (
+ // <div className="flex flex-col relative">
+ // <div className="flex gap-2 mb-2 justify-between sticky top-0 z-10 bg-background">
+ // <div className="flex items-center gap-2">
+ // <MobileSidebar />
+ // </div>
+ // <div className="flex items-center gap-2">
+ // <DateSelector time={time} setTime={setTime} />
+ // <div className="flex items-center">
+ // <Button
+ // variant="outline"
+ // size="icon"
+ // onClick={goBack}
+ // className="rounded-r-none h-8 w-8 sm:h-9 sm:w-9"
+ // >
+ // <ChevronLeft />
+ // </Button>
+ // <Button
+ // variant="outline"
+ // size="icon"
+ // onClick={goForward}
+ // disabled={!canGoForward(time)}
+ // className="rounded-l-none -ml-px h-8 w-8 sm:h-9 sm:w-9"
+ // >
+ // <ChevronRight />
+ // </Button>
+ // </div>
+ // </div>
+ // </div>
+ // </div>
+ // );
+ // }
return (
<div>
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
index 6ca0555c1..796503bd0 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
@@ -41,7 +41,7 @@ export const Row = ({
className="absolute inset-0 bg-accent-400 py-2 opacity-25 rounded-md"
style={{ width: `${e.percentage * ratio}%` }}
></div>
- <div className="z-10 mx-2 flex justify-between items-center text-xs w-full">
+ <div className="z-5 mx-2 flex justify-between items-center text-xs w-full">
<div className="flex items-center gap-1">
{getLabel(e)}
{getLink && (
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
index 76d7c6811..e0e67d4d0 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
@@ -96,7 +96,7 @@ export function BaseStandardSectionDialog({
className="absolute inset-0 bg-accent-400 py-2 opacity-30 rounded-md"
style={{ width: `${e.percentage * ratio}%` }}
></div>
- <div className="z-10 ml-2 mr-4 flex justify-between items-center text-xs w-full h-6">
+ <div className="z-5 ml-2 mr-4 flex justify-between items-center text-xs w-full h-6">
<div className="flex items-center gap-1">
{getLabel(e)}
{getLink && (
diff --git a/client/src/app/[site]/components/shared/StandardSection/Skeleton.tsx b/client/src/app/[site]/components/shared/StandardSection/Skeleton.tsx
index 2fbf2816f..4392a0426 100644
--- a/client/src/app/[site]/components/shared/StandardSection/Skeleton.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/Skeleton.tsx
@@ -39,7 +39,7 @@ export const Skeleton = memo(() => {
className="absolute inset-0 bg-neutral-800 py-2 rounded-md animate-pulse"
style={{ width: `${widths[index]}%` }}
></div>
- <div className="z-10 mx-2 flex justify-between items-center text-sm w-full">
+ <div className="z-5 mx-2 flex justify-between items-center text-sm w-full">
<div className="flex items-center gap-1">
<div
className="h-4 bg-neutral-800 rounded animate-pulse"
diff --git a/client/src/app/[site]/layout.tsx b/client/src/app/[site]/layout.tsx
index e669285a3..603c8bf52 100644
--- a/client/src/app/[site]/layout.tsx
+++ b/client/src/app/[site]/layout.tsx
@@ -8,6 +8,7 @@ import { useSiteHasData, useGetSite } from "../../api/admin/sites";
import { NoData } from "./components/NoData";
import { TopBar } from "../../components/TopBar";
import { Sidebar } from "./components/Sidebar/Sidebar";
+import { useWindowSize } from "@uidotdev/usehooks";
export default function SiteLayout({
children,
@@ -30,6 +31,8 @@ export default function SiteLayout({
}
}, [pathname]);
+ const { width } = useWindowSize();
+
if (!site) {
return null;
}
@@ -42,6 +45,21 @@ export default function SiteLayout({
return <NoData siteMetadata={siteMetadata} />;
}
+ if (width && width < 768) {
+ return (
+ <div className="">
+ <TopBar />
+ <div>{children}</div>
+ </div>
+ // <div className="flex flex-col h-screen relative">
+ // <div className="sticky top-0 z-10 bg-background">
+ // <TopBar />
+ // </div>
+ // <div className="overflow-auto">{children}</div>
+ // </div>
+ );
+ }
+
return (
<div className="flex flex-col h-screen">
<TopBar />
diff --git a/client/src/components/Sessions/SessionsList.tsx b/client/src/components/Sessions/SessionsList.tsx
index e843073c0..eb64e8b72 100644
--- a/client/src/components/Sessions/SessionsList.tsx
+++ b/client/src/components/Sessions/SessionsList.tsx
@@ -54,11 +54,7 @@ export default function SessionsList({ userId }: { userId?: string }) {
);
return (
- <div
- ref={containerRef}
- className="overflow-auto pr-2"
- style={{ height: "calc(100vh - 130px)" }}
- >
+ <div ref={containerRef} className="overflow-auto pr-2">
{isLoading ? (
// Show skeleton cards while loading
<SessionCardSkeleton />