🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Add nice looking card loader
Bill Yang50e6e292772c
diff --git a/client/package-lock.json b/client/package-lock.jsonindex 407d5b8f2..1b7c0355e 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -24,6 +24,7 @@"@types/lodash": "^4.17.15","@types/luxon": "^3.4.2","@types/pg": "^8.11.11",+ "@uidotdev/usehooks": "^2.4.1","class-variance-authority": "^0.7.1","clsx": "^2.1.1","countries-list": "^3.1.1",@@ -31,6 +32,7 @@"date-fns": "^4.1.0","drizzle-orm": "^0.38.4","geojson": "^0.5.0",+ "ldrs": "^1.0.2","leaflet": "^1.9.4","lodash": "^4.17.21","lucide-react": "^0.474.0",@@ -2850,6 +2852,18 @@"@types/react": "^19.0.0"}},+ "node_modules/@uidotdev/usehooks": {+ "version": "2.4.1",+ "resolved": "https://registry.npmjs.org/@uidotdev/usehooks/-/usehooks-2.4.1.tgz",+ "integrity": "sha512-1I+RwWyS+kdv3Mv0Vmc+p0dPYH0DTRAo04HLyXReYBL9AeseDWUJyi4THuksBJcu9F0Pih69Ak150VDnqbVnXg==",+ "engines": {+ "node": ">=16"+ },+ "peerDependencies": {+ "react": ">=18.0.0",+ "react-dom": ">=18.0.0"+ }+ },"node_modules/ansi-regex": {"version": "6.1.0","resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",@@ -3943,6 +3957,11 @@"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz","integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="},+ "node_modules/ldrs": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/ldrs/-/ldrs-1.0.2.tgz",+ "integrity": "sha512-sYJmivdkIiHrUEqTrEWccBoLdaENpzbzkABI5rk8rRxTXrg9i2xVuDvUUuhOhJY3RmQyaoxs046pM1DCRdcIpg=="+ },"node_modules/leaflet": {"version": "1.9.4","resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",diff --git a/client/package.json b/client/package.jsonindex 2d24a96a8..13832dc83 100644--- a/client/package.json+++ b/client/package.json@@ -25,6 +25,7 @@"@types/lodash": "^4.17.15","@types/luxon": "^3.4.2","@types/pg": "^8.11.11",+ "@uidotdev/usehooks": "^2.4.1","class-variance-authority": "^0.7.1","clsx": "^2.1.1","countries-list": "^3.1.1",@@ -32,6 +33,7 @@"date-fns": "^4.1.0","drizzle-orm": "^0.38.4","geojson": "^0.5.0",+ "ldrs": "^1.0.2","leaflet": "^1.9.4","lodash": "^4.17.21","lucide-react": "^0.474.0",diff --git a/client/src/app/components/MainSection/MainSection.tsx b/client/src/app/components/MainSection/MainSection.tsxindex 91df40928..7156704ea 100644--- a/client/src/app/components/MainSection/MainSection.tsx+++ b/client/src/app/components/MainSection/MainSection.tsx@@ -1,5 +1,5 @@"use client";-import { Card, CardContent } from "@/components/ui/card";+import { Card, CardContent, CardLoader } from "@/components/ui/card";import { useTimeSelection } from "../../../lib/timeSelectionStore";import { useGetPageviews } from "../../hooks/useGetPageviews";import { BucketSelection } from "./BucketSelection";@@ -10,6 +10,7 @@ export function MainSection() {return (<Card>+ {isLoading && <CardLoader />}<CardContent className="pt-4 w-full"><BucketSelection /><div className="h-[350px]">diff --git a/client/src/app/components/sections/Browsers/Browsers.tsx b/client/src/app/components/sections/Browsers/Browsers.tsxindex abd4711a6..43d5dafe4 100644--- a/client/src/app/components/sections/Browsers/Browsers.tsx+++ b/client/src/app/components/sections/Browsers/Browsers.tsx@@ -60,6 +60,7 @@ export function Browsers() {<StandardCardtitle="Browsers"data={data}+ isLoading={isLoading}getKey={(e) => e.browser}getLabel={(e) => (<div className="flex gap-2 items-center">diff --git a/client/src/app/components/sections/Countries/Countries.tsx b/client/src/app/components/sections/Countries/Countries.tsxindex 23bb98903..0c06e3ad1 100644--- a/client/src/app/components/sections/Countries/Countries.tsx+++ b/client/src/app/components/sections/Countries/Countries.tsx@@ -13,6 +13,7 @@ export function Countries() {<StandardCardtitle="Countries"data={data}+ isLoading={isLoading}getKey={(e) => e.country}getLabel={(e) => (<span className="flex items-center gap-2">diff --git a/client/src/app/components/sections/Devices/Devices.tsx b/client/src/app/components/sections/Devices/Devices.tsxindex 3ee2743ae..d38f3aeaf 100644--- a/client/src/app/components/sections/Devices/Devices.tsx+++ b/client/src/app/components/sections/Devices/Devices.tsx@@ -7,6 +7,7 @@ export function Devices() {const { data, isLoading } = useGetDevices();return (<StandardCard+ isLoading={isLoading}title="Devices"data={data}getKey={(e) => e.device_type}diff --git a/client/src/app/components/sections/Map/Map.tsx b/client/src/app/components/sections/Map/Map.tsxindex 0240278d1..c49159dac 100644--- a/client/src/app/components/sections/Map/Map.tsx+++ b/client/src/app/components/sections/Map/Map.tsx@@ -14,6 +14,7 @@ import {Card,CardContent,CardHeader,+ CardLoader,CardTitle,} from "../../../../components/ui/card";import { countries } from "countries-list";@@ -46,6 +47,7 @@ export function Map() {return (<Card>+ {isLoading && <CardLoader />}<CardHeader><CardTitle>Map</CardTitle></CardHeader>diff --git a/client/src/app/components/sections/OperatingSystems/OperatingSystems.tsx b/client/src/app/components/sections/OperatingSystems/OperatingSystems.tsxindex c7e3da1fb..c57df360d 100644--- a/client/src/app/components/sections/OperatingSystems/OperatingSystems.tsx+++ b/client/src/app/components/sections/OperatingSystems/OperatingSystems.tsx@@ -26,6 +26,7 @@ export function OperatingSystems() {<StandardCardtitle="Operating Systems"data={data}+ isLoading={isLoading}getKey={(e) => e.operating_system}getLabel={(e) => (<div className="flex gap-2 items-center">diff --git a/client/src/app/components/sections/Pages/Pages.tsx b/client/src/app/components/sections/Pages/Pages.tsxindex e5c066199..bbb0b7c48 100644--- a/client/src/app/components/sections/Pages/Pages.tsx+++ b/client/src/app/components/sections/Pages/Pages.tsx@@ -9,6 +9,7 @@ export function Pages() {<StandardCardtitle="Pages"data={data}+ isLoading={isLoading}getKey={(e) => e.pathname}getLabel={(e) => e.pathname || "Other"}/>diff --git a/client/src/app/components/sections/Referrers/Referrers.tsx b/client/src/app/components/sections/Referrers/Referrers.tsxindex 22548c3bf..54336400e 100644--- a/client/src/app/components/sections/Referrers/Referrers.tsx+++ b/client/src/app/components/sections/Referrers/Referrers.tsx@@ -10,6 +10,7 @@ export function Referrers() {title="Referrers"data={data}getKey={(e) => e.referrer}+ isLoading={isLoading}getLabel={(e) => (<div className="flex items-center"><imgdiff --git a/client/src/app/components/shared/StandardCard.tsx b/client/src/app/components/shared/StandardCard.tsxindex 6da89444c..edcf94c13 100644--- a/client/src/app/components/shared/StandardCard.tsx+++ b/client/src/app/components/shared/StandardCard.tsx@@ -6,12 +6,12 @@ import {Card,CardContent,CardHeader,+ CardLoader,CardTitle,} from "../../../components/ui/card";import {Dialog,DialogContent,- DialogDescription,DialogHeader,DialogTitle,DialogTrigger,@@ -22,6 +22,7 @@ export function StandardCard<T extends { percentage: number; count: number }>({data,getKey,getLabel,+ isLoading,}: {title: string;data:@@ -30,11 +31,13 @@ export function StandardCard<T extends { percentage: number; count: number }>({error?: string;}| undefined;+ isLoading?: boolean;getKey: (item: T) => string;getLabel: (item: T) => ReactNode;}) {return (<Card>+ {isLoading && <CardLoader />}<CardHeader><CardTitle>{title}</CardTitle></CardHeader>diff --git a/client/src/components/ui/card.tsx b/client/src/components/ui/card.tsxindex 4caa131fd..d94bc9ea7 100644--- a/client/src/components/ui/card.tsx+++ b/client/src/components/ui/card.tsx@@ -1,6 +1,9 @@import * as React from "react";-+import { zoomies } from "ldrs";import { cn } from "@/lib/utils";+import { useMeasure } from "@uidotdev/usehooks";++zoomies.register();const Card = React.forwardRef<HTMLDivElement,@@ -9,7 +12,7 @@ const Card = React.forwardRef<<divref={ref}className={cn(- "rounded-xl border border-neutral-200 bg-white text-neutral-950 dark:border-neutral-850 dark:bg-neutral-900 dark:text-neutral-50",+ "rounded-xl border border-neutral-200 bg-white text-neutral-950 dark:border-neutral-850 dark:bg-neutral-900 dark:text-neutral-50 overflow-hidden",className)}{...props}@@ -17,6 +20,26 @@ const Card = React.forwardRef<));Card.displayName = "Card";+const CardLoader = React.forwardRef<+ HTMLDivElement,+ React.HTMLAttributes<HTMLDivElement>+>(({ className, ...props }, ref) => {+ const [ref2, { width }] = useMeasure();+ return (+ <div ref={ref2} className="mt-[-15px]">+ {/* @ts-ignore */}+ <l-zoomies+ size={width}+ stroke="3"+ bg-opacity="0.1"+ speed="1.4"+ color="hsl(var(--fuchsia-400))"+ />+ </div>+ );+});+CardLoader.displayName = "CardLoader";+const CardHeader = React.forwardRef<HTMLDivElement,React.HTMLAttributes<HTMLDivElement>@@ -75,6 +98,7 @@ CardFooter.displayName = "CardFooter";export {Card,+ CardLoader,CardHeader,CardFooter,CardTitle,diff --git a/client/src/components/ui/spinner.tsx b/client/src/components/ui/spinner.tsxdeleted file mode 100644index f9dc6cc3b..000000000--- a/client/src/components/ui/spinner.tsx+++ /dev/null@@ -1,26 +0,0 @@-import { cn } from "../../lib/utils";--export interface ISVGProps extends React.SVGProps<SVGSVGElement> {- size?: number;- className?: string;-}--export const Spinner = ({ size = 24, className, ...props }: ISVGProps) => {- return (- <svg- xmlns="http://www.w3.org/2000/svg"- width={size}- height={size}- {...props}- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- className={cn("animate-spin", className)}- >- <path d="M21 12a9 9 0 1 1-6.219-8.56" />- </svg>- );-};