Skip to content

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

Enhance BaseStandardSection and BaseStandardSectionDialog components

Bill Yangdeab0c0381a5
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
index 935cd4f0b..d2305817a 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
@@ -1,13 +1,17 @@
import { Button } from "@/components/ui/button";
+import NumberFlow from "@number-flow/react";
import { round } from "lodash";
-import { AlertCircle, RefreshCcw, SquareArrowOutUpRight } from "lucide-react";
+import {
+ AlertCircle,
+ Info,
+ RefreshCcw,
+ SquareArrowOutUpRight,
+} from "lucide-react";
import { ReactNode } from "react";
import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";
import { addFilter, FilterParameter } from "../../../../../lib/store";
-import { formatter } from "../../../../../lib/utils";
-import { Skeleton } from "./Skeleton";
import { BaseStandardSectionDialog } from "./BaseStandardSectionDialog";
-import NumberFlow from "@number-flow/react";
+import { Skeleton } from "./Skeleton";
export const Row = ({
e,
@@ -102,13 +106,10 @@ export function BaseStandardSection({
countLabel,
filterParameter,
}: BaseStandardSectionProps) {
- // Determine if we're in a loading state
-
const ratio = data?.data?.[0]?.percentage
? 100 / data?.data?.[0]?.percentage
: 1;
- // Check for errors
const hasError = error;
const errorMessage =
error?.message || "An error occurred while fetching data";
@@ -143,18 +144,27 @@ export function BaseStandardSection({
<div>{title}</div>
<div>{countLabel || "Sessions"}</div>
</div>
- {data?.data?.slice(0, 10).map((e) => (
- <Row
- key={getKey(e)}
- e={e}
- ratio={ratio}
- getKey={getKey}
- getLabel={getLabel}
- getValue={getValue}
- getLink={getLink}
- filterParameter={filterParameter}
- />
- ))}
+ {data?.data?.length ? (
+ data?.data
+ ?.slice(0, 10)
+ .map((e) => (
+ <Row
+ key={getKey(e)}
+ e={e}
+ ratio={ratio}
+ getKey={getKey}
+ getLabel={getLabel}
+ getValue={getValue}
+ getLink={getLink}
+ filterParameter={filterParameter}
+ />
+ ))
+ ) : (
+ <div className="text-neutral-300 w-full text-center mt-6 flex flex-row gap-2 items-center justify-center">
+ <Info className="w-5 h-5" />
+ No Data
+ </div>
+ )}
</>
)}
{isLoading ? (
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
index dfee8a893..63267a101 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
@@ -105,7 +105,7 @@ export function BaseStandardSectionDialog({
columnHelper.accessor("count", {
header: "Sessions",
cell: (info) => (
- <div className="text-right flex flex-row gap-1 items-center justify-end">
+ <div className="flex flex-row gap-1 items-center sm:justify-end">
{info.getValue().toLocaleString()}
</div>
),
@@ -113,7 +113,7 @@ export function BaseStandardSectionDialog({
columnHelper.accessor("percentage", {
header: "Session %",
cell: (info) => (
- <div className="text-right flex flex-row gap-1 items-center justify-end">
+ <div className="flex flex-row gap-1 items-center sm:justify-end">
{info.getValue().toFixed(1)}%
</div>
),
@@ -128,7 +128,7 @@ export function BaseStandardSectionDialog({
columnHelper.accessor("pageviews", {
header: "Pageviews",
cell: (info) => (
- <div className="text-right flex flex-row gap-1 items-center justify-end">
+ <div className="flex flex-row gap-1 items-center sm:justify-end">
{info.getValue()?.toLocaleString()}
</div>
),
@@ -138,7 +138,7 @@ export function BaseStandardSectionDialog({
columnHelper.accessor("pageviews_percentage", {
header: "Pageviews %",
cell: (info) => (
- <div className="text-right flex flex-row gap-1 items-center justify-end">
+ <div className="flex flex-row gap-1 items-center sm:justify-end">
{info.getValue()?.toFixed(1)}%
</div>
),
@@ -187,7 +187,7 @@ export function BaseStandardSectionDialog({
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
- <div className="flex flex-col gap-2 ">
+ <div className="flex flex-col gap-2 overflow-x-auto">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-neutral-400" />
<Input
@@ -199,7 +199,7 @@ export function BaseStandardSectionDialog({
/>
</div>
<div className="max-h-[80vh] overflow-y-auto">
- <table className="w-full text-xs text-left">
+ <table className="w-full text-xs text-left min-w-max">
<thead className="bg-neutral-900 text-neutral-400 sticky top-0 z-10">
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsx
index 19b498cdc..4682af66c 100644
--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx
+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx
@@ -139,7 +139,7 @@ export function Chart({
},
]}
theme={nivoTheme}
- margin={{ top: 10, right: 10, bottom: 20, left: 35 }}
+ margin={{ top: 10, right: 10, bottom: 25, left: 35 }}
xScale={{
type: "time",
format: "%Y-%m-%d %H:%M:%S",
diff --git a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx
index 669758a10..5dc4bea9a 100644
--- a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx
+++ b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx
@@ -54,7 +54,7 @@ export function PreviousChart({
},
]}
theme={nivoTheme}
- margin={{ top: 10, right: 10, bottom: 20, left: 35 }}
+ margin={{ top: 10, right: 10, bottom: 25, left: 35 }}
xScale={{
type: "time",
format: "%Y-%m-%d %H:%M:%S",
diff --git a/client/src/app/[site]/main/components/sections/Pages.tsx b/client/src/app/[site]/main/components/sections/Pages.tsx
index 91c14a16e..10aa87fe4 100644
--- a/client/src/app/[site]/main/components/sections/Pages.tsx
+++ b/client/src/app/[site]/main/components/sections/Pages.tsx
@@ -39,7 +39,7 @@ export function Pages({ isRealtime = false }: { isRealtime?: boolean }) {
title="Pages"
getValue={(e) => e.value}
getKey={(e) => e.value}
- getLabel={(e) => truncateString(e.value, 50) || "Other"}
+ getLabel={(e) => truncateString(e.value, 30) || "Other"}
getLink={(e) => `https://${siteMetadata?.domain}${e.value}`}
/>
</TabsContent>