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.

Added dark mode

Steven Tey8ba290b546a1
diff --git a/components/copy-button.tsx b/components/copy-button.tsx
index 34ba990ab8..6645eb8f21 100644
--- a/components/copy-button.tsx
+++ b/components/copy-button.tsx
@@ -9,12 +9,12 @@ export default function CopyButton({ url }: { url: string }) {
navigator.clipboard.writeText(url);
setTimeout(() => setCopied(false), 3000);
}}
- className="group p-1.5 rounded-full bg-gray-100 hover:bg-blue-100 transition-all"
+ className="group p-1.5 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-blue-100 dark:hover:bg-blue-700 transition-all"
>
{copied ? (
- <TickIcon className="text-gray-500 group-hover:text-blue-800 transition-all" />
+ <TickIcon className="text-gray-500 dark:text-white group-hover:text-blue-800 dark:group-hover:text-white transition-all" />
) : (
- <CopyIcon className="text-gray-500 group-hover:text-blue-800 transition-all" />
+ <CopyIcon className="text-gray-500 dark:text-white group-hover:text-blue-800 dark:group-hover:text-white transition-all" />
)}
</button>
);
diff --git a/components/link-card.tsx b/components/link-card.tsx
index 79623a6600..af029351ea 100644
--- a/components/link-card.tsx
+++ b/components/link-card.tsx
@@ -30,19 +30,19 @@ export default function LinkCard({
return (
<div
key={key}
- className="flex items-center border border-gray-200 hover:border-black p-3 rounded-md transition-all"
+ className="flex items-center border border-gray-200 dark:border-gray-600 hover:border-black dark:hover:border-white p-3 rounded-md transition-all"
>
<BlurImage
src={`https://logo.clearbit.com/${urlHostname}`}
alt={urlHostname}
- className="w-10 h-10 rounded-full mr-2 border border-gray-200"
+ className="w-10 h-10 rounded-full mr-2 border border-gray-200 dark:border-gray-600"
width={20}
height={20}
/>
<div>
<div className="flex items-center space-x-2 mb-1">
<a
- className="text-blue-800 font-semibold"
+ className="text-blue-800 dark:text-blue-400 font-semibold"
href={shortURL}
target="_blank"
rel="noreferrer"
@@ -50,8 +50,8 @@ export default function LinkCard({
{shortURL.replace(/^https?:\/\//, "")}
</a>
<CopyButton url={shortURL} />
- <div className="rounded-md bg-gray-100 px-2 py-0.5">
- <p className="text-sm text-gray-500">
+ <div className="rounded-md bg-gray-100 dark:bg-gray-800 px-2 py-0.5">
+ <p className="text-sm text-gray-500 dark:text-white">
{isValidating || !clicks ? (
<LoadingDots color="#71717A" />
) : (
@@ -61,7 +61,9 @@ export default function LinkCard({
</p>
</div>
</div>
- <p className="text-sm text-gray-500 truncate w-72">{url}</p>
+ <p className="text-sm text-gray-500 dark:text-gray-400 truncate w-72">
+ {url}
+ </p>
</div>
</div>
);
diff --git a/components/placeholder-card.tsx b/components/placeholder-card.tsx
index 999bb63715..25376d1a07 100644
--- a/components/placeholder-card.tsx
+++ b/components/placeholder-card.tsx
@@ -1,14 +1,14 @@
export default function PlaceholderCard() {
return (
- <div className="flex items-center border border-gray-200 hover:border-black p-3 rounded-md transition-all">
- <div className="w-10 h-10 rounded-full mr-2 bg-gray-200 animate-pulse" />
+ <div className="flex items-center border border-gray-200 dark:border-gray-600 hover:border-black dark:hover:border-white p-3 rounded-md transition-all">
+ <div className="w-10 h-10 rounded-full mr-2 bg-gray-200 dark:bg-gray-600 animate-pulse" />
<div>
<div className="flex items-center space-x-2 mb-2.5">
- <div className="w-28 h-6 rounded-md bg-gray-200 animate-pulse" />
- <div className="w-6 h-6 rounded-full bg-gray-200 animate-pulse" />
- <div className="w-20 h-6 rounded-md bg-gray-200 animate-pulse" />
+ <div className="w-28 h-6 rounded-md bg-gray-200 dark:bg-gray-600 animate-pulse" />
+ <div className="w-6 h-6 rounded-full bg-gray-200 dark:bg-gray-600 animate-pulse" />
+ <div className="w-20 h-6 rounded-md bg-gray-200 dark:bg-gray-600 animate-pulse" />
</div>
- <div className="w-72 h-4 rounded-md bg-gray-200 animate-pulse" />
+ <div className="w-72 h-4 rounded-md bg-gray-200 dark:bg-gray-600 animate-pulse" />
</div>
</div>
);
diff --git a/pages/_document.tsx b/pages/_document.tsx
new file mode 100644
index 0000000000..3ada0990a5
--- /dev/null
+++ b/pages/_document.tsx
@@ -0,0 +1,13 @@
+import { Html, Head, Main, NextScript } from "next/document";
+
+export default function Document() {
+ return (
+ <Html className="min-h-screen bg-white dark:bg-black">
+ <Head />
+ <body>
+ <Main />
+ <NextScript />
+ </body>
+ </Html>
+ );
+}
diff --git a/pages/index.tsx b/pages/index.tsx
index 37bf4a8210..157aff54d5 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -14,75 +14,77 @@ export default function Home() {
);
return (
- <main className="my-20 max-w-md mx-auto">
- <div className="my-5 text-center max-w-md">
- <h1 className="text-6xl font-bold">Dub</h1>
- <p className="text-gray-600 text-xl mt-5">
- An open-source link shortener built with <br />
- <VercelEdgeFunctions /> and{" "}
- <a
- className="text-transparent bg-clip-text bg-gradient-to-r from-green-400 to-green-700
+ <>
+ <main className="my-36 max-w-md mx-auto">
+ <div className="my-5 text-center">
+ <h1 className="text-6xl font-bold text-black dark:text-white">Dub</h1>
+ <p className="text-gray-600 dark:text-white text-xl mt-5">
+ An open-source link shortener built with <br />
+ <VercelEdgeFunctions /> and{" "}
+ <a
+ className="text-transparent bg-clip-text bg-gradient-to-r from-green-400 to-green-700
"
- href="https://upstash.com/redis"
- target="_blank"
- rel="noreferrer"
- >
- Upstash Redis
- </a>
- .
- </p>
- </div>
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- setSaving(true);
- fetch(`/api/links?url=${url}`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (response) => {
- setSaving(false);
- if (response.ok) {
- const json = await response.json();
- setHashes([...hashes, json]);
- setUrl("");
- }
- });
- }}
- >
- <div className="mt-1 relative flex items-center">
- <input
- type="url"
- placeholder="Shorten your link"
- value={url}
- onInput={(e) => {
- setUrl((e.target as HTMLInputElement).value);
- }}
- required
- className="peer shadow-sm focus:outline-none focus:ring-0 border focus:border-black block w-full p-2 text-sm border-gray-200 rounded-md pl-3 pr-12"
- />
- <button
- type="submit"
- disabled={saving}
- className={`${
- saving ? "cursor-not-allowed" : ""
- } absolute inset-y-0 right-0 flex my-1.5 mr-1.5 items-center border border-gray-200 hover:border-gray-700 peer-focus:border-gray-700 rounded px-2 text-sm font-sans font-medium text-gray-400 hover:text-gray-700 peer-focus:text-gray-700`}
- >
- {saving ? <LoadingDots color="#e5e7eb" /> : <p>↵</p>}
- </button>
+ href="https://upstash.com/redis"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Upstash Redis
+ </a>
+ .
+ </p>
</div>
- </form>
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ setSaving(true);
+ fetch(`/api/links?url=${url}`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (response) => {
+ setSaving(false);
+ if (response.ok) {
+ const json = await response.json();
+ setHashes([...hashes, json]);
+ setUrl("");
+ }
+ });
+ }}
+ >
+ <div className="mt-1 relative flex items-center">
+ <input
+ type="url"
+ placeholder="Shorten your link"
+ value={url}
+ onInput={(e) => {
+ setUrl((e.target as HTMLInputElement).value);
+ }}
+ required
+ className="peer shadow-sm focus:outline-none focus:ring-0 bg-white dark:bg-black border focus:border-black dark:focus:border-white block w-full p-2 text-sm border-gray-200 dark:border-gray-600 rounded-md pl-3 pr-12"
+ />
+ <button
+ type="submit"
+ disabled={saving}
+ className={`${
+ saving ? "cursor-not-allowed" : ""
+ } absolute inset-y-0 right-0 flex my-1.5 mr-1.5 items-center border border-gray-200 dark:border-gray-600 hover:border-gray-700 dark:hover:border-white peer-focus:border-gray-700 dark:peer-focus:border-white rounded px-2 text-sm font-sans font-medium text-gray-400 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white peer-focus:text-gray-700 dark:peer-focus:text-white`}
+ >
+ {saving ? <LoadingDots color="#e5e7eb" /> : <p>↵</p>}
+ </button>
+ </div>
+ </form>
- <div className="grid gap-2 mt-3">
- {hashes.length > 0
- ? hashes.map(({ key, url }) => (
- <LinkCard key={key} _key={key} url={url} />
- ))
- : Array.from({ length: 3 }).map((_, i) => (
- <PlaceholderCard key={i} />
- ))}
- </div>
- </main>
+ <div className="grid gap-2 mt-3">
+ {hashes.length > 0
+ ? hashes.map(({ key, url }) => (
+ <LinkCard key={key} _key={key} url={url} />
+ ))
+ : Array.from({ length: 3 }).map((_, i) => (
+ <PlaceholderCard key={i} />
+ ))}
+ </div>
+ </main>
+ </>
);
}