Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

show favicon for referrer sites, fixed styles in stats box, added feedback box

Steven Tey8dee0371bed1
diff --git a/components/layout/app/list-box.tsx b/components/layout/app/list-box.tsx
index fba7800b38..1e90a82f39 100644
--- a/components/layout/app/list-box.tsx
+++ b/components/layout/app/list-box.tsx
@@ -26,6 +26,7 @@ export default function ListBox() {
projects?.find((project) => project.slug === slug) || {
name: session?.user?.name || session?.user?.email || "User",
slug: "/",
+ domain: "dub.sh",
}
);
}, [router, projects, session]);
@@ -56,9 +57,9 @@ export default function ListBox() {
selected.slug === "/"
? session?.user?.image ||
`https://avatars.dicebear.com/api/micah/${session?.user?.email}.svg`
- : `https://avatar.tobi.sh/${selected.slug}`
+ : `https://www.google.com/s2/favicons?sz=64&domain_url=${selected.domain}`
}
- alt={selected.name}
+ alt={selected.slug}
className="w-8 h-8 flex-shrink-0 rounded-full overflow-hidden border border-gray-300"
width={48}
height={48}
@@ -84,7 +85,7 @@ export default function ListBox() {
leaveTo="transform opacity-0 scale-95"
>
<Listbox.Options className="absolute mt-1 max-h-60 w-60 overflow-auto rounded-md bg-white p-2 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
- {projects.map(({ name, slug }) => (
+ {projects.map(({ name, slug, domain }) => (
<Listbox.Option
key={slug}
className={`relative flex items-center space-x-2 cursor-pointer p-2 rounded-md hover:bg-gray-100 active:scale-95 ${
@@ -93,9 +94,9 @@ export default function ListBox() {
value={{ name, slug }}
>
<BlurImage
- src={`https://avatar.tobi.sh/${slug}`}
- alt={name}
- className="w-7 h-7 flex-shrink-0 rounded-full overflow-hidden border border-gray-300"
+ src={`https://www.google.com/s2/favicons?sz=64&domain_url=${domain}`}
+ alt={slug}
+ className="w-7 h-7 rounded-full overflow-hidden"
width={48}
height={48}
/>
diff --git a/components/stats/clicks.tsx b/components/stats/clicks.tsx
index 92faf8d997..324414f7cf 100644
--- a/components/stats/clicks.tsx
+++ b/components/stats/clicks.tsx
@@ -11,7 +11,7 @@ export default function Clicks({
isValidating: boolean;
}) {
return (
- <div className="max-w-4xl bg-white p-5 sm:p-10 sm:pr-20 shadow-lg sm:rounded-lg border border-gray-100">
+ <div className="max-w-4xl bg-white p-5 sm:p-10 sm:pr-20 sm:shadow-lg sm:rounded-lg border border-gray-200 sm:border-gray-100 ">
<div className="mb-5 text-left">
<div className="flex space-x-1 items-end">
{isValidating ? (
diff --git a/components/stats/devices.tsx b/components/stats/devices.tsx
index b562e27b93..721f993302 100644
--- a/components/stats/devices.tsx
+++ b/components/stats/devices.tsx
@@ -32,9 +32,9 @@ export default function Devices({ data: rawData }: { data: StatsProps }) {
};
return (
- <div className="flex flex-col justify-between bg-white pt-5 shadow-lg sm:rounded-lg border border-gray-100 h-[420px]">
+ <div className="flex flex-col justify-between bg-white pt-5 sm:shadow-lg sm:rounded-lg border border-gray-200 sm:border-gray-100 h-[420px]">
<div
- className="relative overflow-scroll scrollbar-hide px-7"
+ className="relative h-full overflow-scroll scrollbar-hide px-7"
onScroll={handleScroll}
>
<div className="mb-5 flex justify-between">
diff --git a/components/stats/feedback.tsx b/components/stats/feedback.tsx
new file mode 100644
index 0000000000..d1d98d3bcd
--- /dev/null
+++ b/components/stats/feedback.tsx
@@ -0,0 +1,19 @@
+import BlurImage from "@/components/shared/blur-image";
+
+export default function Feedback() {
+ return (
+ <div className="relative bg-white px-7 py-5 sm:shadow-lg sm:rounded-lg border border-gray-200 sm:border-gray-100 h-[420px] overflow-scroll scrollbar-hide">
+ <div className="mb-5 flex">
+ <h1 className="text-xl font-semibold">Feedback</h1>
+ </div>
+ <div className="flex justify-center items-center">
+ <BlurImage
+ src="/static/illustrations/selfie.svg"
+ alt="No links yet"
+ width={250}
+ height={250}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/components/stats/index.tsx b/components/stats/index.tsx
index 7d0b6a97d9..1c5442da04 100644
--- a/components/stats/index.tsx
+++ b/components/stats/index.tsx
@@ -2,9 +2,10 @@ import { useRouter } from "next/router";
import useSWR from "swr";
import Clicks from "@/components/stats/clicks";
import Devices from "@/components/stats/devices";
+import Feedback from "@/components/stats/feedback";
import Locations from "@/components/stats/locations";
-import Toggle from "@/components/stats/toggle";
import Referer from "@/components/stats/referer";
+import Toggle from "@/components/stats/toggle";
import { StatsProps, dummyData } from "@/lib/stats";
import { fetcher } from "@/lib/utils";
@@ -46,6 +47,7 @@ export default function Stats({
<Locations data={data!} />
<Devices data={data!} />
<Referer data={data!} />
+ <Feedback />
</div>
</div>
</div>
diff --git a/components/stats/locations.tsx b/components/stats/locations.tsx
index 2bc1cf81f4..9b3dfdf014 100644
--- a/components/stats/locations.tsx
+++ b/components/stats/locations.tsx
@@ -31,7 +31,7 @@ export default function Locations({ data: rawData }: { data: StatsProps }) {
return (
<div
- className="relative bg-white px-7 py-5 shadow-lg sm:rounded-lg border border-gray-100 h-[420px] overflow-scroll scrollbar-hide"
+ className="relative bg-white px-7 py-5 sm:shadow-lg sm:rounded-lg border border-gray-200 sm:border-gray-100 h-[420px] overflow-scroll scrollbar-hide"
onScroll={handleScroll}
>
<div className="mb-5 flex justify-between">
diff --git a/components/stats/referer.tsx b/components/stats/referer.tsx
index 514e533d7a..cd57a24c9e 100644
--- a/components/stats/referer.tsx
+++ b/components/stats/referer.tsx
@@ -1,10 +1,9 @@
-import { AnimatePresence, motion } from 'framer-motion';
-import { UIEvent, useMemo, useState } from 'react';
-
-import { processRefererData, StatsProps } from '@/lib/stats';
-import { nFormatter } from '@/lib/utils';
-
-import { LoadingDots } from '../shared/icons';
+import { UIEvent, useMemo, useState } from "react";
+import { AnimatePresence, motion } from "framer-motion";
+import BlurImage from "@/components/shared/blur-image";
+import { Link, LoadingDots } from "@/components/shared/icons";
+import { StatsProps, processRefererData } from "@/lib/stats";
+import { nFormatter } from "@/lib/utils";
export default function Referer({ data: rawData }: { data: StatsProps }) {
const data = {
@@ -15,7 +14,7 @@ export default function Referer({ data: rawData }: { data: StatsProps }) {
} else {
return null;
}
- }, [rawData])
+ }, [rawData]),
};
const [scrolled, setScrolled] = useState(false);
@@ -30,32 +29,51 @@ export default function Referer({ data: rawData }: { data: StatsProps }) {
return (
<div
- className="relative bg-white px-7 py-5 shadow-lg rounded-lg border border-gray-100 h-[420px] overflow-scroll scrollbar-hide"
+ className="relative bg-white px-7 py-5 sm:shadow-lg sm:rounded-lg border border-gray-200 sm:border-gray-100 h-[420px] overflow-scroll scrollbar-hide"
onScroll={handleScroll}
>
<div className="mb-5 flex">
<h1 className="text-xl font-semibold">Referrals</h1>
</div>
- <div className={data.refererData && data.refererData.length > 0 ? 'grid gap-4' : 'h-[300px] flex justify-center items-center'}>
+ <div
+ className={
+ data.refererData && data.refererData.length > 0
+ ? "grid gap-4"
+ : "h-[300px] flex justify-center items-center"
+ }
+ >
{data.refererData ? (
data.refererData.length > 0 ? (
data.refererData.map(({ display, count }, idx) => (
<div key={idx} className="flex justify-between items-center">
<div className="relative flex items-center z-10 w-full max-w-[calc(100%-3rem)]">
<span className="flex space-x-2 px-2 items-center z-10">
+ {display === "(direct)" ? (
+ <Link className="w-4 h-4" />
+ ) : (
+ <BlurImage
+ src={`https://www.google.com/s2/favicons?sz=64&domain_url=${display}`}
+ alt={display}
+ width={20}
+ height={20}
+ className="w-4 h-4 rounded-full"
+ />
+ )}
<p className="text-gray-800 text-sm">{display}</p>
</span>
<motion.div
style={{
- width: `${(count / data.totalClicks) * 100}%`
+ width: `${(count / data.totalClicks) * 100}%`,
}}
className="bg-red-100 absolute h-8 origin-left rounded"
- transition={{ ease: 'easeOut', duration: 0.3 }}
- initial={{ transform: 'scaleX(0)' }}
- animate={{ transform: 'scaleX(1)' }}
+ transition={{ ease: "easeOut", duration: 0.3 }}
+ initial={{ transform: "scaleX(0)" }}
+ animate={{ transform: "scaleX(1)" }}
/>
</div>
- <p className="text-gray-600 text-sm z-10">{nFormatter(count)}</p>
+ <p className="text-gray-600 text-sm z-10">
+ {nFormatter(count)}
+ </p>
</div>
))
) : (
@@ -72,7 +90,7 @@ export default function Referer({ data: rawData }: { data: StatsProps }) {
animate={{
opacity: 1,
y: 0,
- transition: { type: 'linear', duration: 0.2 }
+ transition: { type: "linear", duration: 0.2 },
}}
exit={{ opacity: 0, y: 50, transition: { duration: 0 } }}
className="absolute w-full h-8 flex justify-center items-center bottom-0 left-0 right-0 bg-gradient-to-b from-white to-gray-100 text-sm text-gray-500"