Skip to content

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

Refactor Sidebar and Retention components for improved UI and functionality

Bill Yang5628b9acd0a5
diff --git a/client/src/app/[site]/components/Sidebar/Sidebar.tsx b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
index c8c7e62b8..0785eb73e 100644
--- a/client/src/app/[site]/components/Sidebar/Sidebar.tsx
+++ b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
@@ -64,24 +64,6 @@ export function Sidebar() {
href={getTabPath("map")}
icon={<Map className="w-4 h-4" />}
/>
- <SidebarLink
- label="Sessions"
- active={isActiveTab("sessions")}
- href={getTabPath("sessions")}
- icon={<Rewind className="w-4 h-4" />}
- />
- <SidebarLink
- label="Users"
- active={isActiveTab("users")}
- href={getTabPath("users")}
- icon={<User className="w-4 h-4" />}
- />
- <SidebarLink
- label="Retention"
- active={isActiveTab("retention")}
- href={getTabPath("retention")}
- icon={<LayoutGrid className="w-4 h-4" />}
- />
<SidebarLink
label="Funnels"
active={isActiveTab("funnels")}
@@ -100,6 +82,24 @@ export function Sidebar() {
href={getTabPath("journeys")}
icon={<Split className="w-4 h-4" />}
/>
+ <SidebarLink
+ label="Sessions"
+ active={isActiveTab("sessions")}
+ href={getTabPath("sessions")}
+ icon={<Rewind className="w-4 h-4" />}
+ />
+ <SidebarLink
+ label="Users"
+ active={isActiveTab("users")}
+ href={getTabPath("users")}
+ icon={<User className="w-4 h-4" />}
+ />
+ <SidebarLink
+ label="Retention"
+ active={isActiveTab("retention")}
+ href={getTabPath("retention")}
+ icon={<LayoutGrid className="w-4 h-4" />}
+ />
{/* <SidebarLink
label="Reports"
active={isActiveTab("reports")}
diff --git a/client/src/app/[site]/retention/page.tsx b/client/src/app/[site]/retention/page.tsx
index 0d78753db..ec1fbd936 100644
--- a/client/src/app/[site]/retention/page.tsx
+++ b/client/src/app/[site]/retention/page.tsx
@@ -41,35 +41,36 @@ const getRetentionColor = (
): { backgroundColor: string; textColor: string } => {
if (percentage === null || isNaN(percentage)) {
return {
- backgroundColor: "hsl(var(--neutral-900))",
+ backgroundColor: "rgb(38, 38, 38)", // bg-neutral-800
textColor: "transparent",
};
}
if (percentage === 0) {
return {
- backgroundColor: "hsl(var(--neutral-850))",
- textColor: "var(--text-dark, #262626)",
+ backgroundColor: "rgb(38, 38, 38)", // bg-neutral-800
+ textColor: "white",
};
}
- // Use a consistent blue hue
- const hue = 210; // Fixed blue hue
+ // The base emerald-500 color in RGB
+ const emerald = "rgb(16, 185, 129)"; // emerald-500
- // Use a consistent saturation
- const saturation = 80; // Fixed high saturation
+ // Calculate both linear and logarithmic scales
+ const linearScale = percentage / 100;
+ const logScale = Math.log(percentage + 1) / Math.log(101);
- // Only vary the lightness based on retention percentage
- // High retention = darker (lower lightness), low retention = lighter
- // Scale from 85% (low retention) to 30% (high retention)
- const lightness = Math.max(30, Math.min(85, 85 - percentage * 0.55));
+ // Blend between logarithmic and linear (60% log, 40% linear)
+ // This creates a less extreme logarithmic effect
+ const blendedScale = logScale * 0.6 + linearScale * 0.4;
- // Determine text color (white for dark backgrounds, dark for light backgrounds)
- const textColor = lightness < 50 ? "white" : "var(--text-dark, #262626)";
+ // Scale the blended value to get appropriate opacity (min 0.1, max 1.0)
+ const scaledOpacity = 0.1 + blendedScale * 0.9;
+ // Use the scaled opacity for the background color
return {
- backgroundColor: `hsl(${hue}, ${saturation}%, ${lightness}%)`,
- textColor,
+ backgroundColor: `rgba(16, 185, 129, ${scaledOpacity.toFixed(2)})`,
+ textColor: "white",
};
};