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.

standardized logo and modal everywhere

Steven Tey3369578dac52
diff --git a/app/app/(auth)/login/page.tsx b/app/app/(auth)/login/page.tsx
index 0964db31a8..b5a89276bb 100644
--- a/app/app/(auth)/login/page.tsx
+++ b/app/app/(auth)/login/page.tsx
@@ -1,7 +1,7 @@
import { Suspense } from "react";
import LoginForm from "./form";
import Button from "#/ui/button";
-import { Logo } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
import { constructMetadata } from "#/lib/utils";
export const metadata = constructMetadata({
diff --git a/app/app/(auth)/register/page.tsx b/app/app/(auth)/register/page.tsx
index 54d309efec..64dd42442f 100644
--- a/app/app/(auth)/register/page.tsx
+++ b/app/app/(auth)/register/page.tsx
@@ -1,7 +1,7 @@
import { Suspense } from "react";
import RegisterForm from "./form";
import Button from "#/ui/button";
-import { Logo } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
import { constructMetadata } from "#/lib/utils";
export const metadata = constructMetadata({
diff --git a/app/dub.sh/@modal/(.)stats/[key]/page.tsx b/app/dub.sh/@modal/(.)stats/[key]/page.tsx
index 8284508fa9..0189f0118c 100644
--- a/app/dub.sh/@modal/(.)stats/[key]/page.tsx
+++ b/app/dub.sh/@modal/(.)stats/[key]/page.tsx
@@ -4,15 +4,10 @@ import { Suspense } from "react";
export default function StatsModal({ params }: { params: { key: string } }) {
return (
- <Modal className="bg-gray-50">
- <div
- className="max-h-[calc(100vh-150px)] w-full overflow-scroll bg-gray-50 align-middle shadow-xl
- scrollbar-hide md:w-[768px] md:rounded-2xl md:border md:border-gray-200 lg:w-[1024px] xl:w-[1280px]"
- >
- <Suspense>
- <Stats staticDomain="dub.sh" staticKey={params.key} modal />
- </Suspense>
- </div>
+ <Modal className="max-h-[calc(100vh-150px)] w-full max-w-screen-xl overflow-auto bg-gray-50 scrollbar-hide">
+ <Suspense>
+ <Stats staticDomain="dub.sh" staticKey={params.key} modal />
+ </Suspense>
</Modal>
);
}
diff --git a/app/protected/[domain]/[key]/page.tsx b/app/protected/[domain]/[key]/page.tsx
index 1adf01f605..e5ceac2879 100644
--- a/app/protected/[domain]/[key]/page.tsx
+++ b/app/protected/[domain]/[key]/page.tsx
@@ -1,5 +1,5 @@
import { constructMetadata } from "#/lib/utils";
-import BlurImage from "#/ui/blur-image";
+import { Logo } from "#/ui/icons";
import PasswordForm from "./form";
const title = "Password Required";
@@ -19,13 +19,7 @@ export default function PasswordProtectedLinkPage() {
<div className="w-full max-w-md overflow-hidden rounded-2xl border border-gray-100 shadow-xl">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 py-6 pt-8 text-center sm:px-16">
<a href="https://dub.sh" target="_blank" rel="noreferrer">
- <BlurImage
- src="/_static/logo.png"
- alt="Dub.sh logo"
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
+ <Logo />
</a>
<h3 className="text-xl font-semibold">{title}</h3>
<p className="text-sm text-gray-500">{description}</p>
diff --git a/app/ui/home/footer.tsx b/app/ui/home/footer.tsx
index 97b0e882c0..de13aeb462 100644
--- a/app/ui/home/footer.tsx
+++ b/app/ui/home/footer.tsx
@@ -1,7 +1,8 @@
"use client";
import Link from "next/link";
-import { Github, LinkedIn, Logo, Twitter } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
+import { Github, LinkedIn, Twitter } from "@/components/shared/icons";
import { useParams } from "next/navigation";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
import va from "@vercel/analytics";
diff --git a/app/ui/icons/index.tsx b/app/ui/icons/index.tsx
index cbbea518bc..37d459ff9d 100644
--- a/app/ui/icons/index.tsx
+++ b/app/ui/icons/index.tsx
@@ -2,4 +2,5 @@ export { default as ExpandingArrow } from "./expanding-arrow";
export { default as LoadingCircle } from "./loading-circle";
export { default as LoadingDots } from "./loading-dots";
export { default as LoadingSpinner } from "./loading-spinner";
+export { default as Logo } from "./logo";
export { default as LogoType } from "./logotype";
diff --git a/app/ui/icons/logo.tsx b/app/ui/icons/logo.tsx
new file mode 100644
index 0000000000..bc3295ada4
--- /dev/null
+++ b/app/ui/icons/logo.tsx
@@ -0,0 +1,29 @@
+import { cn } from "#/lib/utils";
+
+export default function Logo({ className }: { className?: string }) {
+ return (
+ <svg
+ width="191"
+ height="191"
+ viewBox="0 0 191 191"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("h-10 w-10 text-black", className)}
+ >
+ <g clipPath="url(#clip0_1301_107)">
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M122 -14H144 9.17859 129.788 5.96937 122 3.72462V-14ZM122 3.72462C113.586 1.29941 104.695 0 95.5 0C42.7568 0 0 42.7568 0 95.5C0 148.243 42.7568 191 95.5 191C148.243 191 191 148.243 191 95.5C191 60.462 172.131 29.8311 144 13.2146V100V148H122V140.897C114.258 146.018 104.977 149 95 149C67.938 149 46 127.062 46 100C46 72.938 67.938 51 95 51C104.977 51 114.258 53.982 122 59.1034V3.72462Z"
+ fill="currentColor"
+ shapeRendering="geometricPrecision"
+ />
+ </g>
+ <defs>
+ <clipPath id="clip0_1301_107">
+ <rect width="191" height="191" rx="95.5" fill="white" />
+ </clipPath>
+ </defs>
+ </svg>
+ );
+}
diff --git a/app/ui/modal.tsx b/app/ui/modal.tsx
index ba6485c283..ec26e13f2d 100644
--- a/app/ui/modal.tsx
+++ b/app/ui/modal.tsx
@@ -23,7 +23,6 @@ export default function Modal({
}) {
const router = useRouter();
const mobileModalRef = useRef<HTMLDivElement | null>(null);
- const desktopModalRef = useRef<HTMLDivElement | null>(null);
const closeModal = ({ dragged }: { dragged?: boolean } = {}) => {
if (disableDefaultHide && !dragged) {
@@ -94,7 +93,7 @@ export default function Modal({
<motion.div
ref={mobileModalRef}
key="mobile-modal"
- className="group fixed inset-x-0 bottom-0 z-40 max-h-[80vh] w-screen cursor-grab active:cursor-grabbing md:hidden"
+ className="rounded-t-4xl group fixed inset-x-0 bottom-0 z-40 max-h-[80vh] w-screen cursor-grab overflow-scroll bg-white active:cursor-grabbing md:hidden"
initial={{ y: "100%" }}
animate={controls}
exit={{ y: "100%" }}
@@ -105,24 +104,21 @@ export default function Modal({
dragElastic={{ top: 0, bottom: 1 }}
dragConstraints={{ top: 0, bottom: 0 }}
>
- <div
- className={cn(
- "rounded-t-4xl -mb-1 flex h-7 w-full items-center justify-center border-t border-gray-200 bg-white",
- className,
- )}
- >
+ <div className="rounded-t-4xl sticky top-0 z-20 flex h-7 w-full items-center justify-center border-t border-gray-200">
<div className="-mr-1 h-1 w-6 rounded-full bg-gray-300 transition-all group-active:rotate-12" />
<div className="h-1 w-6 rounded-full bg-gray-300 transition-all group-active:-rotate-12" />
</div>
{children}
</motion.div>
- <motion.div
- ref={desktopModalRef}
+ <motion.dialog
key="desktop-modal"
- className="fixed inset-0 z-40 m-auto hidden max-h-fit max-w-fit animate-scale-in md:block"
+ className={cn(
+ "fixed inset-0 z-40 m-auto hidden max-h-fit w-full max-w-md animate-scale-in overflow-hidden rounded-2xl border border-gray-200 bg-white p-0 shadow-xl md:block",
+ className,
+ )}
>
{children}
- </motion.div>
+ </motion.dialog>
<motion.div
id="modal-backdrop"
key="backdrop"
diff --git a/app/ui/modals/add-edit-link-modal/index.tsx b/app/ui/modals/add-edit-link-modal/index.tsx
index 0fa1d6b261..b87107750c 100644
--- a/app/ui/modals/add-edit-link-modal/index.tsx
+++ b/app/ui/modals/add-edit-link-modal/index.tsx
@@ -258,9 +258,10 @@ function AddEditLinkModal({
<Modal
showModal={showAddEditLinkModal}
setShowModal={setShowAddEditLinkModal}
+ className="max-w-screen-lg"
disableDefaultHide={homepageDemo ? false : true}
>
- <div className="relative grid max-h-[80vh] w-full divide-x divide-gray-100 overflow-scroll bg-white shadow-xl transition-all scrollbar-hide md:max-h-[min(906px,_90vh)] md:max-w-screen-lg md:grid-cols-2 md:rounded-2xl md:border md:border-gray-200">
+ <div className="relative grid max-h-[80vh] divide-x divide-gray-100 overflow-scroll scrollbar-hide md:max-h-[min(906px,_90vh)] md:grid-cols-2">
{!hideXButton && !homepageDemo && (
<button
onClick={() => setShowAddEditLinkModal(false)}
diff --git a/app/ui/modals/link-qr-modal.tsx b/app/ui/modals/link-qr-modal.tsx
index fbdbc18db8..c24a0f4e0f 100644
--- a/app/ui/modals/link-qr-modal.tsx
+++ b/app/ui/modals/link-qr-modal.tsx
@@ -10,7 +10,8 @@ import {
} from "react";
import { HexColorInput, HexColorPicker } from "react-colorful";
import BlurImage from "#/ui/blur-image";
-import { Clipboard } from "@/components/shared/icons";
+import { Clipboard, Download, Photo } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
import { ChevronRight } from "lucide-react";
import Modal from "#/ui/modal";
import Switch from "#/ui/switch";
@@ -20,7 +21,6 @@ import useProject from "#/lib/hooks/use-project";
import { SimpleLinkProps } from "#/lib/types";
import { getApexDomain, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import { Download, Photo } from "@/components/shared/icons";
import Popover from "#/ui/popover";
import { toast } from "sonner";
import { GOOGLE_FAVICON_URL } from "#/lib/constants";
@@ -105,77 +105,79 @@ function LinkQRModalHelper({
return (
<Modal showModal={showLinkQRModal} setShowModal={setShowLinkQRModal}>
- <div className="inline-block w-full transform bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ {avatarUrl ? (
<BlurImage
- src={avatarUrl || "/_static/logo.png"}
+ src={avatarUrl}
alt={apexDomain}
className="h-10 w-10 rounded-full"
width={40}
height={40}
/>
- <h3 className="text-lg font-medium">Download QR Code</h3>
- </div>
+ ) : (
+ <Logo />
+ )}
+ <h3 className="text-lg font-medium">Download QR Code</h3>
+ </div>
- <div className="flex flex-col space-y-6 bg-gray-50 py-6 text-left sm:rounded-b-2xl">
- <div className="mx-auto rounded-lg border-2 border-gray-200 bg-white p-4">
- <QRCodeSVG
- value={qrData.value}
- size={qrData.size / 8}
- bgColor={qrData.bgColor}
- fgColor={qrData.fgColor}
- level={qrData.level}
- includeMargin={false}
- // @ts-ignore
- imageSettings={
- showLogo && {
- ...qrData.imageSettings,
- height: qrData.imageSettings
- ? qrData.imageSettings.height / 8
- : 0,
- width: qrData.imageSettings
- ? qrData.imageSettings.width / 8
- : 0,
- }
+ <div className="flex flex-col space-y-6 bg-gray-50 py-6 text-left sm:rounded-b-2xl">
+ <div className="mx-auto rounded-lg border-2 border-gray-200 bg-white p-4">
+ <QRCodeSVG
+ value={qrData.value}
+ size={qrData.size / 8}
+ bgColor={qrData.bgColor}
+ fgColor={qrData.fgColor}
+ level={qrData.level}
+ includeMargin={false}
+ // @ts-ignore
+ imageSettings={
+ showLogo && {
+ ...qrData.imageSettings,
+ height: qrData.imageSettings
+ ? qrData.imageSettings.height / 8
+ : 0,
+ width: qrData.imageSettings
+ ? qrData.imageSettings.width / 8
+ : 0,
}
- />
- </div>
-
- <AdvancedSettings
- qrData={qrData}
- setFgColor={setFgColor}
- showLogo={showLogo}
- setShowLogo={setShowLogo}
+ }
/>
+ </div>
- <div className="grid grid-cols-2 gap-2 px-4 sm:px-16">
- <button
- onClick={async () => {
- toast.promise(copyToClipboard, {
- loading: "Copying QR code to clipboard...",
- success: "Copied QR code to clipboard!",
- error: "Failed to copy",
- });
- }}
- className="flex items-center justify-center gap-2 rounded-md border border-black bg-black px-5 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"
- >
- <Clipboard className="h-4 w-4" /> Copy
- </button>
- <QrDropdown
- download={download}
- qrData={qrData}
- showLogo={showLogo}
- logo={qrLogoUrl}
- />
- </div>
+ <AdvancedSettings
+ qrData={qrData}
+ setFgColor={setFgColor}
+ showLogo={showLogo}
+ setShowLogo={setShowLogo}
+ />
- {/* This will be used to prompt downloads. */}
- <a
- className="hidden"
- download={`${props.key}-qrcode.svg`}
- ref={anchorRef}
+ <div className="grid grid-cols-2 gap-2 px-4 sm:px-16">
+ <button
+ onClick={async () => {
+ toast.promise(copyToClipboard, {
+ loading: "Copying QR code to clipboard...",
+ success: "Copied QR code to clipboard!",
+ error: "Failed to copy",
+ });
+ }}
+ className="flex items-center justify-center gap-2 rounded-md border border-black bg-black px-5 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"
+ >
+ <Clipboard className="h-4 w-4" /> Copy
+ </button>
+ <QrDropdown
+ download={download}
+ qrData={qrData}
+ showLogo={showLogo}
+ logo={qrLogoUrl}
/>
</div>
+
+ {/* This will be used to prompt downloads. */}
+ <a
+ className="hidden"
+ download={`${props.key}-qrcode.svg`}
+ ref={anchorRef}
+ />
</div>
</Modal>
);
diff --git a/app/ui/stats/toggle.tsx b/app/ui/stats/toggle.tsx
index 5f47863341..60eab45414 100644
--- a/app/ui/stats/toggle.tsx
+++ b/app/ui/stats/toggle.tsx
@@ -57,7 +57,7 @@ export default function Toggle() {
)}
<Popover
content={
- <div className="w-full p-2 md:w-48">
+ <div className="grid w-full p-2 md:w-48">
{INTERVALS.map(({ display, slug }) =>
(slug === "all" || slug === "90d") &&
(!plan || plan === "free") ? (
diff --git a/components/app/modals/accept-invite-modal.tsx b/components/app/modals/accept-invite-modal.tsx
index 4ed9d44674..40c85c0309 100644
--- a/components/app/modals/accept-invite-modal.tsx
+++ b/components/app/modals/accept-invite-modal.tsx
@@ -8,8 +8,7 @@ import {
useState,
} from "react";
import { mutate } from "swr";
-import BlurImage from "#/ui/blur-image";
-import { LoadingDots } from "#/ui/icons";
+import { Logo, LoadingDots } from "#/ui/icons";
import Modal from "#/ui/modal";
import useProject from "#/lib/swr/use-project";
import { toast } from "sonner";
@@ -33,15 +32,9 @@ function AcceptInviteModal({
setShowModal={setShowAcceptInviteModal}
>
{error?.status === 409 ? (
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <>
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={`/_static/logo.png`}
- alt={"Invite Teammate"}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
+ <Logo />
<h3 className="text-lg font-medium">Project Invitation</h3>
<p className="text-center text-sm text-gray-500">
You've been invited to join and collaborate on the{" "}
@@ -86,17 +79,11 @@ function AcceptInviteModal({
)}
</button>
</div>
- </div>
+ </>
) : (
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <>
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={`/_static/logo.png`}
- alt={"Invite Teammate"}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
+ <Logo />
<h3 className="text-lg font-medium">Project Invitation Expired</h3>
<p className="text-center text-sm text-gray-500">
This invite has expired or is no longer valid.
@@ -110,7 +97,7 @@ function AcceptInviteModal({
Back to dashboard
</Link>
</div>
- </div>
+ </>
)}
</Modal>
);
diff --git a/components/app/modals/add-edit-domain-modal.tsx b/components/app/modals/add-edit-domain-modal.tsx
index 4b839375dc..ce7f19db1f 100644
--- a/components/app/modals/add-edit-domain-modal.tsx
+++ b/components/app/modals/add-edit-domain-modal.tsx
@@ -11,6 +11,7 @@ import {
import { mutate } from "swr";
import { useDebounce } from "use-debounce";
import BlurImage from "#/ui/blur-image";
+import { Logo } from "#/ui/icons";
import { AlertCircleFill, Lock } from "@/components/shared/icons";
import Modal from "#/ui/modal";
import { DomainProps } from "#/lib/types";
@@ -128,231 +129,231 @@ function AddEditDomainModal({
showModal={showAddEditDomainModal}
setShowModal={setShowAddEditDomainModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ {logo ? (
<BlurImage
- src={logo || "/_static/logo.png"}
+ src={logo}
alt={`Logo for ${slug}`}
className="h-10 w-10 rounded-full border border-gray-200"
width={20}
height={20}
/>
- <h3 className="text-lg font-medium">
- {props ? "Edit" : "Add"} Domain
- </h3>
- </div>
+ ) : (
+ <Logo />
+ )}
+ <h3 className="text-lg font-medium">{props ? "Edit" : "Add"} Domain</h3>
+ </div>
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- setSaving(true);
- fetch(endpoint.url, {
- method: endpoint.method,
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(data),
- }).then(async (res) => {
- setSaving(false);
- if (res.status === 200) {
- mutate(`/api/projects/${slug}/domains`);
- setShowAddEditDomainModal(false);
- toast.success(endpoint.successMessage);
- if (!props) {
- router.push(`/${slug}/domains`);
- }
- } else if (res.status === 422) {
- const { domainError: domainErrorResponse } = await res.json();
- if (domainErrorResponse) {
- setDomainError(domainErrorResponse);
- }
- } else {
- setDomainError("Something went wrong. Please try again.");
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ setSaving(true);
+ fetch(endpoint.url, {
+ method: endpoint.method,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ }).then(async (res) => {
+ setSaving(false);
+ if (res.status === 200) {
+ mutate(`/api/projects/${slug}/domains`);
+ setShowAddEditDomainModal(false);
+ toast.success(endpoint.successMessage);
+ if (!props) {
+ router.push(`/${slug}/domains`);
}
- });
- }}
- className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
- >
- <div>
- <div className="flex items-center justify-between">
- <label
- htmlFor="domain"
- className="block text-sm font-medium text-gray-700"
- >
- Domain
- </label>
- {props && lockDomain && (
- <button
- className="flex items-center space-x-2 text-sm text-gray-500 transition-all duration-75 hover:text-black active:scale-95"
- type="button"
- onClick={() => {
- window.confirm(
- "Warning: Changing your project's domain will break all existing short links and reset their analytics. Are you sure you want to continue?",
- ) && setLockDomain(false);
- }}
- >
- <Lock className="h-3 w-3" />
- <p>Unlock</p>
- </button>
- )}
- </div>
- {props && lockDomain ? (
- <div className="mt-1 cursor-not-allowed rounded-md border border-gray-300 bg-gray-100 px-3 py-2 text-sm text-gray-500 shadow-sm">
- {domain}
- </div>
- ) : (
- <div className="relative mt-1 rounded-md shadow-sm">
- <input
- type="text"
- name="domain"
- id="domain"
- required
- pattern="[[\p{Letter}\p{Mark}\d-.]+"
- className={`${
- domainError
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
- } block w-full rounded-md focus:outline-none sm:text-sm`}
- placeholder="dub.sh"
- value={domain}
- onChange={(e) => {
- setDomainError(null);
- setData({ ...data, slug: e.target.value });
- }}
- aria-invalid="true"
- aria-describedby="domain-error"
- />
- {domainError && (
- <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
- <AlertCircleFill
- className="h-5 w-5 text-red-500"
- aria-hidden="true"
- />
- </div>
- )}
- </div>
- )}
- {domainError &&
- (domainError === "Domain is already in use." ? (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- Domain is already in use.{" "}
- <a
- className="underline"
- href="mailto:[email protected]?subject=My Domain Is Already In Use"
- >
- Contact us
- </a>{" "}
- if you'd like to use this domain for your project.
- </p>
- ) : (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- {domainError}
- </p>
- ))}
- </div>
-
- <div>
+ } else if (res.status === 422) {
+ const { domainError: domainErrorResponse } = await res.json();
+ if (domainErrorResponse) {
+ setDomainError(domainErrorResponse);
+ }
+ } else {
+ setDomainError("Something went wrong. Please try again.");
+ }
+ });
+ }}
+ className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ >
+ <div>
+ <div className="flex items-center justify-between">
<label
- htmlFor="target"
+ htmlFor="domain"
className="block text-sm font-medium text-gray-700"
>
- Landing Page
+ Domain
</label>
- {plan !== "free" ? (
- <div className="relative mt-1 rounded-md shadow-sm">
- <input
- type="url"
- name="target"
- id="target"
- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- placeholder="https://example.com"
- value={target}
- onChange={(e) => setData({ ...data, target: e.target.value })}
- />
- </div>
- ) : (
- <Tooltip
- content={
- <TooltipContent
- title="You can't configure a custom landing page on a free plan. Upgrade to a Pro plan to proceed."
- cta="Upgrade to Pro"
- onClick={() => {
- setShowAddEditDomainModal(false);
- setShowUpgradePlanModal(true);
- }}
- />
- }
- fullWidth
+ {props && lockDomain && (
+ <button
+ className="flex items-center space-x-2 text-sm text-gray-500 transition-all duration-75 hover:text-black active:scale-95"
+ type="button"
+ onClick={() => {
+ window.confirm(
+ "Warning: Changing your project's domain will break all existing short links and reset their analytics. Are you sure you want to continue?",
+ ) && setLockDomain(false);
+ }}
>
- <div className="mt-1 w-full cursor-not-allowed rounded-md border border-gray-300 px-3 py-2 text-left text-sm text-gray-300 sm:max-w-md">
- https://yourdomain.com
- </div>
- </Tooltip>
+ <Lock className="h-3 w-3" />
+ <p>Unlock</p>
+ </button>
)}
</div>
-
- <AnimatePresence initial={false}>
- {target && (
- <motion.div key="type" {...SWIPE_REVEAL_ANIMATION_SETTINGS}>
- <label
- htmlFor="type"
- className="block text-sm font-medium text-gray-700"
- >
- Behavior
- </label>
- <select
- value={type}
- onChange={(e) =>
- setData({
- ...data,
- type: e.target.value as "redirect" | "rewrite",
- })
- }
- className="mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-gray-500 shadow-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ {props && lockDomain ? (
+ <div className="mt-1 cursor-not-allowed rounded-md border border-gray-300 bg-gray-100 px-3 py-2 text-sm text-gray-500 shadow-sm">
+ {domain}
+ </div>
+ ) : (
+ <div className="relative mt-1 rounded-md shadow-sm">
+ <input
+ type="text"
+ name="domain"
+ id="domain"
+ required
+ pattern="[[\p{Letter}\p{Mark}\d-.]+"
+ className={`${
+ domainError
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
+ } block w-full rounded-md focus:outline-none sm:text-sm`}
+ placeholder="dub.sh"
+ value={domain}
+ onChange={(e) => {
+ setDomainError(null);
+ setData({ ...data, slug: e.target.value });
+ }}
+ aria-invalid="true"
+ aria-describedby="domain-error"
+ />
+ {domainError && (
+ <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
+ <AlertCircleFill
+ className="h-5 w-5 text-red-500"
+ aria-hidden="true"
+ />
+ </div>
+ )}
+ </div>
+ )}
+ {domainError &&
+ (domainError === "Domain is already in use." ? (
+ <p className="mt-2 text-sm text-red-600" id="domain-error">
+ Domain is already in use.{" "}
+ <a
+ className="underline"
+ href="mailto:[email protected]?subject=My Domain Is Already In Use"
>
- <option value="redirect">Redirect</option>
- <option value="rewrite">Rewrite</option>
- </select>
- </motion.div>
- )}
- </AnimatePresence>
-
- <div className="flex items-center justify-between bg-gray-50">
- <p className="text-sm font-medium text-gray-900">Primary Domain</p>
- <Switch
- fn={() => setData((prev) => ({ ...prev, primary: !primary }))}
- checked={primary}
- disabled={props?.primary}
- />
- </div>
+ Contact us
+ </a>{" "}
+ if you'd like to use this domain for your project.
+ </p>
+ ) : (
+ <p className="mt-2 text-sm text-red-600" id="domain-error">
+ {domainError}
+ </p>
+ ))}
+ </div>
- <div className="grid gap-2">
- <Button
- text={props ? "Save changes" : "Add domain"}
- disabled={saveDisabled}
- loading={saving}
- />
- {props &&
- (props.primary ? (
- <Button
- disabledTooltip="You can't delete your primary domain."
- text="Delete domain"
- />
- ) : (
- <Button
- variant="danger"
- text="Delete domain"
+ <div>
+ <label
+ htmlFor="target"
+ className="block text-sm font-medium text-gray-700"
+ >
+ Landing Page
+ </label>
+ {plan !== "free" ? (
+ <div className="relative mt-1 rounded-md shadow-sm">
+ <input
+ type="url"
+ name="target"
+ id="target"
+ className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ placeholder="https://example.com"
+ value={target}
+ onChange={(e) => setData({ ...data, target: e.target.value })}
+ />
+ </div>
+ ) : (
+ <Tooltip
+ content={
+ <TooltipContent
+ title="You can't configure a custom landing page on a free plan. Upgrade to a Pro plan to proceed."
+ cta="Upgrade to Pro"
onClick={() => {
- window.confirm(
- "Warning: Deleting your project's domain will delete all existing short links using the domain. Are you sure you want to continue?",
- ) && deleteDomain();
+ setShowAddEditDomainModal(false);
+ setShowUpgradePlanModal(true);
}}
- loading={deleting}
/>
- ))}
- </div>
- </form>
- </div>
+ }
+ fullWidth
+ >
+ <div className="mt-1 w-full cursor-not-allowed rounded-md border border-gray-300 px-3 py-2 text-left text-sm text-gray-300 sm:max-w-md">
+ https://yourdomain.com
+ </div>
+ </Tooltip>
+ )}
+ </div>
+
+ <AnimatePresence initial={false}>
+ {target && (
+ <motion.div key="type" {...SWIPE_REVEAL_ANIMATION_SETTINGS}>
+ <label
+ htmlFor="type"
+ className="block text-sm font-medium text-gray-700"
+ >
+ Behavior
+ </label>
+ <select
+ value={type}
+ onChange={(e) =>
+ setData({
+ ...data,
+ type: e.target.value as "redirect" | "rewrite",
+ })
+ }
+ className="mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-gray-500 shadow-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ >
+ <option value="redirect">Redirect</option>
+ <option value="rewrite">Rewrite</option>
+ </select>
+ </motion.div>
+ )}
+ </AnimatePresence>
+
+ <div className="flex items-center justify-between bg-gray-50">
+ <p className="text-sm font-medium text-gray-900">Primary Domain</p>
+ <Switch
+ fn={() => setData((prev) => ({ ...prev, primary: !primary }))}
+ checked={primary}
+ disabled={props?.primary}
+ />
+ </div>
+
+ <div className="grid gap-2">
+ <Button
+ text={props ? "Save changes" : "Add domain"}
+ disabled={saveDisabled}
+ loading={saving}
+ />
+ {props &&
+ (props.primary ? (
+ <Button
+ disabledTooltip="You can't delete your primary domain."
+ text="Delete domain"
+ />
+ ) : (
+ <Button
+ variant="danger"
+ text="Delete domain"
+ onClick={() => {
+ window.confirm(
+ "Warning: Deleting your project's domain will delete all existing short links using the domain. Are you sure you want to continue?",
+ ) && deleteDomain();
+ }}
+ loading={deleting}
+ />
+ ))}
+ </div>
+ </form>
</Modal>
);
}
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 38cc7f7308..da7edc83d5 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -266,9 +266,10 @@ function AddEditLinkModal({
<Modal
showModal={showAddEditLinkModal}
setShowModal={setShowAddEditLinkModal}
+ className="max-w-screen-lg"
disableDefaultHide={homepageDemo ? false : true}
>
- <div className="relative grid max-h-[min(906px,_90vh)] w-full divide-x divide-gray-100 overflow-auto bg-white shadow-xl transition-all scrollbar-hide md:max-w-screen-lg md:grid-cols-2 md:overflow-hidden md:rounded-2xl md:border md:border-gray-200">
+ <div className="relative grid max-h-[min(906px,_90vh)] w-full divide-x divide-gray-100 overflow-auto scrollbar-hide md:grid-cols-2">
{!welcomeFlow && !homepageDemo && (
<button
onClick={() => setShowAddEditLinkModal(false)}
diff --git a/components/app/modals/add-project-modal.tsx b/components/app/modals/add-project-modal.tsx
index 8c0131ac2d..96a85a3734 100644
--- a/components/app/modals/add-project-modal.tsx
+++ b/components/app/modals/add-project-modal.tsx
@@ -10,7 +10,7 @@ import {
} from "react";
import { mutate } from "swr";
import { useDebounce } from "use-debounce";
-import BlurImage from "#/ui/blur-image";
+import { Logo } from "#/ui/icons";
import { AlertCircleFill } from "@/components/shared/icons";
import Modal from "#/ui/modal";
import { generateDomainFromName } from "#/lib/utils";
@@ -87,204 +87,196 @@ function AddProjectModalHelper({
setShowModal={setShowAddProjectModal}
disableDefaultHide={welcomeFlow}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={`/_static/logo.png`}
- alt={"dub.sh"}
- className="h-10 w-10 rounded-full border border-gray-200"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">Create a new project</h3>
- </div>
-
- <form
- onSubmit={async (e: FormEvent<HTMLFormElement>) => {
- e.preventDefault();
- setSaving(true);
- fetch("/api/projects", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(data),
- }).then(async (res) => {
- if (res.status === 200) {
- // track project creation event
- va.track("Created Project");
- mutate("/api/projects");
- if (welcomeFlow) {
- router.push({
- pathname: "/welcome",
- query: {
- type: "upgrade",
- slug,
- },
- });
- } else {
- router.push(`/${slug}`);
- toast.success("Successfully created project!");
- setShowAddProjectModal(false);
- }
- } else if (res.status === 422) {
- const {
- slugError: slugErrorResponse,
- domainError: domainErrorResponse,
- } = await res.json();
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <Logo />
+ <h3 className="text-lg font-medium">Create a new project</h3>
+ </div>
- if (slugErrorResponse) {
- setSlugError(slugErrorResponse);
- toast.error(slugErrorResponse);
- }
- if (domainErrorResponse) {
- setDomainError(domainErrorResponse);
- toast.error(domainErrorResponse);
- }
+ <form
+ onSubmit={async (e: FormEvent<HTMLFormElement>) => {
+ e.preventDefault();
+ setSaving(true);
+ fetch("/api/projects", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ }).then(async (res) => {
+ if (res.status === 200) {
+ // track project creation event
+ va.track("Created Project");
+ mutate("/api/projects");
+ if (welcomeFlow) {
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "upgrade",
+ slug,
+ },
+ });
} else {
- toast.error(res.statusText);
+ router.push(`/${slug}`);
+ toast.success("Successfully created project!");
+ setShowAddProjectModal(false);
}
- setSaving(false);
- });
- }}
- className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
- >
- <div>
- <label
- htmlFor="name"
- className="block text-sm font-medium text-gray-700"
- >
- Project Name
- </label>
- <div className="mt-1 flex rounded-md shadow-sm">
- <input
- name="name"
- id="name"
- type="text"
- required
- autoFocus
- autoComplete="off"
- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- placeholder="Dub"
- value={name}
- onChange={(e) => {
- setData({ ...data, name: e.target.value });
- }}
- aria-invalid="true"
- />
- </div>
+ } else if (res.status === 422) {
+ const {
+ slugError: slugErrorResponse,
+ domainError: domainErrorResponse,
+ } = await res.json();
+
+ if (slugErrorResponse) {
+ setSlugError(slugErrorResponse);
+ toast.error(slugErrorResponse);
+ }
+ if (domainErrorResponse) {
+ setDomainError(domainErrorResponse);
+ toast.error(domainErrorResponse);
+ }
+ } else {
+ toast.error(res.statusText);
+ }
+ setSaving(false);
+ });
+ }}
+ className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ >
+ <div>
+ <label
+ htmlFor="name"
+ className="block text-sm font-medium text-gray-700"
+ >
+ Project Name
+ </label>
+ <div className="mt-1 flex rounded-md shadow-sm">
+ <input
+ name="name"
+ id="name"
+ type="text"
+ required
+ autoFocus
+ autoComplete="off"
+ className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ placeholder="Dub"
+ value={name}
+ onChange={(e) => {
+ setData({ ...data, name: e.target.value });
+ }}
+ aria-invalid="true"
+ />
</div>
+ </div>
- <div>
- <label
- htmlFor="slug"
- className="block text-sm font-medium text-gray-700"
- >
- Project Slug
- </label>
- <div className="relative mt-1 flex rounded-md shadow-sm">
- <span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-5 text-gray-500 sm:text-sm">
- app.dub.sh
- </span>
- <input
- name="slug"
- id="slug"
- type="text"
- required
- autoComplete="off"
- pattern="[a-zA-Z0-9\-]+"
- className={`${
- slugError
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
- } block w-full rounded-r-md focus:outline-none sm:text-sm`}
- placeholder="dub"
- value={slug}
- onChange={(e) => {
- setSlugError(null);
- setData({ ...data, slug: e.target.value });
- }}
- aria-invalid="true"
- />
- {slugError && (
- <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
- <AlertCircleFill
- className="h-5 w-5 text-red-500"
- aria-hidden="true"
- />
- </div>
- )}
- </div>
+ <div>
+ <label
+ htmlFor="slug"
+ className="block text-sm font-medium text-gray-700"
+ >
+ Project Slug
+ </label>
+ <div className="relative mt-1 flex rounded-md shadow-sm">
+ <span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-5 text-gray-500 sm:text-sm">
+ app.dub.sh
+ </span>
+ <input
+ name="slug"
+ id="slug"
+ type="text"
+ required
+ autoComplete="off"
+ pattern="[a-zA-Z0-9\-]+"
+ className={`${
+ slugError
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
+ } block w-full rounded-r-md focus:outline-none sm:text-sm`}
+ placeholder="dub"
+ value={slug}
+ onChange={(e) => {
+ setSlugError(null);
+ setData({ ...data, slug: e.target.value });
+ }}
+ aria-invalid="true"
+ />
{slugError && (
- <p className="mt-2 text-sm text-red-600" id="slug-error">
- {slugError}
- </p>
+ <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
+ <AlertCircleFill
+ className="h-5 w-5 text-red-500"
+ aria-hidden="true"
+ />
+ </div>
)}
</div>
+ {slugError && (
+ <p className="mt-2 text-sm text-red-600" id="slug-error">
+ {slugError}
+ </p>
+ )}
+ </div>
- <div>
- <label
- htmlFor="domain"
- className="block text-sm font-medium text-gray-700"
- >
- Shortlink Domain
- </label>
- <div className="relative mt-1 flex rounded-md shadow-sm">
- <input
- name="domain"
- id="domain"
- type="text"
- required
- autoComplete="off"
- pattern="[a-zA-Z0-9\-.]+"
- className={`${
- domainError
- ? "border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
- } block w-full rounded-md pr-10 focus:outline-none sm:text-sm`}
- placeholder="dub.sh"
- value={domain}
- onChange={(e) => {
- setDomainError(null);
- setData({ ...data, domain: e.target.value });
- }}
- aria-invalid="true"
- />
- {domainError && (
- <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
- <AlertCircleFill
- className="h-5 w-5 text-red-500"
- aria-hidden="true"
- />
- </div>
- )}
- </div>
- {domainError &&
- (domainError === "Domain is already in use." ? (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- Domain is already in use.{" "}
- <a
- className="underline"
- href="mailto:[email protected]?subject=My Domain Is Already In Use"
- >
- Contact us
- </a>{" "}
- if you'd like to use this domain for your project.
- </p>
- ) : (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- {domainError}
- </p>
- ))}
+ <div>
+ <label
+ htmlFor="domain"
+ className="block text-sm font-medium text-gray-700"
+ >
+ Shortlink Domain
+ </label>
+ <div className="relative mt-1 flex rounded-md shadow-sm">
+ <input
+ name="domain"
+ id="domain"
+ type="text"
+ required
+ autoComplete="off"
+ pattern="[a-zA-Z0-9\-.]+"
+ className={`${
+ domainError
+ ? "border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
+ } block w-full rounded-md pr-10 focus:outline-none sm:text-sm`}
+ placeholder="dub.sh"
+ value={domain}
+ onChange={(e) => {
+ setDomainError(null);
+ setData({ ...data, domain: e.target.value });
+ }}
+ aria-invalid="true"
+ />
+ {domainError && (
+ <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
+ <AlertCircleFill
+ className="h-5 w-5 text-red-500"
+ aria-hidden="true"
+ />
+ </div>
+ )}
</div>
+ {domainError &&
+ (domainError === "Domain is already in use." ? (
+ <p className="mt-2 text-sm text-red-600" id="domain-error">
+ Domain is already in use.{" "}
+ <a
+ className="underline"
+ href="mailto:[email protected]?subject=My Domain Is Already In Use"
+ >
+ Contact us
+ </a>{" "}
+ if you'd like to use this domain for your project.
+ </p>
+ ) : (
+ <p className="mt-2 text-sm text-red-600" id="domain-error">
+ {domainError}
+ </p>
+ ))}
+ </div>
- <Button
- disabled={slugError || domainError ? true : false}
- loading={saving}
- text="Create project"
- />
- </form>
- </div>
+ <Button
+ disabled={slugError || domainError ? true : false}
+ loading={saving}
+ text="Create project"
+ />
+ </form>
</Modal>
);
}
diff --git a/components/app/modals/archive-link-modal.tsx b/components/app/modals/archive-link-modal.tsx
index faebb32b12..e445c04eb5 100644
--- a/components/app/modals/archive-link-modal.tsx
+++ b/components/app/modals/archive-link-modal.tsx
@@ -46,66 +46,62 @@ function ArchiveLinkModal({
showModal={showArchiveLinkModal}
setShowModal={setShowArchiveLinkModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 text-center sm:px-16">
- <BlurImage
- src={`${GOOGLE_FAVICON_URL}${apexDomain}`}
- alt={apexDomain}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">
- {archived ? "Archive" : "Unarchive"} {shortlink}
- </h3>
- <p className="text-sm text-gray-500">
- {archived
- ? "Archived links will still work - they just won't show up on your main dashboard."
- : "By unarchiving this link, it will show up on your main dashboard again."}
- </p>
- </div>
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 text-center sm:px-16">
+ <BlurImage
+ src={`${GOOGLE_FAVICON_URL}${apexDomain}`}
+ alt={apexDomain}
+ className="h-10 w-10 rounded-full"
+ width={20}
+ height={20}
+ />
+ <h3 className="text-lg font-medium">
+ {archived ? "Archive" : "Unarchive"} {shortlink}
+ </h3>
+ <p className="text-sm text-gray-500">
+ {archived
+ ? "Archived links will still work - they just won't show up on your main dashboard."
+ : "By unarchiving this link, it will show up on your main dashboard again."}
+ </p>
+ </div>
- <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16">
- <Button
- onClick={async (e) => {
- e.preventDefault();
- setArchiving(true);
- fetch(
- `/api/links/${encodeURIComponent(props.key)}/archive${
- slug ? `?slug=${slug}&domain=${domain}` : ""
- }`,
- {
- method: archived ? "POST" : "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
+ <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16">
+ <Button
+ onClick={async (e) => {
+ e.preventDefault();
+ setArchiving(true);
+ fetch(
+ `/api/links/${encodeURIComponent(props.key)}/archive${
+ slug ? `?slug=${slug}&domain=${domain}` : ""
+ }`,
+ {
+ method: archived ? "POST" : "DELETE",
+ headers: {
+ "Content-Type": "application/json",
},
- ).then(async (res) => {
- setArchiving(false);
- if (res.status === 200) {
- mutate(`/api/links${getQueryString(router)}`);
- mutate(
- (key) =>
- typeof key === "string" &&
- key.startsWith(`/api/links/_count`),
- undefined,
- { revalidate: true },
- );
- setShowArchiveLinkModal(false);
- toast.success(
- `Successfully ${
- archived ? "archived" : "unarchived"
- } link!`,
- );
- } else {
- toast.error(res.statusText);
- }
- });
- }}
- loading={archiving}
- text={`Confirm ${archived ? "archive" : "unarchive"}`}
- />
- </div>
+ },
+ ).then(async (res) => {
+ setArchiving(false);
+ if (res.status === 200) {
+ mutate(`/api/links${getQueryString(router)}`);
+ mutate(
+ (key) =>
+ typeof key === "string" &&
+ key.startsWith(`/api/links/_count`),
+ undefined,
+ { revalidate: true },
+ );
+ setShowArchiveLinkModal(false);
+ toast.success(
+ `Successfully ${archived ? "archived" : "unarchived"} link!`,
+ );
+ } else {
+ toast.error(res.statusText);
+ }
+ });
+ }}
+ loading={archiving}
+ text={`Confirm ${archived ? "archive" : "unarchive"}`}
+ />
</div>
</Modal>
);
diff --git a/components/app/modals/complete-setup-modal.tsx b/components/app/modals/complete-setup-modal.tsx
index d7269829db..27e8a0bf5d 100644
--- a/components/app/modals/complete-setup-modal.tsx
+++ b/components/app/modals/complete-setup-modal.tsx
@@ -7,10 +7,9 @@ import {
useMemo,
useState,
} from "react";
-import BlurImage from "#/ui/blur-image";
import Modal from "#/ui/modal";
import { CheckCircleFill } from "@/components/shared/icons";
-import { ExpandingArrow } from "#/ui/icons";
+import { Logo, ExpandingArrow } from "#/ui/icons";
import useDomains from "#/lib/swr/use-domains";
import useLinksCount from "#/lib/swr/use-links-count";
import { ModalContext } from "#/ui/modal-provider";
@@ -58,54 +57,46 @@ function CompleteSetupModal({
showModal={showCompleteSetupModal}
setShowModal={setShowCompleteSetupModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={`/_static/logo.png`}
- alt={"Invite Teammate"}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">You're almost there!</h3>
- <p className="text-center text-sm text-gray-500">
- Complete the following steps and start sharing your branded short
- links.
- </p>
- </div>
- <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-12">
- <div className="grid divide-y divide-gray-200 rounded-lg border border-gray-200 bg-white">
- {tasks.map(({ display, cta, checked }) => {
- const contents = (
- <div className="group flex items-center justify-between p-3">
- <div className="flex items-center space-x-3">
- <CheckCircleFill
- className={`h-5 w-5 ${
- checked ? "text-green-500" : "text-gray-400"
- }`}
- />
- <p className="text-sm">{display}</p>
- </div>
- <div className="mr-5">
- <ExpandingArrow />
- </div>
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <Logo />
+ <h3 className="text-lg font-medium">You're almost there!</h3>
+ <p className="text-center text-sm text-gray-500">
+ Complete the following steps and start sharing your branded short
+ links.
+ </p>
+ </div>
+ <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-12">
+ <div className="grid divide-y divide-gray-200 rounded-lg border border-gray-200 bg-white">
+ {tasks.map(({ display, cta, checked }) => {
+ const contents = (
+ <div className="group flex items-center justify-between p-3">
+ <div className="flex items-center space-x-3">
+ <CheckCircleFill
+ className={`h-5 w-5 ${
+ checked ? "text-green-500" : "text-gray-400"
+ }`}
+ />
+ <p className="text-sm">{display}</p>
+ </div>
+ <div className="mr-5">
+ <ExpandingArrow />
</div>
- );
- return (
- <Link
- key={display}
- href={cta}
- onClick={() => {
- setShowCompleteSetupModal(false);
- display === "Create or import your links" &&
- setShowAddEditLinkModal(true);
- }}
- >
- {contents}
- </Link>
- );
- })}
- </div>
+ </div>
+ );
+ return (
+ <Link
+ key={display}
+ href={cta}
+ onClick={() => {
+ setShowCompleteSetupModal(false);
+ display === "Create or import your links" &&
+ setShowAddEditLinkModal(true);
+ }}
+ >
+ {contents}
+ </Link>
+ );
+ })}
</div>
</div>
</Modal>
diff --git a/components/app/modals/delete-account-modal.tsx b/components/app/modals/delete-account-modal.tsx
index 021af5a8dd..d23995b694 100644
--- a/components/app/modals/delete-account-modal.tsx
+++ b/components/app/modals/delete-account-modal.tsx
@@ -53,70 +53,63 @@ function DeleteAccountModal({
showModal={showDeleteAccountModal}
setShowModal={setShowDeleteAccountModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={
- session?.user?.image ||
- `https://avatars.dicebear.com/api/micah/${session?.user?.email}.svg`
- }
- alt={
- session?.user?.name || session?.user?.email || "Delete Account"
- }
- className="h-10 w-10 rounded-full border border-gray-200"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">Delete Account</h3>
- <p className="text-center text-sm text-gray-500">
- Warning: This will permanently delete your account and all your
- Dub.sh links and their respective stats.
- </p>
- </div>
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <BlurImage
+ src={
+ session?.user?.image ||
+ `https://avatars.dicebear.com/api/micah/${session?.user?.email}.svg`
+ }
+ alt={session?.user?.name || session?.user?.email || "Delete Account"}
+ className="h-10 w-10 rounded-full border border-gray-200"
+ width={20}
+ height={20}
+ />
+ <h3 className="text-lg font-medium">Delete Account</h3>
+ <p className="text-center text-sm text-gray-500">
+ Warning: This will permanently delete your account and all your Dub.sh
+ links and their respective stats.
+ </p>
+ </div>
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- toast.promise(deleteAccount(), {
- loading: "Deleting account...",
- success: "Account deleted successfully!",
- error: (err) => err,
- });
- }}
- className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
- >
- <div>
- <label
- htmlFor="verification"
- className="block text-sm text-gray-700"
- >
- To verify, type{" "}
- <span className="font-semibold text-black">
- confirm delete account
- </span>{" "}
- below
- </label>
- <div className="relative mt-1 rounded-md shadow-sm">
- <input
- type="text"
- name="verification"
- id="verification"
- pattern="confirm delete account"
- required
- autoFocus={false}
- autoComplete="off"
- className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- />
- </div>
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ toast.promise(deleteAccount(), {
+ loading: "Deleting account...",
+ success: "Account deleted successfully!",
+ error: (err) => err,
+ });
+ }}
+ className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ >
+ <div>
+ <label htmlFor="verification" className="block text-sm text-gray-700">
+ To verify, type{" "}
+ <span className="font-semibold text-black">
+ confirm delete account
+ </span>{" "}
+ below
+ </label>
+ <div className="relative mt-1 rounded-md shadow-sm">
+ <input
+ type="text"
+ name="verification"
+ id="verification"
+ pattern="confirm delete account"
+ required
+ autoFocus={false}
+ autoComplete="off"
+ className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ />
</div>
+ </div>
- <Button
- text="Confirm delete account"
- variant="danger"
- loading={deleting}
- />
- </form>
- </div>
+ <Button
+ text="Confirm delete account"
+ variant="danger"
+ loading={deleting}
+ />
+ </form>
</Modal>
);
}
diff --git a/components/app/modals/delete-link-modal.tsx b/components/app/modals/delete-link-modal.tsx
index b93c668382..9284d8d9c1 100644
--- a/components/app/modals/delete-link-modal.tsx
+++ b/components/app/modals/delete-link-modal.tsx
@@ -44,82 +44,77 @@ function DeleteLinkModal({
showModal={showDeleteLinkModal}
setShowModal={setShowDeleteLinkModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 text-center sm:px-16">
- <BlurImage
- src={`${GOOGLE_FAVICON_URL}${apexDomain}`}
- alt={apexDomain}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">Delete {shortlink}</h3>
- <p className="text-sm text-gray-500">
- Warning: Deleting this link will remove all of its stats. This
- action cannot be undone.
- </p>
- </div>
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 text-center sm:px-16">
+ <BlurImage
+ src={`${GOOGLE_FAVICON_URL}${apexDomain}`}
+ alt={apexDomain}
+ className="h-10 w-10 rounded-full"
+ width={20}
+ height={20}
+ />
+ <h3 className="text-lg font-medium">Delete {shortlink}</h3>
+ <p className="text-sm text-gray-500">
+ Warning: Deleting this link will remove all of its stats. This action
+ cannot be undone.
+ </p>
+ </div>
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- setDeleting(true);
- fetch(
- `/api/links/${encodeURIComponent(props.key)}${
- slug ? `?slug=${slug}&domain=${domain}` : ""
- }`,
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ setDeleting(true);
+ fetch(
+ `/api/links/${encodeURIComponent(props.key)}${
+ slug ? `?slug=${slug}&domain=${domain}` : ""
+ }`,
+ {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
},
- ).then(async (res) => {
- setDeleting(false);
- if (res.status === 200) {
- mutate(`/api/links${getQueryString(router)}`);
- mutate(
- (key) =>
- typeof key === "string" &&
- key.startsWith(`/api/links/_count`),
- undefined,
- { revalidate: true },
- );
- setShowDeleteLinkModal(false);
- toast.success("Successfully deleted shortlink!");
- } else {
- const { error } = await res.json();
- toast.error(error);
- }
- });
- }}
- className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
- >
- <div>
- <label
- htmlFor="verification"
- className="block text-sm text-gray-700"
- >
- To verify, type <span className="font-semibold">{shortlink}</span>{" "}
- below
- </label>
- <div className="relative mt-1 rounded-md shadow-sm">
- <input
- type="text"
- name="verification"
- id="verification"
- pattern={shortlink}
- required
- autoFocus
- autoComplete="off"
- className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- />
- </div>
+ },
+ ).then(async (res) => {
+ setDeleting(false);
+ if (res.status === 200) {
+ mutate(`/api/links${getQueryString(router)}`);
+ mutate(
+ (key) =>
+ typeof key === "string" &&
+ key.startsWith(`/api/links/_count`),
+ undefined,
+ { revalidate: true },
+ );
+ setShowDeleteLinkModal(false);
+ toast.success("Successfully deleted shortlink!");
+ } else {
+ const { error } = await res.json();
+ toast.error(error);
+ }
+ });
+ }}
+ className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ >
+ <div>
+ <label htmlFor="verification" className="block text-sm text-gray-700">
+ To verify, type <span className="font-semibold">{shortlink}</span>{" "}
+ below
+ </label>
+ <div className="relative mt-1 rounded-md shadow-sm">
+ <input
+ type="text"
+ name="verification"
+ id="verification"
+ pattern={shortlink}
+ required
+ autoFocus
+ autoComplete="off"
+ className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ />
</div>
+ </div>
- <Button variant="danger" text="Confirm delete" loading={deleting} />
- </form>
- </div>
+ <Button variant="danger" text="Confirm delete" loading={deleting} />
+ </form>
</Modal>
);
}
diff --git a/components/app/modals/delete-project-modal.tsx b/components/app/modals/delete-project-modal.tsx
index 7e0d0c39e6..bdbf8ec637 100644
--- a/components/app/modals/delete-project-modal.tsx
+++ b/components/app/modals/delete-project-modal.tsx
@@ -51,7 +51,7 @@ function DeleteProjectModal({
showModal={showDeleteProjectModal}
setShowModal={setShowDeleteProjectModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <div className="inline-block w-full transform overflow-hidden bg-white align-middle transition-all">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
<BlurImage
src={logo || `https://avatar.vercel.sh/${id}`}
diff --git a/components/app/modals/google-oauth-modal.tsx b/components/app/modals/google-oauth-modal.tsx
index e2743414f8..29811f1e64 100644
--- a/components/app/modals/google-oauth-modal.tsx
+++ b/components/app/modals/google-oauth-modal.tsx
@@ -6,9 +6,9 @@ import {
useMemo,
useState,
} from "react";
-import BlurImage from "#/ui/blur-image";
import Modal from "#/ui/modal";
import Button from "#/ui/button";
+import { Logo } from "#/ui/icons";
import { Google } from "@/components/shared/icons";
import Cookies from "js-cookie";
@@ -26,50 +26,42 @@ function GoogleOauthModal({
showModal={showGoogleOauthModal}
setShowModal={setShowGoogleOauthModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={`/_static/logo.png`}
- alt={"Invite Teammate"}
- className="h-10 w-10 rounded-full"
- width={20}
- height={20}
- />
- <h3 className="text-lg font-medium">Connect your Google Account</h3>
- <p className="text-center text-sm text-gray-500">
- This allows you to sign in to your Dub account with Google.{" "}
- <a
- className="underline underline-offset-4 transition-colors hover:text-black"
- href="https://dub.sh/changelog/sign-in-with-google"
- target="_blank"
- rel="noopener noreferrer"
- >
- Read the announcement.
- </a>
- </p>
- </div>
- <div className="flex flex-col space-y-3 bg-gray-50 px-4 py-8 text-left sm:px-16">
- <Button
- text="Connect Google Account"
- onClick={() => {
- setClickedGoogle(true);
- signIn("google", {
- callbackUrl: "/settings?google=true",
- });
- }}
- loading={clickedGoogle}
- icon={<Google className="h-4 w-4" />}
- />
- <button
- onClick={() => {
- setShowGoogleOauthModal(false);
- Cookies.set("hideGoogleOauthModal", true, { expires: 14 });
- }}
- className="text-sm text-gray-400 underline underline-offset-4 transition-colors hover:text-gray-800 active:text-gray-400"
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <Logo />
+ <h3 className="text-lg font-medium">Connect your Google Account</h3>
+ <p className="text-center text-sm text-gray-500">
+ This allows you to sign in to your Dub account with Google.{" "}
+ <a
+ className="underline underline-offset-4 transition-colors hover:text-black"
+ href="https://dub.sh/changelog/sign-in-with-google"
+ target="_blank"
+ rel="noopener noreferrer"
>
- Don't show this again
- </button>
- </div>
+ Read the announcement.
+ </a>
+ </p>
+ </div>
+ <div className="flex flex-col space-y-3 bg-gray-50 px-4 py-8 text-left sm:px-16">
+ <Button
+ text="Connect Google Account"
+ onClick={() => {
+ setClickedGoogle(true);
+ signIn("google", {
+ callbackUrl: "/settings?google=true",
+ });
+ }}
+ loading={clickedGoogle}
+ icon={<Google className="h-4 w-4" />}
+ />
+ <button
+ onClick={() => {
+ setShowGoogleOauthModal(false);
+ Cookies.set("hideGoogleOauthModal", true, { expires: 14 });
+ }}
+ className="text-sm text-gray-400 underline underline-offset-4 transition-colors hover:text-gray-800 active:text-gray-400"
+ >
+ Don't show this again
+ </button>
</div>
</Modal>
);
diff --git a/components/app/modals/import-bitly-modal.tsx b/components/app/modals/import-bitly-modal.tsx
index 1cb9480dbe..2b8093e585 100644
--- a/components/app/modals/import-bitly-modal.tsx
+++ b/components/app/modals/import-bitly-modal.tsx
@@ -8,14 +8,13 @@ import {
useMemo,
useState,
} from "react";
-import BlurImage from "#/ui/blur-image";
import Modal from "#/ui/modal";
import useProject from "#/lib/swr/use-project";
import Switch from "#/ui/switch";
import Button from "#/ui/button";
import { toast } from "sonner";
import { ArrowRight } from "lucide-react";
-import { LoadingSpinner } from "#/ui/icons";
+import { Logo, LoadingSpinner } from "#/ui/icons";
import { ModalContext } from "#/ui/modal-provider";
import useSWR, { mutate } from "swr";
import { BitlyGroupProps } from "#/lib/types";
@@ -86,162 +85,152 @@ function ImportBitlyModal({
setShowModal={setShowImportBitlyModal}
onClose={() => closeModal(router)}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-8 sm:px-16">
- <div className="flex items-center space-x-3 py-4">
- <img
- src="/_static/icons/bitly.svg"
- alt="Bitly logo"
- className="h-10 w-10 rounded-full border border-gray-200"
- />
- <ArrowRight className="h-5 w-5 text-gray-600" />
- <BlurImage
- src="/_static/logo.png"
- alt="Dub logo"
- className="h-10 w-10 rounded-full border border-gray-200"
- width={20}
- height={20}
- />
- </div>
- <h3 className="text-lg font-medium">Import Your Bitly Links</h3>
- <p className="text-center text-sm text-gray-500">
- Easily import all your existing Bitly links into Dub with just a few
- clicks.
- </p>
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-8 sm:px-16">
+ <div className="flex items-center space-x-3 py-4">
+ <img
+ src="/_static/icons/bitly.svg"
+ alt="Bitly logo"
+ className="h-10 w-10 rounded-full border border-gray-200"
+ />
+ <ArrowRight className="h-5 w-5 text-gray-600" />
+ <Logo />
</div>
+ <h3 className="text-lg font-medium">Import Your Bitly Links</h3>
+ <p className="text-center text-sm text-gray-500">
+ Easily import all your existing Bitly links into Dub with just a few
+ clicks.
+ </p>
+ </div>
- <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16">
- {isLoading ? (
- <button className="flex flex-col items-center justify-center space-y-4 bg-none">
- <LoadingSpinner />
- <p className="text-sm text-gray-500">Connecting to Bitly</p>
- </button>
- ) : groups ? (
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- setImporting(true);
- toast.promise(
- fetch(`/api/projects/${slug}/import/bitly`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- selectedDomains,
- selectedGroupTags,
- }),
- }).then((res) => {
- setImporting(false);
- if (res.ok) {
- closeModal(router);
- mutate(`/api/projects/${slug}/domains`);
- setPollLinks(true);
- } else {
- throw new Error();
- }
- }),
- {
- loading: "Adding links to import queue...",
- success:
- "Successfully added links to import queue! You can now safely navigate from this tab – we will send you an email when your links have been fully imported.",
- error: "Error adding links to import queue",
+ <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16">
+ {isLoading ? (
+ <button className="flex flex-col items-center justify-center space-y-4 bg-none">
+ <LoadingSpinner />
+ <p className="text-sm text-gray-500">Connecting to Bitly</p>
+ </button>
+ ) : groups ? (
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ setImporting(true);
+ toast.promise(
+ fetch(`/api/projects/${slug}/import/bitly`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
},
- );
- }}
- className="flex flex-col space-y-4"
- >
- <div className="divide-y divide-gray-200">
- {groups.map(({ guid, bsds, tags }) => (
- <div key={guid} className="flex flex-col space-y-2">
- <div className="flex items-center justify-between">
- <p className="text-sm font-medium text-gray-700">
- Domains
- </p>
- <Tooltip content="Your Bitly group ID">
- <p className="cursor-default text-xs uppercase text-gray-400 transition-colors hover:text-gray-700">
- {guid}
- </p>
- </Tooltip>
- </div>
- {bsds.map((bsd) => (
- <div
- key={bsd}
- className="flex items-center justify-between space-x-2 rounded-md border border-gray-200 bg-white px-4 py-2"
- >
- <p className="font-medium text-gray-800">{bsd}</p>
- <Switch
- fn={() => {
- const selected = isSelected(bsd);
- if (selected) {
- setSelectedDomains((prev) =>
- prev.filter((d) => d.domain !== bsd),
- );
- } else {
- setSelectedDomains((prev) => [
- ...prev,
- {
- domain: bsd,
- bitlyGroup: guid,
- },
- ]);
- }
- }}
- checked={isSelected(bsd)}
- />
- </div>
- ))}
- <div className="flex items-center justify-between space-x-2 rounded-md py-1 pl-2 pr-4">
- <p className="text-xs text-gray-500">
- {tags.length} tags found. Import all?
+ body: JSON.stringify({
+ selectedDomains,
+ selectedGroupTags,
+ }),
+ }).then((res) => {
+ setImporting(false);
+ if (res.ok) {
+ closeModal(router);
+ mutate(`/api/projects/${slug}/domains`);
+ setPollLinks(true);
+ } else {
+ throw new Error();
+ }
+ }),
+ {
+ loading: "Adding links to import queue...",
+ success:
+ "Successfully added links to import queue! You can now safely navigate from this tab – we will send you an email when your links have been fully imported.",
+ error: "Error adding links to import queue",
+ },
+ );
+ }}
+ className="flex flex-col space-y-4"
+ >
+ <div className="divide-y divide-gray-200">
+ {groups.map(({ guid, bsds, tags }) => (
+ <div key={guid} className="flex flex-col space-y-2">
+ <div className="flex items-center justify-between">
+ <p className="text-sm font-medium text-gray-700">Domains</p>
+ <Tooltip content="Your Bitly group ID">
+ <p className="cursor-default text-xs uppercase text-gray-400 transition-colors hover:text-gray-700">
+ {guid}
</p>
+ </Tooltip>
+ </div>
+ {bsds.map((bsd) => (
+ <div
+ key={bsd}
+ className="flex items-center justify-between space-x-2 rounded-md border border-gray-200 bg-white px-4 py-2"
+ >
+ <p className="font-medium text-gray-800">{bsd}</p>
<Switch
fn={() => {
- if (selectedGroupTags.includes(guid)) {
- setSelectedGroupTags((prev) =>
- prev.filter((g) => g !== guid),
+ const selected = isSelected(bsd);
+ if (selected) {
+ setSelectedDomains((prev) =>
+ prev.filter((d) => d.domain !== bsd),
);
} else {
- setSelectedGroupTags((prev) => [...prev, guid]);
+ setSelectedDomains((prev) => [
+ ...prev,
+ {
+ domain: bsd,
+ bitlyGroup: guid,
+ },
+ ]);
}
}}
- checked={selectedGroupTags.includes(guid)}
+ checked={isSelected(bsd)}
/>
</div>
+ ))}
+ <div className="flex items-center justify-between space-x-2 rounded-md py-1 pl-2 pr-4">
+ <p className="text-xs text-gray-500">
+ {tags.length} tags found. Import all?
+ </p>
+ <Switch
+ fn={() => {
+ if (selectedGroupTags.includes(guid)) {
+ setSelectedGroupTags((prev) =>
+ prev.filter((g) => g !== guid),
+ );
+ } else {
+ setSelectedGroupTags((prev) => [...prev, guid]);
+ }
+ }}
+ checked={selectedGroupTags.includes(guid)}
+ />
</div>
- ))}
- </div>
- <Button
- text="Confirm import"
- loading={importing}
- disabled={selectedDomains.length === 0}
- />
- <a
- href={bitlyOAuthURL}
- className="text-center text-xs text-gray-500 underline underline-offset-4 transition-colors hover:text-gray-800"
- >
- Sign in to a different Bitly account?
- </a>
- </form>
- ) : (
+ </div>
+ ))}
+ </div>
<Button
- text="Sign in with Bitly"
- variant="secondary"
- loading={redirecting}
- icon={
- <img
- src="/_static/icons/bitly.svg"
- alt="Bitly logo"
- className="h-5 w-5 rounded-full border border-gray-200"
- />
- }
- onClick={() => {
- setRedirecting(true);
- router.push(bitlyOAuthURL);
- }}
+ text="Confirm import"
+ loading={importing}
+ disabled={selectedDomains.length === 0}
/>
- )}
- </div>
+ <a
+ href={bitlyOAuthURL}
+ className="text-center text-xs text-gray-500 underline underline-offset-4 transition-colors hover:text-gray-800"
+ >
+ Sign in to a different Bitly account?
+ </a>
+ </form>
+ ) : (
+ <Button
+ text="Sign in with Bitly"
+ variant="secondary"
+ loading={redirecting}
+ icon={
+ <img
+ src="/_static/icons/bitly.svg"
+ alt="Bitly logo"
+ className="h-5 w-5 rounded-full border border-gray-200"
+ />
+ }
+ onClick={() => {
+ setRedirecting(true);
+ router.push(bitlyOAuthURL);
+ }}
+ />
+ )}
</div>
</Modal>
);
diff --git a/components/app/modals/invite-teammate-modal.tsx b/components/app/modals/invite-teammate-modal.tsx
index e072a8ecf4..7a4eb0dbae 100644
--- a/components/app/modals/invite-teammate-modal.tsx
+++ b/components/app/modals/invite-teammate-modal.tsx
@@ -13,6 +13,7 @@ import Modal from "#/ui/modal";
import useProject from "#/lib/swr/use-project";
import { toast } from "sonner";
import Button from "#/ui/button";
+import { Logo } from "#/ui/icons";
function InviteTeammateModal({
showInviteTeammateModal,
@@ -32,70 +33,70 @@ function InviteTeammateModal({
showModal={showInviteTeammateModal}
setShowModal={setShowInviteTeammateModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ {logo ? (
<BlurImage
- src={logo || `/_static/logo.png`}
+ src={logo}
alt={"Invite Teammate"}
className="h-10 w-10 rounded-full"
width={20}
height={20}
/>
- <h3 className="text-lg font-medium">Invite Teammate</h3>
- <p className="text-center text-sm text-gray-500">
- Invite a teammate to join your project. Invitations will be valid
- for 14 days.
- </p>
- </div>
-
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- setInviting(true);
- fetch(`/api/projects/${slug}/invites`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ email }),
- }).then(async (res) => {
- setInviting(false);
- if (res.status === 200) {
- toast.success("Invitation sent!");
- va.track("User invited teammate", {
- project: slug,
- });
- mutate(`/api/projects/${slug}/invites`);
- setShowInviteTeammateModal(false);
- } else {
- const error = await res.text();
- toast.error(error);
- }
- });
- }}
- className="flex flex-col space-y-4 bg-gray-50 px-4 py-8 text-left sm:px-16"
- >
- <div>
- <label htmlFor="email" className="block text-sm text-gray-700">
- Email
- </label>
- <div className="relative mt-1 rounded-md shadow-sm">
- <input
- type="email"
- name="email"
- id="email"
- placeholder="[email protected]"
- autoFocus
- autoComplete="off"
- required
- value={email}
- onChange={(e) => setEmail(e.target.value)}
- className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- />
- </div>
- </div>
-
- <Button loading={inviting} text="Send invite" />
- </form>
+ ) : (
+ <Logo />
+ )}
+ <h3 className="text-lg font-medium">Invite Teammate</h3>
+ <p className="text-center text-sm text-gray-500">
+ Invite a teammate to join your project. Invitations will be valid for
+ 14 days.
+ </p>
</div>
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ setInviting(true);
+ fetch(`/api/projects/${slug}/invites`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ email }),
+ }).then(async (res) => {
+ setInviting(false);
+ if (res.status === 200) {
+ toast.success("Invitation sent!");
+ va.track("User invited teammate", {
+ project: slug,
+ });
+ mutate(`/api/projects/${slug}/invites`);
+ setShowInviteTeammateModal(false);
+ } else {
+ const error = await res.text();
+ toast.error(error);
+ }
+ });
+ }}
+ className="flex flex-col space-y-4 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ >
+ <div>
+ <label htmlFor="email" className="block text-sm text-gray-700">
+ Email
+ </label>
+ <div className="relative mt-1 rounded-md shadow-sm">
+ <input
+ type="email"
+ name="email"
+ id="email"
+ placeholder="[email protected]"
+ autoFocus
+ autoComplete="off"
+ required
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ />
+ </div>
+ </div>
+ <Button loading={inviting} text="Send invite" />
+ </form>
</Modal>
);
}
diff --git a/components/app/modals/link-filters-modal.tsx b/components/app/modals/link-filters-modal.tsx
index 1cd1305f08..6cc3c9402c 100644
--- a/components/app/modals/link-filters-modal.tsx
+++ b/components/app/modals/link-filters-modal.tsx
@@ -22,9 +22,7 @@ function LinkFiltersModal({
showModal={showLinkFiltersModal}
setShowModal={setShowLinkFiltersModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white pb-20 align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <LinkFilters />
- </div>
+ <LinkFilters />
</Modal>
);
}
diff --git a/components/app/modals/link-qr-modal.tsx b/components/app/modals/link-qr-modal.tsx
index 017e366844..3ea6b80531 100644
--- a/components/app/modals/link-qr-modal.tsx
+++ b/components/app/modals/link-qr-modal.tsx
@@ -8,7 +8,8 @@ import {
} from "react";
import { HexColorInput, HexColorPicker } from "react-colorful";
import BlurImage from "#/ui/blur-image";
-import { Clipboard } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
+import { Clipboard, Download, Photo } from "@/components/shared/icons";
import { ChevronRight } from "lucide-react";
import Modal from "#/ui/modal";
import Switch from "#/ui/switch";
@@ -18,7 +19,6 @@ import useProject from "#/lib/swr/use-project";
import { SimpleLinkProps } from "#/lib/types";
import { getApexDomain, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import { Download, Photo } from "@/components/shared/icons";
import Popover from "@/components/shared/popover";
import { toast } from "sonner";
import { GOOGLE_FAVICON_URL } from "#/lib/constants";
@@ -103,15 +103,19 @@ function LinkQRModalHelper({
return (
<Modal showModal={showLinkQRModal} setShowModal={setShowLinkQRModal}>
- <div className="inline-block w-full transform bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <div className="inline-block w-full transform bg-white align-middle shadow-xl transition-all sm:rounded-2xl sm:border sm:border-gray-200">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- <BlurImage
- src={avatarUrl || "/_static/logo.png"}
- alt={apexDomain}
- className="h-10 w-10 rounded-full"
- width={40}
- height={40}
- />
+ {avatarUrl ? (
+ <BlurImage
+ src={avatarUrl}
+ alt={apexDomain}
+ className="h-10 w-10 rounded-full"
+ width={40}
+ height={40}
+ />
+ ) : (
+ <Logo />
+ )}
<h3 className="text-lg font-medium">Download QR Code</h3>
</div>
diff --git a/components/app/modals/remove-teammate-modal.tsx b/components/app/modals/remove-teammate-modal.tsx
index 5753cdcbe1..41ddb4e433 100644
--- a/components/app/modals/remove-teammate-modal.tsx
+++ b/components/app/modals/remove-teammate-modal.tsx
@@ -13,6 +13,7 @@ import useProject from "#/lib/swr/use-project";
import { toast } from "sonner";
import Button from "#/ui/button";
import { UserProps } from "#/lib/types";
+import { Logo } from "#/ui/icons";
function RemoveTeammateModal({
showRemoveTeammateModal,
@@ -36,73 +37,71 @@ function RemoveTeammateModal({
showModal={showRemoveTeammateModal}
setShowModal={setShowRemoveTeammateModal}
>
- <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ {logo ? (
<BlurImage
- src={logo || `/_static/logo.png`}
- alt="Remove Teammate"
+ src={logo}
+ alt={"Invite Teammate"}
className="h-10 w-10 rounded-full"
width={20}
height={20}
/>
- <h3 className="text-lg font-medium">Remove Teammate</h3>
- <p className="text-center text-sm text-gray-500">
- This will remove{" "}
- <span className="font-semibold text-black">{name || email}</span>
- {invite
- ? "'s invitation to join your project."
- : " from your project. Are you sure you want to continue?"}
- </p>
- </div>
+ ) : (
+ <Logo />
+ )}
+ <h3 className="text-lg font-medium">Remove Teammate</h3>
+ <p className="text-center text-sm text-gray-500">
+ This will remove{" "}
+ <span className="font-semibold text-black">{name || email}</span>
+ {invite
+ ? "'s invitation to join your project."
+ : " from your project. Are you sure you want to continue?"}
+ </p>
+ </div>
- <div className="flex flex-col space-y-4 bg-gray-50 px-4 py-8 text-left sm:px-16">
- <div className="flex items-center space-x-3 rounded-md border border-gray-300 bg-white p-3">
- <BlurImage
- src={
- image || `https://avatars.dicebear.com/api/micah/${email}.svg`
- }
- alt={email}
- width={40}
- height={40}
- className="overflow-hidden rounded-full border border-gray-200"
- />
- <div className="flex flex-col">
- <h3 className="text-sm font-medium">{name || email}</h3>
- <p className="text-xs text-gray-500">{email}</p>
- </div>
- </div>
- <Button
- text="Confirm remove"
- variant="danger"
- loading={removing}
- onClick={() => {
- setRemoving(true);
- fetch(
- `/api/projects/${slug}/${
- invite ? `invites?email=${email}` : `users?userId=${id}`
- }`,
- {
- method: "DELETE",
- headers: { "Content-Type": "application/json" },
- },
- ).then(async (res) => {
- setRemoving(false);
- if (res.status === 200) {
- toast.success(
- `${invite ? "Invite" : "User"} removed from project!`,
- );
- mutate(
- `/api/projects/${slug}/${invite ? "invites" : "users"}`,
- );
- setShowRemoveTeammateModal(false);
- } else {
- const error = await res.text();
- toast.error(error);
- }
- });
- }}
+ <div className="flex flex-col space-y-4 bg-gray-50 px-4 py-8 text-left sm:px-16">
+ <div className="flex items-center space-x-3 rounded-md border border-gray-300 bg-white p-3">
+ <BlurImage
+ src={image || `https://avatars.dicebear.com/api/micah/${email}.svg`}
+ alt={email}
+ width={40}
+ height={40}
+ className="overflow-hidden rounded-full border border-gray-200"
/>
+ <div className="flex flex-col">
+ <h3 className="text-sm font-medium">{name || email}</h3>
+ <p className="text-xs text-gray-500">{email}</p>
+ </div>
</div>
+ <Button
+ text="Confirm remove"
+ variant="danger"
+ loading={removing}
+ onClick={() => {
+ setRemoving(true);
+ fetch(
+ `/api/projects/${slug}/${
+ invite ? `invites?email=${email}` : `users?userId=${id}`
+ }`,
+ {
+ method: "DELETE",
+ headers: { "Content-Type": "application/json" },
+ },
+ ).then(async (res) => {
+ setRemoving(false);
+ if (res.status === 200) {
+ toast.success(
+ `${invite ? "Invite" : "User"} removed from project!`,
+ );
+ mutate(`/api/projects/${slug}/${invite ? "invites" : "users"}`);
+ setShowRemoveTeammateModal(false);
+ } else {
+ const error = await res.text();
+ toast.error(error);
+ }
+ });
+ }}
+ />
</div>
</Modal>
);
diff --git a/components/app/modals/upgrade-plan-modal.tsx b/components/app/modals/upgrade-plan-modal.tsx
index d05c2caf97..39337b3b42 100644
--- a/components/app/modals/upgrade-plan-modal.tsx
+++ b/components/app/modals/upgrade-plan-modal.tsx
@@ -17,6 +17,7 @@ import { PLANS } from "#/lib/stripe/utils";
import { getStripe } from "#/lib/stripe/client";
import Badge from "#/ui/badge";
import Confetti from "react-dom-confetti";
+import { Logo } from "#/ui/icons";
function UpgradePlanModal({
showUpgradePlanModal,
@@ -67,14 +68,9 @@ function UpgradePlanModal({
animate="show"
className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-8 sm:px-16"
>
- <motion.img
- src="/_static/logo.png"
- alt="Dub logo"
- className="h-10 w-10 rounded-full border border-gray-200"
- width={20}
- height={20}
- variants={STAGGER_CHILD_VARIANTS}
- />
+ <motion.div variants={STAGGER_CHILD_VARIANTS}>
+ <Logo />
+ </motion.div>
<motion.h3
className="text-lg font-medium"
variants={STAGGER_CHILD_VARIANTS}
diff --git a/components/app/welcome/interim.tsx b/components/app/welcome/interim.tsx
index efc63a0b4f..f6297cb343 100644
--- a/components/app/welcome/interim.tsx
+++ b/components/app/welcome/interim.tsx
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { motion } from "framer-motion";
import BlurImage from "#/ui/blur-image";
-import { Logo } from "@/components/shared/icons";
+import { Logo } from "#/ui/icons";
import { STAGGER_CHILD_VARIANTS } from "#/lib/constants";
export default function Interim() {
diff --git a/components/layout/app/index.tsx b/components/layout/app/index.tsx
index af06e3f1f2..4802d00fff 100644
--- a/components/layout/app/index.tsx
+++ b/components/layout/app/index.tsx
@@ -2,7 +2,8 @@ import dynamic from "next/dynamic";
import Link from "next/link";
import { useRouter } from "next/router";
import { ReactNode, useContext, useEffect, useState } from "react";
-import { Divider, Logo } from "@/components/shared/icons";
+import { Divider } from "@/components/shared/icons";
+import Logo from "#/ui/icons/logo";
import Meta from "../meta";
import ProjectSelect from "./project-select";
import UserDropdown from "./user-dropdown";
diff --git a/components/layout/app/project-select.tsx b/components/layout/app/project-select.tsx
index b3ad8ccee6..f0b335b774 100644
--- a/components/layout/app/project-select.tsx
+++ b/components/layout/app/project-select.tsx
@@ -1,5 +1,5 @@
import { useRouter } from "next/router";
-import { useContext, useMemo, useState } from "react";
+import { useCallback, useContext, useMemo, useState } from "react";
import { useSession } from "next-auth/react";
import BlurImage from "#/ui/blur-image";
import { Tick } from "@/components/shared/icons";
@@ -125,6 +125,20 @@ function ProjectList({
}) {
const { data: session } = useSession();
const { setShowAddProjectModal } = useContext(ModalContext);
+ const router = useRouter();
+ const { domain, key } = router.query as { domain?: string; key?: string };
+ const href = useCallback(
+ (slug: string) => {
+ if (domain || key || selected.slug === "/") {
+ // if we're on a link page, navigate back to the project root
+ return `/${slug}`;
+ } else {
+ // else, we keep the path but remove all query params
+ return router.asPath.replace(selected.slug, slug).split("?")[0];
+ }
+ },
+ [domain, key, router, selected.slug],
+ );
return (
<div className="relative mt-1 max-h-72 w-full space-y-0.5 overflow-auto rounded-md bg-white p-2 text-base sm:w-60 sm:text-sm sm:shadow-lg">
@@ -168,7 +182,8 @@ function ProjectList({
className={`relative flex w-full items-center space-x-2 rounded-md px-2 py-1.5 hover:bg-gray-100 active:bg-gray-200 ${
selected.slug === slug ? "font-medium" : ""
} transition-all duration-75`}
- href={`/${slug}`}
+ href={href(slug)}
+ shallow={false}
>
<BlurImage
src={logo || `${GOOGLE_FAVICON_URL}${primaryDomain?.slug}`}
diff --git a/components/shared/icons/index.tsx b/components/shared/icons/index.tsx
index 2c037f02ff..e86e71101c 100644
--- a/components/shared/icons/index.tsx
+++ b/components/shared/icons/index.tsx
@@ -5,7 +5,6 @@ export { default as Copy } from "./copy";
export { default as X } from "./x";
export { default as Chart } from "./chart";
export { default as Divider } from "./divider";
-export { default as Logo } from "./logo";
export { default as Github } from "./github";
export { default as Twitter } from "./twitter";
export { default as Facebook } from "./facebook";
diff --git a/components/shared/icons/logo.tsx b/components/shared/icons/logo.tsx
deleted file mode 100644
index 9fb7eb2220..0000000000
--- a/components/shared/icons/logo.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-export default function Logo({ className }: { className: string }) {
- return (
- <svg
- width="191"
- height="191"
- fill="currentColor"
- viewBox="0 0 191 191"
- className={className}
- >
- <g clipPath="url(#clip0_928_108)">
- <path
- fill="currentColor"
- fillRule="evenodd"
- d="M122-14h22v27.215a94.965 94.965 0 00-22-9.49V-14zm0 17.725A95.548 95.548 0 0095.5 0C42.757 0 0 42.757 0 95.5S42.757 191 95.5 191 191 148.243 191 95.5c0-35.038-18.869-65.669-47-82.285V148h-22v-7.103A48.776 48.776 0 0195 149c-27.062 0-49-21.938-49-49s21.938-49 49-49a48.773 48.773 0 0127 8.103V3.725z"
- clipRule="evenodd"
- ></path>
- </g>
- <defs>
- <clipPath id="clip0_928_108">
- <rect width="191" height="191" fill="#fff" rx="95.5"></rect>
- </clipPath>
- </defs>
- </svg>
- );
-}
diff --git a/components/stats/toggle.tsx b/components/stats/toggle.tsx
index 4cf75c6bc1..4b86130190 100644
--- a/components/stats/toggle.tsx
+++ b/components/stats/toggle.tsx
@@ -56,7 +56,7 @@ export default function Toggle({ atModalTop }: { atModalTop?: boolean }) {
)}
<Popover
content={
- <div className="w-full p-2 md:w-48">
+ <div className="grid w-full p-2 md:w-48">
{INTERVALS.map(({ display, slug }) =>
(slug === "all" || slug === "90d") &&
(!plan || plan === "free") ? (