Skip to content

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

Refactor button layout and improve label handling across multiple sections

Bill Yang7a45b0698bac
diff --git a/.prettierignore b/.prettierignore
index f07851ec5..66867a8be 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -69,3 +69,4 @@ tsconfig.tsbuildinfo
*.dll
*.so
*.dylib
+
diff --git a/client/src/app/[site]/components/shared/StandardSection/Row.tsx b/client/src/app/[site]/components/shared/StandardSection/Row.tsx
index 58b929539..8ccec2046 100644
--- a/client/src/app/[site]/components/shared/StandardSection/Row.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/Row.tsx
@@ -62,12 +62,12 @@ const RowItem = ({
className="absolute inset-0 bg-dataviz py-2 opacity-25 rounded-md"
style={{ width: `${item.percentage * ratio}%` }}
></div>
- <div className="z-10 mx-2 flex justify-between items-center text-xs w-full">
- <div className="flex items-center gap-1">
+ <div className="z-10 mx-2 flex justify-between items-center text-xs w-full gap-2">
+ <div className="flex items-center gap-1 min-w-0 flex-1">
{leftContent}
- {getLabel(item)}
+ <span className="truncate">{getLabel(item)}</span>
{getLink && (
- <a href={getLink(item)} target="_blank" onClick={e => e.stopPropagation()}>
+ <a href={getLink(item)} target="_blank" onClick={e => e.stopPropagation()} className="flex-shrink-0">
<SquareArrowOutUpRight
className="ml-0.5 w-3.5 h-3.5 text-neutral-300 hover:text-neutral-100"
strokeWidth={3}
@@ -75,7 +75,7 @@ const RowItem = ({
</a>
)}
</div>
- <div className="text-xs flex gap-2">
+ <div className="text-xs flex gap-2 flex-shrink-0">
<div className="hidden group-hover:block text-neutral-400">{round(item.percentage, 1)}%</div>
<NumberFlow respectMotionPreference={false} value={item.count} format={{ notation: "compact" }} />
</div>
diff --git a/client/src/app/[site]/main/components/sections/Countries.tsx b/client/src/app/[site]/main/components/sections/Countries.tsx
index 9c7735678..7bff78e49 100644
--- a/client/src/app/[site]/main/components/sections/Countries.tsx
+++ b/client/src/app/[site]/main/components/sections/Countries.tsx
@@ -52,7 +52,7 @@ export function Countries() {
<TabsTrigger value="timezones">Timezones</TabsTrigger>
</TabsList>
{tab !== "map" && (
- <div>
+ <div className="w-8">
<Button size="smIcon" onClick={() => setExpanded(!expanded)}>
<Expand className="w-4 h-4" />
</Button>
diff --git a/client/src/app/[site]/main/components/sections/Devices.tsx b/client/src/app/[site]/main/components/sections/Devices.tsx
index a77b8267a..e951b87e8 100644
--- a/client/src/app/[site]/main/components/sections/Devices.tsx
+++ b/client/src/app/[site]/main/components/sections/Devices.tsx
@@ -31,9 +31,11 @@ export function Devices() {
<TabsTrigger value="dimensions">Screen Dimensions</TabsTrigger>
</TabsList>
</div>
- <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
- <Expand />
- </Button>
+ <div className="w-8">
+ <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
+ <Expand className="w-4 h-4" />
+ </Button>
+ </div>
</div>
<TabsContent value="devices">
<StandardSection
diff --git a/client/src/app/[site]/main/components/sections/Network.tsx b/client/src/app/[site]/main/components/sections/Network.tsx
index c3c4ac760..8e41a0f76 100644
--- a/client/src/app/[site]/main/components/sections/Network.tsx
+++ b/client/src/app/[site]/main/components/sections/Network.tsx
@@ -45,9 +45,9 @@ export function Network() {
<TabsTrigger value="asn_domain">ASN Domain</TabsTrigger>
</TabsList>
</div>
- <div className="w-10">
+ <div className="w-8">
<Button size="smIcon" onClick={() => setExpanded(!expanded)}>
- <Expand />
+ <Expand className="w-4 h-4" />
</Button>
</div>
</div>
diff --git a/client/src/app/[site]/main/components/sections/Pages.tsx b/client/src/app/[site]/main/components/sections/Pages.tsx
index d3bab1ff8..324891175 100644
--- a/client/src/app/[site]/main/components/sections/Pages.tsx
+++ b/client/src/app/[site]/main/components/sections/Pages.tsx
@@ -7,13 +7,10 @@ import { useGetSite } from "../../../../../api/admin/sites";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../../../components/ui/basic-tabs";
import { Button } from "../../../../../components/ui/button";
import { Card, CardContent } from "../../../../../components/ui/card";
-import { truncateString } from "../../../../../lib/utils";
import { StandardSection } from "../../../components/shared/StandardSection/StandardSection";
type Tab = "pages" | "page_title" | "entry_pages" | "exit_pages" | "hostname";
-const MAX_LABEL_LENGTH = 70;
-
export function Pages() {
const { data: siteMetadata } = useGetSite();
const [tab, setTab] = useState<Tab>("pages");
@@ -36,9 +33,11 @@ export function Pages() {
<TabsTrigger value="hostname">Hostnames</TabsTrigger>
</TabsList>
</div>
- <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
- <Expand className="w-4 h-4" />
- </Button>
+ <div className="w-8">
+ <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
+ <Expand className="w-4 h-4" />
+ </Button>
+ </div>
</div>
<TabsContent value="pages">
<StandardSection
@@ -46,7 +45,7 @@ export function Pages() {
title="Pages"
getValue={e => e.value}
getKey={e => e.value}
- getLabel={e => truncateString(e.value, MAX_LABEL_LENGTH) || "Other"}
+ getLabel={e => e.value || "Other"}
getLink={e => `https://${siteMetadata?.domain}${e.value}`}
expanded={expanded}
close={close}
@@ -58,7 +57,7 @@ export function Pages() {
title="Page Title"
getValue={e => e.value}
getKey={e => e.value}
- getLabel={e => truncateString(e.value, MAX_LABEL_LENGTH) || "Other"}
+ getLabel={e => e.value || "Other"}
// getLink={(e) =>
// e.pathname
// ? `https://${siteMetadata?.domain}${e.pathname}`
@@ -74,7 +73,7 @@ export function Pages() {
title="Entry Pages"
getValue={e => e.value}
getKey={e => e.value}
- getLabel={e => truncateString(e.value, MAX_LABEL_LENGTH) || "Other"}
+ getLabel={e => e.value || "Other"}
getLink={e => `https://${siteMetadata?.domain}${e.value}`}
expanded={expanded}
close={close}
@@ -86,7 +85,7 @@ export function Pages() {
title="Exit Pages"
getValue={e => e.value}
getKey={e => e.value}
- getLabel={e => truncateString(e.value, MAX_LABEL_LENGTH) || "Other"}
+ getLabel={e => e.value || "Other"}
getLink={e => `https://${siteMetadata?.domain}${e.value}`}
expanded={expanded}
close={close}
diff --git a/client/src/app/[site]/main/components/sections/Referrers.tsx b/client/src/app/[site]/main/components/sections/Referrers.tsx
index 1e70c8881..d9917002f 100644
--- a/client/src/app/[site]/main/components/sections/Referrers.tsx
+++ b/client/src/app/[site]/main/components/sections/Referrers.tsx
@@ -32,9 +32,11 @@ export function Referrers() {
<TabsTrigger value="utm_content">Content</TabsTrigger>
</TabsList>
</div>
- <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
- <Expand className="w-4 h-4" />
- </Button>
+ <div className="w-8">
+ <Button size="smIcon" onClick={() => setExpanded(!expanded)}>
+ <Expand className="w-4 h-4" />
+ </Button>
+ </div>
</div>
<TabsContent value="referrers">
<StandardSection
diff --git a/client/src/app/admin/components/organizations/Organizations.tsx b/client/src/app/admin/components/organizations/Organizations.tsx
index f963ff9b5..9d2af831a 100644
--- a/client/src/app/admin/components/organizations/Organizations.tsx
+++ b/client/src/app/admin/components/organizations/Organizations.tsx
@@ -370,7 +370,11 @@ export function Organizations() {
<TabsTrigger value="growth">Organization Growth</TabsTrigger>
<TabsTrigger value="usage">Service Usage</TabsTrigger>
</TabsList>
-
+ </div>
+ <TabsContent value="growth">
+ <GrowthChart data={organizations} color="#8b5cf6" title="Organizations" />
+ </TabsContent>
+ <TabsContent value="usage">
<div className="flex items-center gap-1 bg-neutral-800 p-1 rounded-lg">
<Button
size="sm"
@@ -405,11 +409,6 @@ export function Organizations() {
All Time
</Button>
</div>
- </div>
- <TabsContent value="growth">
- <GrowthChart data={organizations} color="#8b5cf6" title="Organizations" />
- </TabsContent>
- <TabsContent value="usage">
<ServiceUsageChart
startDate={startDate}
endDate={endDate}