Skip to content

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

Refactor Header and StandardSection components for improved layout and responsiveness. Adjusted padding in Header for better spacing on different screen sizes. Updated Row component to position elements more effectively and modified item display logic in StandardSection to adapt to window size, enhancing user experience across devices.

Bill Yang7f72661f6f89
diff --git a/client/src/app/[site]/components/Header/Header.tsx b/client/src/app/[site]/components/Header/Header.tsx
index 1fc005f1b..50a936aa1 100644
--- a/client/src/app/[site]/components/Header/Header.tsx
+++ b/client/src/app/[site]/components/Header/Header.tsx
@@ -11,7 +11,7 @@ export function Header() {
return (
<div className="flex flex-col">
{user && (
- <div className="flex flex-col px-4">
+ <div className="flex flex-col px-2 md:px-4">
<FreePlanBanner />
<UsageBanners />
<NoData />
diff --git a/client/src/app/[site]/components/shared/StandardSection/Row.tsx b/client/src/app/[site]/components/shared/StandardSection/Row.tsx
index ae749b959..712c79b6e 100644
--- a/client/src/app/[site]/components/shared/StandardSection/Row.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/Row.tsx
@@ -5,11 +5,7 @@ import { ChevronDown, ChevronRight, SquareArrowOutUpRight } from "lucide-react";
import { ReactNode, useState, useCallback } from "react";
import { usePaginatedSingleCol } from "../../../../../api/analytics/usePaginatedSingleCol";
import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";
-import {
- addFilter,
- removeFilter,
- useStore,
-} from "../../../../../lib/store";
+import { addFilter, removeFilter, useStore } from "../../../../../lib/store";
// Custom hook for filter handling logic
const useFilterToggle = () => {
diff --git a/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx
index 2723091ce..d1fe6d18a 100644
--- a/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx
@@ -10,6 +10,7 @@ import { CardLoader } from "../../../../../components/ui/card";
import { StandardSectionDialog } from "./StandardSectionDialog";
import { Row } from "./Row";
import { Skeleton } from "./Skeleton";
+import { useWindowSize } from "@uidotdev/usehooks";
export function StandardSection({
title,
@@ -52,6 +53,10 @@ export function StandardSection({
? 100 / itemsForDisplay[0].percentage
: 1;
+ const { width } = useWindowSize();
+
+ const MAX_ITEMS_TO_DISPLAY = width && width < 768 ? 10 : Infinity;
+
return (
<>
{isFetching && (
@@ -83,14 +88,14 @@ export function StandardSection({
</Button>
</div>
) : (
- <div className="flex flex-col gap-2">
+ <div className="flex flex-col gap-2 overflow-x-hidden">
<div className="flex flex-row gap-2 justify-between pr-1 text-xs text-neutral-400">
<div>{title}</div>
<div>{countLabel || "Sessions"}</div>
</div>
{itemsForDisplay?.length ? (
itemsForDisplay
- .slice(0, 10)
+ .slice(0, MAX_ITEMS_TO_DISPLAY)
.map((e) => (
<Row
key={getKey(e)}