Skip to content

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

feat: Use `cn` function (#198)

Andrii Zontov51780fc8f652
diff --git a/client/src/app/[site]/components/Sidebar/Sidebar.tsx b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
index fac07f630..e452b61dd 100644
--- a/client/src/app/[site]/components/Sidebar/Sidebar.tsx
+++ b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
@@ -1,22 +1,22 @@
"use client";
-import { CursorClick, Funnel, Target } from "@phosphor-icons/react/dist/ssr";
+import { Funnel, Target } from "@phosphor-icons/react/dist/ssr";
import {
- ChartBarDecreasing,
Earth,
LayoutDashboard,
LayoutGrid,
+ Map,
+ MousePointerClick,
Rewind,
Settings,
- User,
- Map,
Split,
- MousePointerClick,
+ User
} from "lucide-react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useGetSite } from "../../../../api/admin/sites";
import { SiteSettings } from "../../../../components/SiteSettings/SiteSettings";
import { authClient } from "../../../../lib/auth";
+import { cn } from "../../../../lib/utils";
import LiveUserCount from "./LiveUserCount";
import { SiteSelector } from "./SiteSelector";
@@ -145,13 +145,7 @@ function SidebarLink({
}) {
return (
<Link href={href} className="focus:outline-none">
- <div
- className={`px-3 py-2 rounded-lg transition-colors w-full ${
- active
- ? "bg-neutral-800 text-white"
- : "text-neutral-200 hover:text-white hover:bg-neutral-800/50"
- }`}
- >
+ <div className={cn("px-3 py-2 rounded-lg transition-colors w-full", active ? "bg-neutral-800 text-white" : "text-neutral-200 hover:text-white hover:bg-neutral-800/50")}>
<div className="flex items-center gap-2">
{icon}
<span className="text-sm">{label}</span>
diff --git a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx b/client/src/app/[site]/components/Sidebar/SiteSelector.tsx
index 3d36a73b0..951ff8516 100644
--- a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx
+++ b/client/src/app/[site]/components/Sidebar/SiteSelector.tsx
@@ -1,15 +1,16 @@
import { Check } from "lucide-react";
import { usePathname, useRouter } from "next/navigation";
import { useGetSite, useGetSites } from "../../../../api/admin/sites";
+import { Favicon } from "../../../../components/Favicon";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "../../../../components/ui/dropdown-menu";
-import { userStore } from "../../../../lib/userStore";
import { resetStore, useStore } from "../../../../lib/store";
-import { Favicon } from "../../../../components/Favicon";
+import { userStore } from "../../../../lib/userStore";
+import { cn } from "../../../../lib/utils";
function SiteSelectorContent() {
const { data: sites } = useGetSites();
@@ -29,9 +30,7 @@ function SiteSelectorContent() {
resetStore();
router.push(`/${site.siteId}`);
}}
- className={`flex items-center justify-between ${
- isSelected ? "bg-neutral-800" : ""
- }`}
+ className={cn("flex items-center justify-between", isSelected && "bg-neutral-800")}
>
<div className="flex items-center gap-2">
<Favicon domain={site.domain} className="w-4 h-4" />
diff --git a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx
index 30cb30ce3..0a0327211 100644
--- a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx
+++ b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx
@@ -1,4 +1,9 @@
import { X } from "lucide-react";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "../../../../../components/ui/tooltip";
import { useGetRegionName } from "../../../../../lib/geo";
import {
FilterParameter,
@@ -7,17 +12,13 @@ import {
updateFilter,
useStore,
} from "../../../../../lib/store";
+import { cn } from "../../../../../lib/utils";
import {
filterTypeToLabel,
getParameterNameLabel,
getParameterValueLabel,
} from "../../shared/Filters/utils";
import { NewFilterButton } from "./NewFilterButton";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "../../../../../components/ui/tooltip";
export function Filters({
availableFilters,
@@ -44,22 +45,15 @@ export function Filters({
<TooltipTrigger>
<div
key={filter.parameter}
- className={`px-2 py-1 rounded-lg ${
- disabled ? "bg-neutral-900" : "bg-neutral-850"
- } text-neutral-400 flex items-center gap-1 text-sm`}
+ className={cn("px-2 py-1 rounded-lg text-neutral-400 flex items-center gap-1 text-sm", disabled ? "bg-neutral-900" : "bg-neutral-850")}
>
<div
- className={disabled ? "text-neutral-500" : "text-neutral-300"}
+ className={cn(disabled ? "text-neutral-500" : "text-neutral-300")}
>
{getParameterNameLabel(filter.parameter)}
</div>
<div
- className={`text-emerald-400 font-medium cursor-pointer whitespace-nowrap ${
- filter.type === "not_equals" ||
- filter.type === "not_contains"
- ? "text-red-400"
- : ""
- }`}
+ className={cn("text-emerald-400 font-medium cursor-pointer whitespace-nowrap", (filter.type === "not_equals" || filter.type === "not_contains") && "text-red-400")}
onClick={() => {
let newType: FilterType = "equals";
if (filter.type === "equals") {
@@ -78,9 +72,7 @@ export function Filters({
{filterTypeToLabel(filter.type)}
</div>
<div
- className={`text-neutral-100 font-medium whitespace-nowrap ${
- disabled ? "text-neutral-500" : ""
- }`}
+ className={cn("text-neutral-100 font-medium whitespace-nowrap", disabled && "text-neutral-500")}
>
{getParameterValueLabel(filter, getRegionName)}
</div>
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
index 435062fe6..b486736f5 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSectionDialog.tsx
@@ -1,10 +1,8 @@
-import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogHeader,
- DialogTitle,
- DialogTrigger,
+ DialogTitle
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import {
@@ -12,21 +10,20 @@ import {
flexRender,
getCoreRowModel,
getSortedRowModel,
- useReactTable,
SortingState,
+ useReactTable,
} from "@tanstack/react-table";
import { useDebounce } from "@uidotdev/usehooks";
import {
- Search,
- SquareArrowOutUpRight,
- ChevronUp,
ChevronDown,
- Expand,
+ ChevronUp,
+ Search,
+ SquareArrowOutUpRight
} from "lucide-react";
import { ReactNode, useMemo, useState } from "react";
import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";
import { addFilter, FilterParameter } from "../../../../../lib/store";
-import { formatSecondsAsMinutesAndSeconds } from "../../../../../lib/utils";
+import { cn, formatSecondsAsMinutesAndSeconds } from "../../../../../lib/utils";
interface BaseStandardSectionDialogProps {
title: string;
@@ -200,7 +197,7 @@ export function BaseStandardSectionDialog({
<Input
type="text"
placeholder={`Filter ${data.length} items...`}
- className="pl-9 bg-neutral-900 border-neutral-700 text-xs"
+ className="pl-9 bg-neutral-900 border-neutral-700 text-xs"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
@@ -214,18 +211,14 @@ export function BaseStandardSectionDialog({
<th
key={header.id}
scope="col"
- className={`px-2 py-1 font-medium whitespace-nowrap cursor-pointer select-none ${
- index === 0 ? "text-left" : "text-right"
- }`}
+ className={cn("px-2 py-1 font-medium whitespace-nowrap cursor-pointer select-none", index === 0 ? "text-left" : "text-right")}
style={{
minWidth: header.id === "user_id" ? "100px" : "auto",
}}
onClick={header.column.getToggleSortingHandler()}
>
<div
- className={`flex items-center gap-1 ${
- index === 0 ? "" : "justify-end"
- }`}
+ className={cn("flex items-center gap-1", index !== 0 && "justify-end")}
>
{header.isPlaceholder
? null
@@ -248,9 +241,7 @@ export function BaseStandardSectionDialog({
return (
<tr
key={row.id}
- className={`border-b border-neutral-800 hover:bg-neutral-850 cursor-pointer group ${
- rowIndex % 2 === 0 ? "bg-neutral-900" : "bg-neutral-950"
- }`}
+ className={cn("border-b border-neutral-800 hover:bg-neutral-850 cursor-pointer group", rowIndex % 2 === 0 ? "bg-neutral-900" : "bg-neutral-950")}
onClick={() =>
addFilter({
parameter: filterParameter,
@@ -262,9 +253,7 @@ export function BaseStandardSectionDialog({
{row.getVisibleCells().map((cell, cellIndex) => (
<td
key={cell.id}
- className={`px-2 py-2 relative ${
- cellIndex === 0 ? "" : "text-right"
- }`}
+ className={cn("px-2 py-2 relative", cellIndex !== 0 && "text-right")}
>
{cellIndex === 0 && (
<div
diff --git a/client/src/app/[site]/events/components/EventList.tsx b/client/src/app/[site]/events/components/EventList.tsx
index 1f6ee8c5c..1fc01ded0 100644
--- a/client/src/app/[site]/events/components/EventList.tsx
+++ b/client/src/app/[site]/events/components/EventList.tsx
@@ -6,6 +6,7 @@ import { memo, useState } from "react";
import { EventName } from "../../../../api/analytics/useGetEventNames";
import { useGetEventProperties } from "../../../../api/analytics/useGetEventProperties";
import { NothingFound } from "../../../../components/NothingFound";
+import { cn } from "../../../../lib/utils";
import { EventProperties } from "./EventProperties";
// Skeleton component for EventList
@@ -42,18 +43,14 @@ const EventListSkeleton = memo(
{Array.from({ length: 10 }).map((_, index) => (
<div
key={index}
- className={`relative ${
- size === "small" ? "h-6" : "h-9"
- } flex items-center`}
+ className={cn("relative flex items-center", size === "small" ? "h-6" : "h-9")}
>
<div
className="absolute inset-0 bg-neutral-800 py-2 rounded-md animate-pulse"
style={{ width: `${widths[index]}%` }}
></div>
<div
- className={`z-5 mx-2 flex justify-between items-center ${
- size === "small" ? "text-xs" : "text-sm"
- } w-full`}
+ className={cn("z-5 mx-2 flex justify-between items-center w-full", size === "small" ? "text-xs" : "text-sm")}
>
<div className="flex items-center gap-1">
<div className="h-4 w-4 bg-neutral-800 rounded animate-pulse mr-1"></div>
@@ -63,9 +60,7 @@ const EventListSkeleton = memo(
></div>
</div>
<div
- className={`${
- size === "small" ? "text-xs" : "text-sm"
- } flex gap-2`}
+ className={cn("flex gap-2", size === "small" ? "text-xs" : "text-sm")}
>
<div
className="h-4 bg-neutral-800 rounded animate-pulse"
@@ -131,9 +126,7 @@ export function EventList({
<div key={event.eventName} className="flex flex-col">
{/* Event Row */}
<div
- className={`relative ${
- size === "small" ? "h-6" : "h-9"
- } flex items-center cursor-pointer hover:bg-neutral-850 group px-2 rounded-md`}
+ className={cn("relative flex items-center cursor-pointer hover:bg-neutral-850 group px-2 rounded-md", size === "small" ? "h-6" : "h-9")}
onClick={() => handleEventClick(event.eventName)}
>
<div
@@ -141,9 +134,7 @@ export function EventList({
style={{ width: `${percentage}%` }}
></div>
<div
- className={`z-10 flex justify-between items-center ${
- size === "small" ? "text-xs" : "text-sm"
- } w-full`}
+ className={cn("z-10 flex justify-between items-center w-full", size === "small" ? "text-xs" : "text-sm")}
>
<div className="font-medium truncate max-w-[70%] flex items-center gap-1">
{isExpanded ? (
@@ -154,9 +145,7 @@ export function EventList({
{event.eventName}
</div>
<div
- className={`text-sm flex gap-2 ${
- size === "small" ? "text-xs" : "text-sm"
- }`}
+ className={cn("text-sm flex gap-2", size === "small" ? "text-xs" : "text-sm")}
>
<div className="hidden group-hover:block text-neutral-400">
{Math.round(percentage * 10) / 10}%
diff --git a/client/src/app/[site]/events/components/EventLog.tsx b/client/src/app/[site]/events/components/EventLog.tsx
index 000919791..9f7c25049 100644
--- a/client/src/app/[site]/events/components/EventLog.tsx
+++ b/client/src/app/[site]/events/components/EventLog.tsx
@@ -2,9 +2,9 @@
import { useCallback, useEffect, useRef } from "react";
import { useGetEventsInfinite } from "../../../../api/analytics/useGetEvents";
+import { NothingFound } from "../../../../components/NothingFound";
import { formatter } from "../../../../lib/utils";
import { EventLogItem, EventLogItemSkeleton } from "./EventLogItem";
-import { NothingFound } from "../../../../components/NothingFound";
export function EventLog() {
const containerRef = useRef<HTMLDivElement>(null);
@@ -90,7 +90,7 @@ export function EventLog() {
return (
<div className="space-y-1">
{/* Event list */}
- <div ref={containerRef} className={`max-h-[80vh] overflow-y-auto pr-2`}>
+ <div ref={containerRef} className="max-h-[80vh] overflow-y-auto pr-2">
{allEvents.map((event, index) => (
<EventLogItem key={`${event.timestamp}-${index}`} event={event} />
))}
diff --git a/client/src/app/[site]/events/components/EventLogItem.tsx b/client/src/app/[site]/events/components/EventLogItem.tsx
index c6b7a79c1..5e9090fa3 100644
--- a/client/src/app/[site]/events/components/EventLogItem.tsx
+++ b/client/src/app/[site]/events/components/EventLogItem.tsx
@@ -1,21 +1,21 @@
"use client";
-import { Event } from "../../../../api/analytics/useGetEvents";
-import { DateTime } from "luxon";
-import { Browser } from "../../components/shared/icons/Browser";
-import { CountryFlag } from "../../components/shared/icons/CountryFlag";
-import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
-import { getCountryName } from "../../../../lib/utils";
-import { Laptop, Smartphone, FileText, MousePointerClick } from "lucide-react";
+import { Badge } from "@/components/ui/badge";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
-import { Badge } from "@/components/ui/badge";
+import { FileText, Laptop, MousePointerClick, Smartphone } from "lucide-react";
+import { DateTime } from "luxon";
import Link from "next/link";
import { useParams } from "next/navigation";
import { memo } from "react";
+import { Event } from "../../../../api/analytics/useGetEvents";
+import { getCountryName } from "../../../../lib/utils";
+import { Browser } from "../../components/shared/icons/Browser";
+import { CountryFlag } from "../../components/shared/icons/CountryFlag";
+import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
// DeviceIcon component for displaying mobile/desktop icons
function DeviceIcon({ deviceType }: { deviceType: string }) {
@@ -210,7 +210,7 @@ export const EventLogItemSkeleton = memo(() => {
<div className="flex items-center gap-2 flex-grow">
<div className="h-4 w-4 bg-neutral-800 rounded-sm animate-pulse flex-shrink-0"></div>
<div
- className={`h-4 w-40 bg-neutral-800 rounded animate-pulse flex-shrink-0`}
+ className="h-4 w-40 bg-neutral-800 rounded animate-pulse flex-shrink-0"
></div>
<div className="flex space-x-1 flex-shrink-0">
<div className="h-4 w-4 bg-neutral-800 rounded-sm animate-pulse"></div>
diff --git a/client/src/app/[site]/events/components/EventProperties.tsx b/client/src/app/[site]/events/components/EventProperties.tsx
index 1531edccd..8f86dd506 100644
--- a/client/src/app/[site]/events/components/EventProperties.tsx
+++ b/client/src/app/[site]/events/components/EventProperties.tsx
@@ -1,9 +1,10 @@
"use client";
-import { EventProperty } from "../../../../api/analytics/useGetEventProperties";
import NumberFlow from "@number-flow/react";
import { Info } from "lucide-react";
import { memo } from "react";
+import { EventProperty } from "../../../../api/analytics/useGetEventProperties";
+import { cn } from "../../../../lib/utils";
interface EventPropertiesProps {
properties: EventProperty[];
@@ -67,9 +68,7 @@ export function EventProperties({
return (
<div
- className={`flex flex-col gap-4 ${
- size === "small" ? "max-h-[30vh]" : "max-h-[60vh]"
- } overflow-y-auto pr-2`}
+ className={cn("flex flex-col gap-4 overflow-y-auto pr-2", size === "small" ? "max-h-[30vh]" : "max-h-[60vh]")}
>
{sortedKeys.map((key) => {
// Sort property values by count (descending)
@@ -78,9 +77,7 @@ export function EventProperties({
return (
<div
key={key}
- className={`flex flex-col gap-1 ${
- size === "small" ? "text-xs" : "text-sm"
- }`}
+ className={cn("flex flex-col gap-1", size === "small" ? "text-xs" : "text-sm")}
>
{/* Property Key Header */}
<div className="font-semibold text-primary py-1 border-b border-neutral-800">
@@ -95,9 +92,7 @@ export function EventProperties({
return (
<div
key={`${property.propertyKey}-${property.propertyValue}`}
- className={`relative ${
- size === "small" ? "h-6" : "h-8"
- } flex items-center hover:bg-neutral-850 group px-2 rounded-md`}
+ className={cn("relative flex items-center hover:bg-neutral-850 group px-2 rounded-md", size === "small" ? "h-6" : "h-8")}
>
<div
className="absolute inset-0 bg-dataviz py-2 opacity-25 rounded-md"
@@ -151,16 +146,12 @@ const EventPropertiesSkeleton = memo(
return (
<div
- className={`flex flex-col gap-4 ${
- size === "small" ? "max-h-[30vh]" : "max-h-[60vh]"
- } overflow-y-auto pr-2`}
+ className={cn("flex flex-col gap-4 overflow-y-auto pr-2", size === "small" ? "max-h-[30vh]" : "max-h-[60vh]")}
>
{Array.from({ length: groupCount }).map((_, groupIndex) => (
<div
key={groupIndex}
- className={`flex flex-col gap-1 ${
- size === "small" ? "text-xs" : "text-sm"
- }`}
+ className={cn("flex flex-col gap-1", size === "small" ? "text-xs" : "text-sm")}
>
{/* Property Key Header Skeleton */}
<div className="font-semibold py-1 border-b border-neutral-800">
@@ -181,9 +172,7 @@ const EventPropertiesSkeleton = memo(
return (
<div
key={propIndex}
- className={`relative ${
- size === "small" ? "h-6" : "h-8"
- } flex items-center px-2 rounded-md`}
+ className={cn("relative flex items-center px-2 rounded-md", size === "small" ? "h-6" : "h-8")}
>
<div
className="absolute inset-0 bg-neutral-800 py-2 opacity-25 rounded-md animate-pulse"
diff --git a/client/src/app/[site]/funnels/components/FunnelRow.tsx b/client/src/app/[site]/funnels/components/FunnelRow.tsx
index 68daeac66..36181e2bd 100644
--- a/client/src/app/[site]/funnels/components/FunnelRow.tsx
+++ b/client/src/app/[site]/funnels/components/FunnelRow.tsx
@@ -29,6 +29,7 @@ import { toast } from "sonner";
import { getStartAndEndDate } from "../../../../api/utils";
import { ThreeDotLoader } from "../../../../components/Loaders";
import { useGetRegionName } from "../../../../lib/geo";
+import { cn } from "../../../../lib/utils";
import {
filterTypeToLabel,
getParameterNameLabel,
@@ -178,12 +179,7 @@ export function FunnelRow({ funnel }: FunnelRowProps) {
{getParameterNameLabel(filter.parameter)}
</span>
<span
- className={`mx-1 ${
- filter.type === "not_equals" ||
- filter.type === "not_contains"
- ? "text-red-400"
- : "text-emerald-400"
- }`}
+ className={cn("mx-1", filter.type === "not_equals" || filter.type === "not_contains" ? "text-red-400" : "text-emerald-400")}
>
{filterTypeToLabel(filter.type)}
</span>
diff --git a/client/src/app/[site]/goals/components/GoalFormModal.tsx b/client/src/app/[site]/goals/components/GoalFormModal.tsx
index 08f2d7d35..0acdcf076 100644
--- a/client/src/app/[site]/goals/components/GoalFormModal.tsx
+++ b/client/src/app/[site]/goals/components/GoalFormModal.tsx
@@ -1,6 +1,14 @@
"use client";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { FileText, MousePointerClick } from "lucide-react";
import { useState } from "react";
+import { useForm } from "react-hook-form";
+import * as z from "zod";
+import { useCreateGoal } from "../../../../api/analytics/useCreateGoal";
+import { Goal } from "../../../../api/analytics/useGetGoals";
+import { useUpdateGoal } from "../../../../api/analytics/useUpdateGoal";
+import { Button } from "../../../../components/ui/button";
import {
Dialog,
DialogContent,
@@ -18,23 +26,9 @@ import {
FormMessage,
} from "../../../../components/ui/form";
import { Input } from "../../../../components/ui/input";
-import { Button } from "../../../../components/ui/button";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "../../../../components/ui/select";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useForm } from "react-hook-form";
-import * as z from "zod";
-import { Goal } from "../../../../api/analytics/useGetGoals";
-import { useCreateGoal } from "../../../../api/analytics/useCreateGoal";
-import { useUpdateGoal } from "../../../../api/analytics/useUpdateGoal";
-import { Switch } from "../../../../components/ui/switch";
import { Label } from "../../../../components/ui/label";
-import { FileText, MousePointerClick } from "lucide-react";
+import { Switch } from "../../../../components/ui/switch";
+import { cn } from "../../../../lib/utils";
// Define form schema
const formSchema = z
@@ -226,9 +220,7 @@ export default function GoalFormModal({
variant={
field.value === "path" ? "default" : "outline"
}
- className={`flex-1 flex items-center justify-center gap-2 ${
- field.value === "path" ? "border-blue-500" : ""
- }`}
+ className={cn("flex-1 flex items-center justify-center gap-2", field.value === "path" && "border-blue-500")}
onClick={() => field.onChange("path")}
>
<FileText className="w-4 h-4 text-blue-500" />
@@ -239,9 +231,7 @@ export default function GoalFormModal({
variant={
field.value === "event" ? "default" : "outline"
}
- className={`flex-1 flex items-center justify-center gap-2 ${
- field.value === "event" ? "border-amber-500" : ""
- }`}
+ className={cn("flex-1 flex items-center justify-center gap-2", field.value === "event" && "border-amber-500")}
onClick={() => field.onChange("event")}
>
<MousePointerClick className="w-4 h-4 text-amber-500" />
diff --git a/client/src/app/[site]/layout.tsx b/client/src/app/[site]/layout.tsx
index 0cde4930b..75a2f6f98 100644
--- a/client/src/app/[site]/layout.tsx
+++ b/client/src/app/[site]/layout.tsx
@@ -1,13 +1,13 @@
"use client";
+import { useWindowSize } from "@uidotdev/usehooks";
import { usePathname } from "next/navigation";
import { useEffect } from "react";
+import { useGetSite, useSiteHasData } from "../../api/admin/sites";
+import { TopBar } from "../../components/TopBar";
import { useStore } from "../../lib/store";
import { useSyncStateWithUrl } from "../../lib/urlParams";
import { Header } from "./components/Header/Header";
-import { useSiteHasData, useGetSite } from "../../api/admin/sites";
-import { TopBar } from "../../components/TopBar";
import { Sidebar } from "./components/Sidebar/Sidebar";
-import { useWindowSize } from "@uidotdev/usehooks";
export default function SiteLayout({
children,
@@ -42,7 +42,7 @@ export default function SiteLayout({
if (width && width < 768) {
return (
- <div className="">
+ <div>
<TopBar />
<Header />
<div>{children}</div>
diff --git a/client/src/app/[site]/main/components/MainSection/MainSection.tsx b/client/src/app/[site]/main/components/MainSection/MainSection.tsx
index 5ffbdada0..991da1f58 100644
--- a/client/src/app/[site]/main/components/MainSection/MainSection.tsx
+++ b/client/src/app/[site]/main/components/MainSection/MainSection.tsx
@@ -1,16 +1,17 @@
"use client";
import { Card, CardContent, CardLoader } from "@/components/ui/card";
+import { Tilt_Warp } from "next/font/google";
+import Image from "next/image";
+import Link from "next/link";
+import { useGetOverview } from "../../../../../api/analytics/useGetOverview";
+import { useGetOverviewBucketed } from "../../../../../api/analytics/useGetOverviewBucketed";
+import { authClient } from "../../../../../lib/auth";
+import { useStore } from "../../../../../lib/store";
+import { cn } from "../../../../../lib/utils";
import { BucketSelection } from "./BucketSelection";
import { Chart } from "./Chart";
import { Overview } from "./Overview";
import { PreviousChart } from "./PreviousChart";
-import { useStore } from "../../../../../lib/store";
-import { useGetOverviewBucketed } from "../../../../../api/analytics/useGetOverviewBucketed";
-import { useGetOverview } from "../../../../../api/analytics/useGetOverview";
-import { Tilt_Warp } from "next/font/google";
-import Link from "next/link";
-import Image from "next/image";
-import { authClient } from "../../../../../lib/auth";
const SELECTED_STAT_MAP = {
pageviews: "Pageviews",
@@ -63,7 +64,7 @@ export function MainSection() {
<div className="flex items-center space-x-4">
<Link
href={session.data ? "/" : "https://rybbit.io"}
- className={`text-lg font-semibold flex items-center gap-1.5 ${tilt_wrap.className} opacity-75`}
+ className={cn("text-lg font-semibold flex items-center gap-1.5 opacity-75", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={20} height={20} />
rybbit.io
diff --git a/client/src/app/[site]/main/components/MainSection/Overview.tsx b/client/src/app/[site]/main/components/MainSection/Overview.tsx
index 55e3e357c..7acf27726 100644
--- a/client/src/app/[site]/main/components/MainSection/Overview.tsx
+++ b/client/src/app/[site]/main/components/MainSection/Overview.tsx
@@ -3,13 +3,12 @@
import { Skeleton } from "@/components/ui/skeleton";
import { cn, formatSecondsAsMinutesAndSeconds } from "@/lib/utils";
import NumberFlow from "@number-flow/react";
+import { TrendingDown, TrendingUp } from "lucide-react";
+import { useState } from "react";
import { useGetOverview } from "../../../../../api/analytics/useGetOverview";
-import { StatType, useStore } from "../../../../../lib/store";
import { useGetOverviewBucketed } from "../../../../../api/analytics/useGetOverviewBucketed";
+import { StatType, useStore } from "../../../../../lib/store";
import { SparklinesChart } from "./SparklinesChart";
-import { TrendingDown } from "lucide-react";
-import { TrendingUp } from "lucide-react";
-import { useState } from "react";
const ChangePercentage = ({
current,
@@ -35,12 +34,7 @@ const ChangePercentage = ({
return (
<div
- className={cn(
- "text-xs flex items-center gap-1",
- (reverseColor ? -change : change) > 0
- ? "text-green-400"
- : "text-red-400"
- )}
+ className={cn("text-xs flex items-center gap-1", (reverseColor ? -change : change) > 0 ? "text-green-400" : "text-red-400")}
>
{change > 0 ? (
<TrendingUp className="w-4 h-4" />
@@ -86,15 +80,12 @@ const Stat = ({
return (
<div
- className={cn(
- "flex flex-col cursor-pointer border-r border-neutral-800 last:border-r-0 text-nowrap",
- selectedStat === id && "bg-neutral-850"
- )}
+ className={cn("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="flex flex-col px-3 py-2">
<div className="text-sm font-medium text-muted-foreground">{title}</div>
<div className="text-2xl font-medium flex gap-2 items-center justify-between">
{isLoading ? (
diff --git a/client/src/app/[site]/main/components/sections/Weekdays.tsx b/client/src/app/[site]/main/components/sections/Weekdays.tsx
index 982454ae2..03135fda5 100644
--- a/client/src/app/[site]/main/components/sections/Weekdays.tsx
+++ b/client/src/app/[site]/main/components/sections/Weekdays.tsx
@@ -25,6 +25,7 @@ import {
TooltipTrigger,
} from "../../../../../components/ui/tooltip";
import { StatType, useStore } from "../../../../../lib/store";
+import { cn } from "../../../../../lib/utils";
export function Weekdays() {
const { site } = useStore();
@@ -263,7 +264,7 @@ export function Weekdays() {
<Tooltip key={day}>
<TooltipTrigger asChild>
<div
- className={`flex-1 mx-0.5 ${colorClass} hover:ring-1 hover:ring-emerald-300 transition-all rounded-sm my-0.5`}
+ className={cn("flex-1 mx-0.5 hover:ring-1 hover:ring-emerald-300 transition-all rounded-sm my-0.5", colorClass)}
/>
</TooltipTrigger>
<TooltipContent className="flex flex-col gap-1 p-2">
diff --git a/client/src/app/[site]/map/page.tsx b/client/src/app/[site]/map/page.tsx
index 9289cad47..722a8a14f 100644
--- a/client/src/app/[site]/map/page.tsx
+++ b/client/src/app/[site]/map/page.tsx
@@ -2,9 +2,10 @@
import { Switch } from "@/components/ui/switch";
import { useState } from "react";
+import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
+import { cn } from "../../../lib/utils";
import { MapComponent } from "../components/shared/Map";
import { SubHeader } from "../components/SubHeader/SubHeader";
-import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
export default function MapPage() {
useSetPageTitle("Rybbit · Map");
@@ -19,7 +20,7 @@ export default function MapPage() {
<div className="absolute bottom-2 md:bottom-4 left-2 md:left-4 z-50">
<div className="flex items-center gap-3 bg-neutral-900 rounded-md px-3 py-2 text-sm">
<span
- className={mapMode === "total" ? "text-white" : "text-neutral-400"}
+ className={cn(mapMode === "total" ? "text-white" : "text-neutral-400")}
>
Total Visits
</span>
@@ -31,9 +32,7 @@ export default function MapPage() {
className="data-[state=checked]:bg-accent-400"
/>
<span
- className={
- mapMode === "perCapita" ? "text-white" : "text-neutral-400"
- }
+ className={cn(mapMode === "perCapita" ? "text-white" : "text-neutral-400")}
>
Per Capita
</span>
diff --git a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
index 833bae77a..75b3edee2 100644
--- a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
+++ b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
@@ -5,13 +5,13 @@ import {
} from "@/components/ui/tooltip";
import { FileText, Laptop, MousePointerClick, Smartphone } from "lucide-react";
import { DateTime } from "luxon";
+import Link from "next/link";
import { Event, useGetEvents } from "../../../../api/analytics/useGetEvents";
import { Skeleton } from "../../../../components/ui/skeleton";
-import { getCountryName } from "../../../../lib/utils";
+import { cn, getCountryName } from "../../../../lib/utils";
import { Browser } from "../../components/shared/icons/Browser";
import { CountryFlag } from "../../components/shared/icons/CountryFlag";
import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
-import Link from "next/link";
// DeviceIcon component for displaying mobile/desktop icons
function DeviceIcon({ deviceType }: { deviceType: string }) {
@@ -207,7 +207,7 @@ function EventCardSkeleton() {
<div className="flex items-center gap-2">
<Skeleton className="h-4 w-4 rounded-sm" />
</div>
- <Skeleton className={`h-4 ${getRandomWidth()}`} />
+ <Skeleton className={cn("h-4", getRandomWidth())} />
</div>
{/* Details row */}
diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsx
index efc0fe006..3cc8aa08c 100644
--- a/client/src/app/layout.tsx
+++ b/client/src/app/layout.tsx
@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
import { Toaster } from "../components/ui/sonner";
import { TooltipProvider } from "../components/ui/tooltip";
import { userStore } from "../lib/userStore";
+import { cn } from "../lib/utils";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
@@ -85,7 +86,7 @@ export default function RootLayout({
<html lang="en" className="dark">
<TooltipProvider>
<body
- className={`${inter.className} bg-background text-foreground h-full`}
+ className={cn("bg-background text-foreground h-full", inter.className)}
>
<QueryProvider>{children}</QueryProvider>
<Toaster />
diff --git a/client/src/app/settings/account/components/ChangePassword.tsx b/client/src/app/settings/account/components/ChangePassword.tsx
index 789940802..e158457db 100644
--- a/client/src/app/settings/account/components/ChangePassword.tsx
+++ b/client/src/app/settings/account/components/ChangePassword.tsx
@@ -1,29 +1,29 @@
"use client";
-import { useState, useEffect } from "react";
+import { cn } from "@/lib/utils";
+import {
+ CheckCircle2,
+ KeyRound,
+ ShieldAlert,
+ ShieldCheck,
+ XCircle,
+} from "lucide-react";
+import { useEffect, useState } from "react";
+import { toast } from "sonner";
import { Button } from "../../../../components/ui/button";
-import { authClient } from "../../../../lib/auth";
import {
Dialog,
+ DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
- DialogClose,
} from "../../../../components/ui/dialog";
-import { Label } from "../../../../components/ui/label";
import { Input } from "../../../../components/ui/input";
-import {
- KeyRound,
- CheckCircle2,
- XCircle,
- ShieldAlert,
- ShieldCheck,
-} from "lucide-react";
-import { toast } from "sonner";
-import { cn } from "@/lib/utils";
+import { Label } from "../../../../components/ui/label";
+import { authClient } from "../../../../lib/auth";
export function ChangePassword() {
const [open, setOpen] = useState(false);
@@ -186,14 +186,7 @@ export function ChangePassword() {
<span>New Password</span>
{passwordStrength > 0 && (
<span
- className={cn(
- "text-xs",
- passwordStrength <= 2
- ? "text-red-500"
- : passwordStrength === 3
- ? "text-yellow-500"
- : "text-green-500"
- )}
+ className={cn("text-xs", passwordStrength <= 2 ? "text-red-500" : passwordStrength === 3 ? "text-yellow-500" : "text-green-500")}
>
{passwordStrength <= 2
? "Weak"
@@ -230,25 +223,13 @@ export function ChangePassword() {
{[1, 2, 3, 4].map((index) => (
<div
key={index}
- className={cn(
- "h-1.5 w-1/4 rounded-full transition-colors duration-300",
- index <= passwordStrength
- ? getStrengthColor()
- : "bg-neutral-200 dark:bg-neutral-700"
- )}
+ className={cn("h-1.5 w-1/4 rounded-full transition-colors duration-300", index <= passwordStrength ? getStrengthColor() : "bg-neutral-200 dark:bg-neutral-700")}
/>
))}
</div>
{passwordFeedback && (
<p
- className={cn(
- "text-xs mt-1",
- passwordStrength <= 2
- ? "text-red-500"
- : passwordStrength === 3
- ? "text-yellow-500"
- : "text-green-500"
- )}
+ className={cn("text-xs mt-1", passwordStrength <= 2 ? "text-red-500" : passwordStrength === 3 ? "text-yellow-500" : "text-green-500")}
>
{passwordFeedback}
</p>
diff --git a/client/src/app/settings/account/components/DeleteAccount.tsx b/client/src/app/settings/account/components/DeleteAccount.tsx
index 5b88da0d3..18401ef65 100644
--- a/client/src/app/settings/account/components/DeleteAccount.tsx
+++ b/client/src/app/settings/account/components/DeleteAccount.tsx
@@ -1,7 +1,10 @@
"use client";
+import { useQueryClient } from "@tanstack/react-query";
+import { AlertTriangle } from "lucide-react";
+import { useRouter } from "next/navigation";
import { useState } from "react";
-import { Button } from "../../../../components/ui/button";
+import { toast } from "sonner";
import {
AlertDialog,
AlertDialogAction,
@@ -13,13 +16,11 @@ import {
AlertDialogTitle,
AlertDialogTrigger,
} from "../../../../components/ui/alert-dialog";
-import { authClient } from "../../../../lib/auth";
-import { AlertTriangle } from "lucide-react";
-import { toast } from "sonner";
+import { Button } from "../../../../components/ui/button";
import { Input } from "../../../../components/ui/input";
import { Label } from "../../../../components/ui/label";
-import { useRouter } from "next/navigation";
-import { useQueryClient } from "@tanstack/react-query";
+import { authClient } from "../../../../lib/auth";
+import { cn } from "../../../../lib/utils";
export function DeleteAccount() {
const [isDeleting, setIsDeleting] = useState(false);
@@ -107,7 +108,7 @@ export function DeleteAccount() {
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
- className={`mt-1 ${passwordError ? "border-red-500" : ""}`}
+ className={cn("mt-1", passwordError && "border-red-500")}
disabled={isDeleting}
/>
{passwordError && (
diff --git a/client/src/app/signup/page.tsx b/client/src/app/signup/page.tsx
index 4622ef315..f9611c02e 100644
--- a/client/src/app/signup/page.tsx
+++ b/client/src/app/signup/page.tsx
@@ -29,6 +29,7 @@ import { useSetPageTitle } from "../../hooks/useSetPageTitle";
import { authClient } from "../../lib/auth";
import { DISABLE_SIGNUP, IS_CLOUD } from "../../lib/const";
import { userStore } from "../../lib/userStore";
+import { cn } from "../../lib/utils";
// Animation variants for step transitions
const contentVariants = {
@@ -547,26 +548,10 @@ export default function SignupPage() {
{[1, 2, 3, 4].map((step) => (
<div
key={step}
- className={`flex items-center space-x-3 py-3 ${
- currentStep === step
- ? "text-emerald-400 font-medium"
- : currentStep > step
- ? "text-muted-foreground"
- : "text-muted-foreground/60"
- }`}
+ className={cn("flex items-center space-x-3 py-3", currentStep === step ? "text-emerald-400 font-medium" : currentStep > step ? "text-muted-foreground" : "text-muted-foreground/60")}
>
<div
- className={`
- flex items-center justify-center w-8 h-8 rounded-full
- ${
- currentStep === step
- ? "bg-emerald-600 text-primary-foreground"
- : currentStep > step
- ? "bg-emerald-600/20 text-emerald-400"
- : "bg-muted-foreground/20 text-muted-foreground"
- }
- transition-all duration-300
- `}
+ className={cn("flex items-center justify-center w-8 h-8 rounded-full transition-all duration-300", currentStep === step ? "bg-emerald-600 text-primary-foreground" : currentStep > step ? "bg-emerald-600/20 text-emerald-400" : "bg-muted-foreground/20 text-muted-foreground")}
>
{currentStep > step ? (
<Check className="h-4 w-4" />
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index bc52a6675..39826a54b 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -9,6 +9,7 @@ import { useState } from "react";
import { toast } from "sonner";
import { StandardPage } from "../../components/StandardPage";
import { BACKEND_URL } from "../../lib/const";
+import { cn } from "../../lib/utils";
import { useStripeSubscription } from "../settings/subscription/utils/useStripeSubscription";
// Available event tiers for the slider
@@ -198,21 +199,13 @@ export default function Subscribe() {
<div className="flex gap-3 mb-2 text-sm">
<button
onClick={() => setIsAnnual(false)}
- className={`px-3 py-1 rounded-full transition-colors cursor-pointer ${
- !isAnnual
- ? "bg-emerald-500/20 text-emerald-400 font-medium"
- : "text-neutral-400 hover:text-neutral-200"
- }`}
+ className={cn("px-3 py-1 rounded-full transition-colors cursor-pointer", !isAnnual ? "bg-emerald-500/20 text-emerald-400 font-medium" : "text-neutral-400 hover:text-neutral-200")}
>
Monthly
</button>
<button
onClick={() => setIsAnnual(true)}
- className={`px-3 py-1 rounded-full transition-colors cursor-pointer ${
- isAnnual
- ? "bg-emerald-500/20 text-emerald-400 font-medium"
- : "text-neutral-400 hover:text-neutral-200"
- }`}
+ className={cn("px-3 py-1 rounded-full transition-colors cursor-pointer", isAnnual ? "bg-emerald-500/20 text-emerald-400 font-medium" : "text-neutral-400 hover:text-neutral-200")}
>
Annual
<span className="ml-1 text-xs text-emerald-500">
@@ -251,11 +244,7 @@ export default function Subscribe() {
{EVENT_TIERS.map((tier, index) => (
<span
key={index}
- className={
- eventLimitIndex === index
- ? "font-bold text-emerald-400"
- : ""
- }
+ className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}
>
{typeof tier === "string"
? tier
diff --git a/client/src/components/CodeSnippet.tsx b/client/src/components/CodeSnippet.tsx
index 416b30f82..423d0b3f4 100644
--- a/client/src/components/CodeSnippet.tsx
+++ b/client/src/components/CodeSnippet.tsx
@@ -1,7 +1,7 @@
"use client";
-import * as React from "react";
import { Check, Copy } from "lucide-react";
+import * as React from "react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
@@ -28,11 +28,7 @@ export function CodeSnippet({
return (
<div className="relative">
<pre
- className={cn(
- "overflow-x-auto rounded-lg border-neutral-500 bg-muted p-3 text-wrap",
- "font-mono text-sm",
- className
- )}
+ className={cn("overflow-x-auto rounded-lg border-neutral-500 bg-muted p-3 text-wrap font-mono text-sm", className)}
{...props}
>
{language && (
diff --git a/client/src/components/CopyText.tsx b/client/src/components/CopyText.tsx
index c04b1845b..e96876bcf 100644
--- a/client/src/components/CopyText.tsx
+++ b/client/src/components/CopyText.tsx
@@ -1,12 +1,12 @@
-import { useState, useEffect, ReactNode } from "react";
-import { Copy, Check } from "lucide-react";
-import { cn } from "@/lib/utils";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { cn } from "@/lib/utils";
+import { Check, Copy } from "lucide-react";
+import { ReactNode, useEffect, useState } from "react";
interface CopyTextProps {
text: string;
@@ -68,10 +68,7 @@ export function CopyText({
<TooltipTrigger asChild>
<button
onClick={handleCopy}
- className={cn(
- "p-1 rounded-md transition-colors text-gray-400 hover:text-gray-200 hover:bg-neutral-800 focus:outline-none",
- copyButtonClassName
- )}
+ className={cn("p-1 rounded-md transition-colors text-gray-400 hover:text-gray-200 hover:bg-neutral-800 focus:outline-none", copyButtonClassName)}
aria-label="Copy to clipboard"
>
{copied ? (
diff --git a/client/src/components/Favicon.tsx b/client/src/components/Favicon.tsx
index 6cfa90188..724702039 100644
--- a/client/src/components/Favicon.tsx
+++ b/client/src/components/Favicon.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { cn } from "../lib/utils";
export function Favicon({
domain,
@@ -13,9 +14,7 @@ export function Favicon({
if (imageError) {
return (
<div
- className={`${
- className ?? "w-4 h-4"
- } bg-neutral-700 rounded-full flex items-center justify-center text-xs font-medium text-white`}
+ className={cn("bg-neutral-700 rounded-full flex items-center justify-center text-xs font-medium text-white", className ?? "w-4 h-4")}
>
{firstLetter}
</div>
@@ -25,7 +24,7 @@ export function Favicon({
return (
<img
src={`https://icons.duckduckgo.com/ip3/${domain}.ico`}
- className={className ?? "w-4 h-4"}
+ className={cn(className ?? "w-4 h-4")}
alt={`Favicon for ${domain}`}
onError={() => setImageError(true)}
/>
diff --git a/client/src/components/Logo.tsx b/client/src/components/Logo.tsx
index 7c2020da8..9ddc0320e 100644
--- a/client/src/components/Logo.tsx
+++ b/client/src/components/Logo.tsx
@@ -1,5 +1,6 @@
import { Tilt_Warp } from "next/font/google";
import Image from "next/image";
+import { cn } from "../lib/utils";
const tilt_wrap = Tilt_Warp({
subsets: ["latin"],
@@ -14,7 +15,7 @@ export function Logo({
if (size === "small") {
return (
<div
- className={`flex items-center gap-1.5 ${tilt_wrap.className} text-lg`}
+ className={cn("flex items-center gap-1.5 text-lg", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={22} height={22} />
rybbit.
@@ -25,7 +26,7 @@ export function Logo({
if (size === "medium") {
return (
<div
- className={`flex items-center gap-1.5 ${tilt_wrap.className} text-xl`}
+ className={cn("flex items-center gap-1.5 text-xl", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={24} height={24} />
rybbit.
@@ -36,7 +37,7 @@ export function Logo({
if (size === "large") {
return (
<div
- className={`flex items-center gap-1.5 ${tilt_wrap.className} text-2xl`}
+ className={cn("flex items-center gap-1.5 text-2xl", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={27} height={27} />
rybbit.
@@ -47,7 +48,7 @@ export function Logo({
if (size === "xlarge") {
return (
<div
- className={`flex items-center gap-2 ${tilt_wrap.className} text-3xl`}
+ className={cn("flex items-center gap-2 text-3xl", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={34} height={34} />
rybbit.
@@ -58,7 +59,7 @@ export function Logo({
if (size === "xxlarge") {
return (
<div
- className={`flex items-center gap-2 ${tilt_wrap.className} text-4xl`}
+ className={cn("flex items-center gap-2 text-4xl", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={38} height={38} />
rybbit.
diff --git a/client/src/components/MultiSelect.tsx b/client/src/components/MultiSelect.tsx
index 228030273..a034bc6e7 100644
--- a/client/src/components/MultiSelect.tsx
+++ b/client/src/components/MultiSelect.tsx
@@ -1,5 +1,5 @@
import { forwardRef } from "react";
-import { Props as ReactSelectProps, GroupBase } from "react-select";
+import { GroupBase, Props as ReactSelectProps } from "react-select";
import Creatable from "react-select/creatable";
@@ -21,7 +21,7 @@ export const MultiSelect = forwardRef<any, MultiSelectProps<any>>(
isMulti
unstyled
closeMenuOnSelect={false}
- className={className}
+ className={cn(className)}
classNames={{
control: ({ isFocused }) =>
cn(
diff --git a/client/src/components/Sessions/SessionCard.tsx b/client/src/components/Sessions/SessionCard.tsx
index b9b960018..63483a75d 100644
--- a/client/src/components/Sessions/SessionCard.tsx
+++ b/client/src/components/Sessions/SessionCard.tsx
@@ -1,29 +1,27 @@
-import { memo, useState } from "react";
-import { DateTime } from "luxon";
-import { Browser } from "../../app/[site]/components/shared/icons/Browser";
-import { CountryFlag } from "../../app/[site]/components/shared/icons/CountryFlag";
-import { OperatingSystem } from "../../app/[site]/components/shared/icons/OperatingSystem";
-import { formatter, getCountryName } from "../../lib/utils";
+import { Skeleton } from "@/components/ui/skeleton";
import {
- Laptop,
- Smartphone,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import {
+ ArrowRight,
ChevronDown,
ChevronRight,
- ArrowRight,
- Clock,
FileText,
+ Laptop,
MousePointerClick,
+ Smartphone
} from "lucide-react";
-import Avatar from "boring-avatars";
+import { DateTime } from "luxon";
+import { memo, useState } from "react";
import { GetSessionsResponse } from "../../api/analytics/userSessions";
-import { Skeleton } from "@/components/ui/skeleton";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { SessionDetails } from "./SessionDetails";
+import { Browser } from "../../app/[site]/components/shared/icons/Browser";
+import { CountryFlag } from "../../app/[site]/components/shared/icons/CountryFlag";
+import { OperatingSystem } from "../../app/[site]/components/shared/icons/OperatingSystem";
+import { cn, formatter, getCountryName } from "../../lib/utils";
import { Badge } from "../ui/badge";
+import { SessionDetails } from "./SessionDetails";
interface SessionCardProps {
session: GetSessionsResponse[number];
@@ -274,22 +272,20 @@ export const SessionCardSkeleton = memo(() => {
{/* Entry/Exit paths with randomized widths */}
<div className="items-center ml-3 flex-1 min-w-0 hidden md:flex">
- <Skeleton className={`h-3 max-w-[200px] ${getRandomWidth()}`} />
+ <Skeleton className={cn("h-3 max-w-[200px]", getRandomWidth())} />
<div className="mx-2 flex-shrink-0">
<Skeleton className="h-3 w-3" />
</div>
- <Skeleton className={`h-3 max-w-[200px] ${getRandomWidth()}`} />
+ <Skeleton className={cn("h-3 max-w-[200px]", getRandomWidth())} />
</div>
{/* Time */}
<div className="flex items-center gap-4">
{/* Date/time skeleton */}
- <Skeleton className={`h-3 ${getRandomTimeWidth()}`} />
+ <Skeleton className={cn("h-3", getRandomTimeWidth())} />
{/* Duration skeleton */}
- <Skeleton
- className={`h-3 ${getRandomDurationWidth()} hidden md:block`}
- />
+ <Skeleton className={cn("h-3", getRandomDurationWidth(), "hidden md:block")} />
</div>
{/* Expand icon */}
diff --git a/client/src/components/Sessions/SessionDetails.tsx b/client/src/components/Sessions/SessionDetails.tsx
index d94618e9c..b4ad389d7 100644
--- a/client/src/components/Sessions/SessionDetails.tsx
+++ b/client/src/components/Sessions/SessionDetails.tsx
@@ -1,34 +1,33 @@
-import { DateTime } from "luxon";
-import { Browser } from "../../app/[site]/components/shared/icons/Browser";
-import { CountryFlag } from "../../app/[site]/components/shared/icons/CountryFlag";
-import { OperatingSystem } from "../../app/[site]/components/shared/icons/OperatingSystem";
-import { getCountryName, getLanguageName } from "../../lib/utils";
+import CopyText from "@/components/CopyText";
+import { Alert, AlertDescription } from "@/components/ui/alert";
+import { Badge } from "@/components/ui/badge";
+import { Skeleton } from "@/components/ui/skeleton";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import Avatar from "boring-avatars";
import {
- MonitorSmartphone,
+ ArrowRight,
Clock,
FileText,
- MousePointerClick,
- ArrowRight,
Loader2,
- Smartphone,
Monitor,
- Tablet,
+ MousePointerClick,
+ Smartphone,
+ Tablet
} from "lucide-react";
-import Avatar from "boring-avatars";
+import { DateTime } from "luxon";
+import Link from "next/link";
+import { useParams } from "next/navigation";
+import { memo, useMemo } from "react";
import {
- useGetSessionDetailsInfinite,
- PageviewEvent,
GetSessionsResponse,
+ PageviewEvent,
+ useGetSessionDetailsInfinite,
} from "../../api/analytics/userSessions";
-import { Skeleton } from "@/components/ui/skeleton";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { Badge } from "@/components/ui/badge";
-import { Alert, AlertDescription } from "@/components/ui/alert";
-import Link from "next/link";
-import CopyText from "@/components/CopyText";
-import { memo, useMemo } from "react";
+import { Browser } from "../../app/[site]/components/shared/icons/Browser";
+import { CountryFlag } from "../../app/[site]/components/shared/icons/CountryFlag";
+import { OperatingSystem } from "../../app/[site]/components/shared/icons/OperatingSystem";
+import { cn, getCountryName, getLanguageName } from "../../lib/utils";
import { Button } from "../ui/button";
-import { useParams } from "next/navigation";
// Component to display a single pageview or event
function PageviewItem({
@@ -73,9 +72,7 @@ function PageviewItem({
)}
{/* Connecting line */}
<div
- className={`flex items-center justify-center w-8 h-8 rounded-full ${
- isEvent ? "bg-amber-900/30" : "bg-blue-900/30"
- } border ${isEvent ? "border-amber-500/50" : "border-blue-500/50"}`}
+ className={cn("flex items-center justify-center w-8 h-8 rounded-full border", isEvent ? "bg-amber-900/30 border-amber-500/50" : "bg-blue-900/30 border-blue-500/50")}
>
<span className="text-sm font-medium">{index + 1}</span>
</div>
@@ -200,14 +197,14 @@ const SessionDetailsTimelineSkeleton = memo(
<div className="flex items-center">
<Skeleton className="h-4 w-4 mr-3" />
<Skeleton
- className={`h-4 ${getRandomWidth()} max-w-md mr-4`}
+ className={cn("h-4", getRandomWidth(), "max-w-md mr-4")}
/>
<Skeleton className="h-3 w-16 flex-shrink-0 ml-auto" />
</div>
<div className="mt-1 pl-7">
{Math.random() > 0.5 && (
<Skeleton
- className={`h-3 ${Math.random() > 0.7 ? "w-48" : "w-32"}`}
+ className={cn("h-3", Math.random() > 0.7 ? "w-48" : "w-32")}
/>
)}
</div>
diff --git a/docs/src/app/components/Cards/UserProfiles.jsx b/docs/src/app/components/Cards/UserProfiles.jsx
index 7ee3e94bc..7c4dd267c 100644
--- a/docs/src/app/components/Cards/UserProfiles.jsx
+++ b/docs/src/app/components/Cards/UserProfiles.jsx
@@ -1,8 +1,9 @@
-import { CountryFlag } from "../Country";
+import Avatar from "boring-avatars";
+import { Laptop } from "lucide-react";
+import { cn } from "../../../lib/utils";
import { Browser } from "../Browser";
+import { CountryFlag } from "../Country";
import { OperatingSystem } from "../OperatingSystem";
-import { Laptop } from "lucide-react";
-import Avatar from "boring-avatars";
@@ -83,7 +84,7 @@ export function UserProfiles() {
return (
<div
key={i}
- className={`w-3 h-3 rounded-sm ${bgColor}`}
+ className={cn("w-3 h-3 rounded-sm", bgColor)}
title={`${activityLevel} visits`}
/>
);
diff --git a/docs/src/app/components/Logo.jsx b/docs/src/app/components/Logo.jsx
index b17ff9ab6..ab9ed8f32 100644
--- a/docs/src/app/components/Logo.jsx
+++ b/docs/src/app/components/Logo.jsx
@@ -1,5 +1,6 @@
-import Image from 'next/image'
-import { Tilt_Warp } from "next/font/google"
+import { Tilt_Warp } from "next/font/google";
+import Image from 'next/image';
+import { cn } from '../../lib/utils';
const tilt_wrap = Tilt_Warp({
subsets: ["latin"],
@@ -8,7 +9,7 @@ const tilt_wrap = Tilt_Warp({
export function Logo() {
return (
- <div className={`text-4xl flex items-center gap-3 ${tilt_wrap.className}`}>
+ <div className={cn("text-4xl flex items-center gap-3", tilt_wrap.className)}>
<Image src="/rybbit.png" alt="Rybbit" width={40} height={40} />
rybbit.
</div>
@@ -17,7 +18,7 @@ export function Logo() {
export function SmallLogo() {
return (
- <div className={`text-2xl flex items-center gap-1.5 ${tilt_wrap.className}`}>
+ <div className={cn("text-2xl flex items-center gap-1.5", tilt_wrap.className)}>
<Image src="/rybbit.png" alt="Rybbit" width={32} height={32} />
rybbit.
</div>
diff --git a/docs/src/app/components/PricingSection.jsx b/docs/src/app/components/PricingSection.jsx
index bff220348..87f2f58c0 100644
--- a/docs/src/app/components/PricingSection.jsx
+++ b/docs/src/app/components/PricingSection.jsx
@@ -1,9 +1,10 @@
"use client";
-import Link from "next/link";
import { Slider } from "@/components/ui/slider";
import { Check } from "lucide-react";
+import Link from "next/link";
import { useState } from "react";
+import { cn } from "../../lib/utils";
// Available event tiers for the slider
const EVENT_TIERS = [
@@ -114,21 +115,13 @@ export function PricingSection() {
<div className="flex gap-3 mb-2 text-sm">
<button
onClick={() => setIsAnnual(false)}
- className={`px-3 py-1 rounded-full transition-colors cursor-pointer ${
- !isAnnual
- ? "bg-emerald-500/20 text-emerald-400 font-medium"
- : "text-neutral-400 hover:text-neutral-200"
- } `}
+ className={cn("px-3 py-1 rounded-full transition-colors cursor-pointer", !isAnnual ? "bg-emerald-500/20 text-emerald-400 font-medium" : "text-neutral-400 hover:text-neutral-200")}
>
Monthly
</button>
<button
onClick={() => setIsAnnual(true)}
- className={`px-3 py-1 rounded-full transition-colors cursor-pointer ${
- isAnnual
- ? "bg-emerald-500/20 text-emerald-400 font-medium"
- : "text-neutral-400 hover:text-neutral-200"
- }`}
+ className={cn("px-3 py-1 rounded-full transition-colors cursor-pointer", isAnnual ? "bg-emerald-500/20 text-emerald-400 font-medium" : "text-neutral-400 hover:text-neutral-200")}
>
Annual
<span className="ml-1 text-xs text-emerald-500">
@@ -167,11 +160,7 @@ export function PricingSection() {
{EVENT_TIERS.map((tier, index) => (
<span
key={index}
- className={
- eventLimitIndex === index
- ? "font-bold text-emerald-400"
- : ""
- }
+ className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}
>
{index === EVENT_TIERS.length - 1
? "10M+"
diff --git a/docs/src/app/components/Tweet.tsx b/docs/src/app/components/Tweet.tsx
index 5caa85e06..82e37679d 100644
--- a/docs/src/app/components/Tweet.tsx
+++ b/docs/src/app/components/Tweet.tsx
@@ -1,4 +1,5 @@
/* eslint-disable @next/next/no-img-element */
+import { cn } from "@/lib/utils";
import { Suspense } from "react";
import {
enrichTweet,
@@ -8,8 +9,6 @@ import {
} from "react-tweet";
import { getTweet, type Tweet } from "react-tweet/api";
-import { cn } from "@/lib/utils";
-
interface TwitterIconProps {
className?: string;
[key: string]: unknown;
@@ -23,7 +22,7 @@ const Twitter = ({ className, ...props }: TwitterIconProps) => (
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
- className={className}
+ className={cn(className)}
{...props}
>
<g>
@@ -37,7 +36,7 @@ const Verified = ({ className, ...props }: TwitterIconProps) => (
<svg
aria-label="Verified Account"
viewBox="0 0 24 24"
- className={className}
+ className={cn(className)}
{...props}
>
<g fill="currentColor">
@@ -68,10 +67,7 @@ export const TweetSkeleton = ({
[key: string]: unknown;
}) => (
<div
- className={cn(
- "flex size-full max-h-max min-w-72 flex-col gap-2 rounded-lg border p-4",
- className
- )}
+ className={cn("flex size-full max-h-max min-w-72 flex-col gap-2 rounded-lg border p-4", className)}
{...props}
>
<div className="flex flex-row gap-2">
@@ -90,10 +86,7 @@ export const TweetNotFound = ({
[key: string]: unknown;
}) => (
<div
- className={cn(
- "flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4",
- className
- )}
+ className={cn("flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4", className)}
{...props}
>
<h3>Tweet not found</h3>
@@ -239,10 +232,7 @@ export const MagicTweet = ({
const enrichedTweet = enrichTweet(tweet);
return (
<div
- className={cn(
- "relative flex size-full max-w-lg flex-col gap-2 overflow-hidden rounded-lg border p-4 backdrop-blur-md bg-neutral-900",
- className
- )}
+ className={cn("relative flex size-full max-w-lg flex-col gap-2 overflow-hidden rounded-lg border p-4 backdrop-blur-md bg-neutral-900", className)}
{...props}
>
<TweetHeader tweet={enrichedTweet} />
diff --git a/docs/src/app/layout.jsx b/docs/src/app/layout.jsx
index 77d1ef49b..5825fdf5d 100644
--- a/docs/src/app/layout.jsx
+++ b/docs/src/app/layout.jsx
@@ -1,13 +1,14 @@
/* eslint-env node */
import { Tilt_Warp } from "next/font/google";
import Image from "next/image";
-import { Footer, Layout, Navbar } from "nextra-theme-docs";
+import Link from "next/link";
+import { Layout, Navbar } from "nextra-theme-docs";
import "nextra-theme-docs/style.css";
-import { Head, Banner } from "nextra/components";
+import { Head } from "nextra/components";
import { getPageMap } from "nextra/page-map";
-import "./globals.css";
+import { cn } from "../lib/utils";
import { SmallLogo } from "./components/Logo";
-import Link from "next/link";
+import "./globals.css";
const tilt_wrap = Tilt_Warp({
subsets: ["latin"],
@@ -70,7 +71,7 @@ export default async function RootLayout({ children }) {
<Navbar
logo={
<div
- className={`text-2xl flex items-center gap-1.5 ${tilt_wrap.className}`}
+ className={cn("text-2xl flex items-center gap-1.5", tilt_wrap.className)}
>
<Image src="/rybbit.png" alt="Rybbit" width={30} height={30} />
rybbit.
diff --git a/docs/src/app/page.jsx b/docs/src/app/page.jsx
index 69b6f5c01..eed49f5f5 100644
--- a/docs/src/app/page.jsx
+++ b/docs/src/app/page.jsx
@@ -6,6 +6,7 @@ import {
} from "@/components/ui/accordion";
import { Tilt_Warp } from "next/font/google";
import Link from "next/link";
+import { cn } from "../lib/utils";
import { AdvancedFilters } from "./components/Cards/AdvancedFilters";
import { EventTracking } from "./components/Cards/EventTracking";
import { Funnels } from "./components/Cards/Funnels";
@@ -35,7 +36,7 @@ export default function IndexPage() {
return (
<div className="flex flex-col items-center justify-center overflow-x-hidden">
<h1
- className={`text-4xl md:text-5xl lg:text-7xl font-semibold pt-16 md:pt-24 px-4 tracking-tight max-w-4xl text-center text-transparent bg-clip-text bg-gradient-to-b from-white via-gray-100 to-gray-400 ${tilt_wrap.className}`}
+ className={cn("text-4xl md:text-5xl lg:text-7xl font-semibold pt-16 md:pt-24 px-4 tracking-tight max-w-4xl text-center text-transparent bg-clip-text bg-gradient-to-b from-white via-gray-100 to-gray-400", tilt_wrap.className)}
>
The Open Source Google Analytics Replacement
</h1>
diff --git a/docs/src/components/magicui/animated-shiny-text.tsx b/docs/src/components/magicui/animated-shiny-text.tsx
index 7a8506bae..36687b4e9 100644
--- a/docs/src/components/magicui/animated-shiny-text.tsx
+++ b/docs/src/components/magicui/animated-shiny-text.tsx
@@ -20,17 +20,7 @@ export const AnimatedShinyText: FC<AnimatedShinyTextProps> = ({
"--shiny-width": `${shimmerWidth}px`,
} as CSSProperties
}
- className={cn(
- "mx-auto max-w-md text-neutral-600/70 dark:text-neutral-400/70",
-
- // Shine effect
- "animate-shiny-text bg-clip-text bg-no-repeat [background-position:0_0] [background-size:var(--shiny-width)_100%] [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]",
-
- // Shine gradient
- "bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80",
-
- className,
- )}
+ className={cn("mx-auto max-w-md text-neutral-600/70 dark:text-neutral-400/70 animate-shiny-text bg-clip-text bg-no-repeat [background-position:0_0] [background-size:var(--shiny-width)_100%] [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite] bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80", className)}
{...props}
>
{children}
diff --git a/docs/src/components/magicui/dot-pattern.tsx b/docs/src/components/magicui/dot-pattern.tsx
index f115a1340..c19691cbc 100644
--- a/docs/src/components/magicui/dot-pattern.tsx
+++ b/docs/src/components/magicui/dot-pattern.tsx
@@ -111,10 +111,7 @@ export function DotPattern({
<svg
ref={containerRef}
aria-hidden="true"
- className={cn(
- "pointer-events-none absolute inset-0 h-full w-full",
- className,
- )}
+ className={cn("pointer-events-none absolute inset-0 h-full w-full", className)}
{...props}
>
<defs>
diff --git a/docs/src/components/magicui/marquee.tsx b/docs/src/components/magicui/marquee.tsx
index fa9c129ba..dafc500d0 100644
--- a/docs/src/components/magicui/marquee.tsx
+++ b/docs/src/components/magicui/marquee.tsx
@@ -44,14 +44,7 @@ export function Marquee({
return (
<div
{...props}
- className={cn(
- "group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] [gap:var(--gap)]",
- {
- "flex-row": !vertical,
- "flex-col": vertical,
- },
- className,
- )}
+ className={cn("group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] [gap:var(--gap)]", { "flex-row": !vertical, "flex-col": vertical }, className)}
>
{Array(repeat)
.fill(0)
diff --git a/docs/src/components/magicui/shine-border.tsx b/docs/src/components/magicui/shine-border.tsx
index 45b1c411e..444a97efb 100644
--- a/docs/src/components/magicui/shine-border.tsx
+++ b/docs/src/components/magicui/shine-border.tsx
@@ -53,10 +53,7 @@ export function ShineBorder({
...style,
} as React.CSSProperties
}
- className={cn(
- "pointer-events-none absolute inset-0 size-full rounded-[inherit] will-change-[background-position] motion-safe:animate-shine",
- className,
- )}
+ className={cn("pointer-events-none absolute inset-0 size-full rounded-[inherit] will-change-[background-position] motion-safe:animate-shine", className)}
{...props}
/>
);
diff --git a/docs/src/components/ui/accordion.tsx b/docs/src/components/ui/accordion.tsx
index 4a8cca46b..ad6583506 100644
--- a/docs/src/components/ui/accordion.tsx
+++ b/docs/src/components/ui/accordion.tsx
@@ -1,8 +1,8 @@
"use client"
-import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDownIcon } from "lucide-react"
+import * as React from "react"
import { cn } from "@/lib/utils"
@@ -63,4 +63,4 @@ function AccordionContent({
)
}
-export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
+export { Accordion, AccordionContent, AccordionItem, AccordionTrigger }
diff --git a/docs/src/components/ui/slider.tsx b/docs/src/components/ui/slider.tsx
index 65ee663c8..9755d9f57 100644
--- a/docs/src/components/ui/slider.tsx
+++ b/docs/src/components/ui/slider.tsx
@@ -1,7 +1,7 @@
"use client";
-import * as React from "react";
import * as SliderPrimitive from "@radix-ui/react-slider";
+import * as React from "react";
import { cn } from "@/lib/utils";
@@ -38,15 +38,11 @@ function Slider({
>
<SliderPrimitive.Track
data-slot="slider-track"
- className={cn(
- "bg-neutral-700/60 relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
- )}
+ className="bg-neutral-700/60 relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
>
<SliderPrimitive.Range
data-slot="slider-range"
- className={cn(
- "bg-emerald-500 absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
- )}
+ className="bg-emerald-500 absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
/>
</SliderPrimitive.Track>
{Array.from({ length: _values.length }, (_, index) => (