Skip to content

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

Refactor StandardSection components for improved styling and interactivity

Bill Yang62edf66e65bd
diff --git a/client/public/greenfrog.png b/client/public/greenfrog.png
new file mode 100644
index 000000000..1396433cc
Binary files /dev/null and b/client/public/greenfrog.png differ
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
index 796503bd0..70b07bad8 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
@@ -38,10 +38,11 @@ export const Row = ({
}
>
<div
+ // className="absolute h-0.5 bottom-0 bg-accent-400 opacity-90"
className="absolute inset-0 bg-accent-400 py-2 opacity-25 rounded-md"
style={{ width: `${e.percentage * ratio}%` }}
></div>
- <div className="z-5 mx-2 flex justify-between items-center text-xs w-full">
+ <div className="z-10 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 8999f25cd..b72fb87c9 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: `${Math.min(e.percentage * ratio, 100)}%` }}
></div>
- <div className="z-5 ml-2 mr-2 md:mr-4 flex justify-between items-center text-xs w-full min-h-6 py-1">
+ <div className="z-10 ml-2 mr-2 md:mr-4 flex justify-between items-center text-xs w-full min-h-6 py-1">
<div className="flex items-center gap-1 min-w-0 max-w-[65%]">
<div className="truncate">{getLabel(e)}</div>
{getLink && (
diff --git a/client/src/app/[site]/main/components/MainSection/Overview.tsx b/client/src/app/[site]/main/components/MainSection/Overview.tsx
index 56b821cf7..984010e3e 100644
--- a/client/src/app/[site]/main/components/MainSection/Overview.tsx
+++ b/client/src/app/[site]/main/components/MainSection/Overview.tsx
@@ -9,6 +9,7 @@ import { useGetOverviewBucketed } from "../../../../../api/analytics/useGetOverv
import { SparklinesChart } from "./SparklinesChart";
import { TrendingDown } from "lucide-react";
import { TrendingUp } from "lucide-react";
+import { useState } from "react";
const ChangePercentage = ({
current,
@@ -67,6 +68,7 @@ const Stat = ({
postfix?: string;
}) => {
const { selectedStat, setSelectedStat, site, bucket } = useStore();
+ const [isHovering, setIsHovering] = useState(false);
const { data, isFetching, error } = useGetOverviewBucketed({ site, bucket });
@@ -79,10 +81,12 @@ const Stat = ({
return (
<div
className={cn(
- "flex flex-col hover:bg-neutral-800 cursor-pointer border-r border-neutral-800 last:border-r-0 text-nowrap",
+ "flex flex-col cursor-pointer border-r border-neutral-800 last:border-r-0 text-nowrap",
selectedStat === id && "bg-neutral-850"
)}
onClick={() => setSelectedStat(id)}
+ onMouseEnter={() => setIsHovering(true)}
+ onMouseLeave={() => setIsHovering(false)}
>
<div className={cn("flex flex-col px-3 py-2")}>
<div className="text-sm font-medium text-muted-foreground">{title}</div>
@@ -114,7 +118,7 @@ const Stat = ({
</div>
</div>
<div className="h-[40px] mt-[-16]">
- <SparklinesChart data={sparklinesData} />
+ <SparklinesChart data={sparklinesData} isHovering={isHovering} />
</div>
</div>
);
diff --git a/client/src/app/[site]/main/components/MainSection/SparklinesChart.tsx b/client/src/app/[site]/main/components/MainSection/SparklinesChart.tsx
index 7f3fcceb4..6001184a6 100644
--- a/client/src/app/[site]/main/components/MainSection/SparklinesChart.tsx
+++ b/client/src/app/[site]/main/components/MainSection/SparklinesChart.tsx
@@ -1,6 +1,5 @@
"use client";
import { nivoTheme } from "@/lib/nivo";
-import { useStore } from "@/lib/store";
import { ResponsiveLine } from "@nivo/line";
import { DateTime } from "luxon";
@@ -8,8 +7,10 @@ export const formatter = Intl.NumberFormat("en", { notation: "compact" });
export function SparklinesChart({
data,
+ isHovering,
}: {
data: { value: number; time: string }[] | undefined;
+ isHovering: boolean;
}) {
const formattedData = data
?.map((e, i) => {
@@ -61,7 +62,9 @@ export function SparklinesChart({
useMesh={true}
animate={false}
enableSlices={"x"}
- colors={["hsl(var(--accent-400))"]}
+ colors={[
+ isHovering ? "hsl(var(--accent-300))" : "hsl(var(--accent-400))",
+ ]}
enableArea={false}
areaBaselineValue={0}
areaOpacity={0.3}
diff --git a/client/src/components/ui/card.tsx b/client/src/components/ui/card.tsx
index eae40baac..dda8732c5 100644
--- a/client/src/components/ui/card.tsx
+++ b/client/src/components/ui/card.tsx
@@ -35,7 +35,7 @@ const CardLoader = React.forwardRef<
stroke="3"
bg-opacity="0.1"
speed="1.4"
- color="hsl(var(--accent-400))"
+ color="hsl(var(--neutral-400))"
/>
</div>
);