The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added toggle
Steven Tey76b77b036e5d
diff --git a/components/shared/modal.tsx b/components/shared/modal.tsxindex f07981b7f2..576fe79da6 100644--- a/components/shared/modal.tsx+++ b/components/shared/modal.tsx@@ -16,7 +16,7 @@ export default function Modal({const closeModal = useCallback(() => {if (stats) {- router.back();+ router.push("/");} else {setShowModal(false);}@@ -39,7 +39,7 @@ export default function Modal({leaveFrom="opacity-100"leaveTo="opacity-0">- <Dialog.Overlay className="fixed inset-0 bg-gray-100 bg-opacity-10 backdrop-blur" />+ <Dialog.Overlay className="fixed inset-0 bg-gray-100 dark:bg-black bg-opacity-10 backdrop-blur dark:backdrop-blur-none" /></Transition.Child><spandiff --git a/components/stats/index.module.css b/components/stats/index.module.cssindex cad88d34f6..e9e6f3c0dd 100644--- a/components/stats/index.module.css+++ b/components/stats/index.module.css@@ -28,10 +28,10 @@@media (prefers-color-scheme: dark) {.tooltip {background-color: black !important;- border: solid 1px #eaeaea;+ border: solid 1px #52525b;box-shadow: none !important;}.tooltip::after {- border-top-color: black;+ border-top-color: #52525b;}}diff --git a/components/stats/index.tsx b/components/stats/index.tsxindex 48fb5a4155..c3f32049d1 100644--- a/components/stats/index.tsx+++ b/components/stats/index.tsx@@ -1,6 +1,7 @@import dynamic from "next/dynamic";import { Suspense } from "react";import { RawStatsProps } from "@/lib/stats";+import Toggle from "@/components/stats/toggle";import StatsChart from "@/components/stats/stats-chart";const StatsMap = dynamic(() => import("@/components/stats/stats-map"), {suspense: true,@@ -15,6 +16,7 @@ export default function Stats({}) {return (<div className="flex flex-col justify-center items-center my-36">+ <Toggle />{/* @ts-ignore */}<StatsChart _key={_key} stats={stats} /><div className="h-20" />diff --git a/components/stats/stats-chart.tsx b/components/stats/stats-chart.tsxindex a084781185..d06b20fd1a 100644--- a/components/stats/stats-chart.tsx+++ b/components/stats/stats-chart.tsx@@ -68,7 +68,6 @@ const StatsChart = ({return scaleLinear({range: [CHART_HEIGHT, 0],domain: [0, rangeFormatter(Math.max(...clicksData.map((d) => d.count)))],- // domain: [0, rangeFormatter(100)],nice: true,round: true,});@@ -94,23 +93,6 @@ const StatsChart = ({return (<div style={{ width: CHART_WIDTH }}>- <div className="w-full flex justify-end">- <div className="flex space-x-1 p-1 rounded-md shadow-md border-gray-100">- {["1h", "24h", "7d", "30d"].map((int) => (- <button- key={int}- className={`${- interval === int- ? "border-blue-600 bg-blue-50"- : "border-transparent"- } w-14 py-1.5 border text-sm rounded-md transition-all`}- onClick={() => setInterval(int as IntervalProps)}- >- {int}- </button>- ))}- </div>- </div><figure className="flex my-10"><svg ref={containerRef} height={CHART_HEIGHT} width={LEFT_AXIS_WIDTH}><AxisLeft@@ -202,13 +184,13 @@ const StatsChart = ({className={styles.tooltip}><div className="text-center">- <h3 className="text-black my-1">+ <h3 className="text-black dark:text-white my-1"><span className="text-2xl font-semibold">{nFormatter(tooltipData.count)}</span>{" "}clicks</h3>- <p className="text-xs text-gray-600">+ <p className="text-xs text-gray-600 dark:text-gray-400">{intervalData[interval].format(tooltipData.start)} -{" "}{intervalData[interval].format(tooltipData.end)}</p>diff --git a/components/stats/stats-map.tsx b/components/stats/stats-map.tsxindex ec2a855327..1cd2a34139 100644--- a/components/stats/stats-map.tsx+++ b/components/stats/stats-map.tsx@@ -106,13 +106,15 @@ const StatsMap = ({className={styles.tooltip}><div className="text-center">- <h3 className="text-black my-1">+ <h3 className="text-black dark:text-white my-1"><span className="text-2xl font-semibold">{nFormatter(tooltipData.count)}</span>{" "}clicks</h3>- <p className="text-xs text-gray-600">{tooltipData.country}</p>+ <p className="text-xs text-gray-600 dark:text-gray-400">+ {tooltipData.country}+ </p></div></TooltipInPortal></>diff --git a/components/stats/stats-modal.tsx b/components/stats/stats-modal.tsxindex 0d812ec450..8391a04071 100644--- a/components/stats/stats-modal.tsx+++ b/components/stats/stats-modal.tsx@@ -16,7 +16,7 @@ export default function StatsModal({}) {return (<Modal showModal={showStatsModal} setShowModal={setShowStatsModal}>- <div className="inline-block w-full max-w-screen-xl max-h-[calc(100vh-100px)] py-8 px-4 sm:px-16 overflow-scroll text-center align-middle transition-all transform bg-white shadow-xl rounded-2xl">+ <div className="inline-block w-full max-w-screen-xl max-h-[calc(100vh-100px)] py-8 px-4 sm:px-16 overflow-scroll text-center align-middle transform bg-white dark:bg-black border dark:border-gray-600 shadow-xl dark:shadow-none rounded-2xl"><Stats _key={_key} stats={stats} /></div></Modal>diff --git a/components/stats/toggle.tsx b/components/stats/toggle.tsxnew file mode 100644index 0000000000..1e35516eff--- /dev/null+++ b/components/stats/toggle.tsx@@ -0,0 +1,38 @@+import { useRouter } from "next/router";+import { PERIODS } from "@/lib/constants";++export default function Toggle() {+ const router = useRouter();+ return (+ <div className="w-3/4 flex justify-end">+ <div className="flex space-x-1 p-1 rounded-md shadow-md dark:shadow-none border border-gray-100 dark:border-gray-600">+ {PERIODS.map((period) => (+ <button+ key={period}+ className={`${+ router.query.period === period+ ? "bg-blue-50 dark:bg-gray-600"+ : ""+ } w-14 py-1.5 text-sm dark:text-white rounded-md transition-all`}+ onClick={() => {+ router.push(+ {+ query: {+ ...router.query,+ period,+ },+ },+ `/stats/${encodeURI(+ router.query.stats as string+ )}?period=${period}`,+ { shallow: true }+ );+ }}+ >+ {period}+ </button>+ ))}+ </div>+ </div>+ );+}diff --git a/lib/constants.ts b/lib/constants.tsindex 2e42d77bf8..131d4fac14 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -5,3 +5,5 @@ export const LOCALHOST_GEO_DATA = {latitude: "37.7695",longitude: "-122.385",};++export const PERIODS = ["1h", "24h", "7d", "30d"];