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.

More modal UI improvements

Tim Wilsonacdaba638690
diff --git a/apps/web/ui/modals/register-domain.tsx b/apps/web/ui/modals/register-domain.tsx
index f82eedbb06..455fb58561 100644
--- a/apps/web/ui/modals/register-domain.tsx
+++ b/apps/web/ui/modals/register-domain.tsx
@@ -1,9 +1,16 @@
import useWorkspace from "@/lib/swr/use-workspace";
-import { Button, Modal, SimpleTooltipContent, useMediaQuery } from "@dub/ui";
+import {
+ AnimatedSizeContainer,
+ Button,
+ Modal,
+ SimpleTooltipContent,
+ useMediaQuery,
+} from "@dub/ui";
import { cn } from "@dub/utils";
import { CircleCheck, Search } from "lucide-react";
import { FormEvent, useCallback, useEffect, useMemo, useState } from "react";
import { toast } from "sonner";
+import { AlertCircleFill, CheckCircleFill } from "../shared/icons";
import { ProBadgeTooltip } from "../shared/pro-badge-tooltip";
interface RegisterDomainProps {
@@ -107,82 +114,110 @@ const RegisterDomain = ({ showModal, setShowModal }: RegisterDomainProps) => {
)}
</div>
- <div
- className={cn(
- "mt-2 flex rounded-md border border-gray-300",
- // searchedDomain?.available ? "bg-[#def5c6]" : "bg-white",
- // !searchedDomain?.available ? "bg-[#F5E4C6]" : "bg-white",
- )}
- >
- <input
- name="domain"
- id="domain"
- type="text"
- required
- autoComplete="off"
- className="block w-full rounded-md rounded-r-none border-0 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm"
- aria-invalid="true"
- autoFocus={!isMobile}
- placeholder={workspace.slug}
- value={slug}
- onChange={(e) => {
- setSlug(e.target.value);
- }}
- />
- <span className="inline-flex items-center rounded-md rounded-l-none bg-white px-3 font-medium text-gray-500 sm:text-sm">
- .link
- </span>
- <div className="p-0.5">
- <Button
- className="h-8 w-fit border-gray-300 px-2"
- icon={<Search className="mx-0.5 size-4" />}
- onClick={searchDomainAvailability}
- disabled={!slug || isSearching}
- loading={isSearching}
- />
+ <div className="mt-2">
+ <div
+ className={cn(
+ "-m-1 rounded-[0.625rem] p-1",
+ searchedDomain &&
+ (searchedDomain.available ? "bg-[#def5c6]" : "bg-orange-100"),
+ )}
+ >
+ <div className="flex rounded-md border border-gray-300 bg-white">
+ <input
+ name="domain"
+ id="domain"
+ type="text"
+ required
+ autoComplete="off"
+ className="block w-full rounded-md rounded-r-none border-0 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm"
+ aria-invalid="true"
+ autoFocus={!isMobile}
+ placeholder={workspace.slug}
+ value={slug}
+ onChange={(e) => {
+ setSlug(e.target.value);
+ }}
+ />
+ <span className="inline-flex items-center rounded-md rounded-l-none bg-white px-3 font-medium text-gray-500 sm:text-sm">
+ .link
+ </span>
+ <div className="p-0.5">
+ <Button
+ className="h-8 w-fit border-gray-300 px-2"
+ icon={<Search className="mx-0.5 size-4" />}
+ onClick={searchDomainAvailability}
+ disabled={!slug || isSearching}
+ loading={isSearching}
+ />
+ </div>
+ </div>
+
+ <AnimatedSizeContainer
+ height
+ transition={{ ease: "easeInOut", duration: 0.1 }}
+ >
+ {searchedDomain && (
+ <div className="flex justify-between gap-3 px-2 pb-2 pt-3 text-sm text-gray-700">
+ <p>
+ {searchedDomain.available ? (
+ <>
+ <span className="font-semibold text-gray-800">
+ {searchedDomain.domain}
+ </span>{" "}
+ is available. Claim your free domain before it's gone!
+ </>
+ ) : (
+ <>
+ <span className="font-semibold text-gray-800">
+ {searchedDomain?.domain}
+ </span>{" "}
+ is not available.
+ </>
+ )}
+ </p>
+ {searchedDomain.available ? (
+ <CheckCircleFill className="size-5 shrink-0 text-green-500" />
+ ) : (
+ <AlertCircleFill className="size-5 shrink-0 text-amber-500" />
+ )}
+ </div>
+ )}
+ </AnimatedSizeContainer>
</div>
</div>
-
- {searchedDomain &&
- (searchedDomain?.available ? (
- <div className="rounded-md bg-[#DEF5C6] p-2 text-sm">
- <strong>{searchedDomain.domain}</strong> is available. Claim
- your free domain before it's gone!
- </div>
- ) : (
- <div className="rounded-md bg-[#F5E4C6] p-2 text-sm">
- <strong>{searchedDomain?.domain}</strong> is not available.
- </div>
- ))}
</div>
- {availableDomains.length > 0 && (
- <div>
- <h2 className="text-sm font-medium">Available alternatives</h2>
- <div className="mt-2 overflow-hidden rounded-md border border-gray-200">
- <div className="flex flex-col divide-y divide-gray-200">
- {availableDomains.map((alternative) => (
- <div
- key={alternative.domain}
- className="flex items-center justify-between px-3 py-2 focus:outline-none"
- >
- <div className="flex items-center gap-2">
- <CircleCheck className="size-5 fill-green-500 text-white" />
- <span className="text-sm font-medium">
- {alternative.domain}
- </span>
+ {searchedDomain &&
+ !searchedDomain.available &&
+ availableDomains.length > 0 && (
+ <div>
+ <h2 className="text-sm font-medium text-gray-800">
+ Available alternatives
+ </h2>
+ <div className="mt-2 overflow-hidden rounded-lg border border-gray-200">
+ <div className="flex flex-col divide-y divide-gray-200">
+ {availableDomains.map((alternative) => (
+ <div
+ key={alternative.domain}
+ className="flex items-center justify-between p-1.5 pl-3 focus:outline-none"
+ >
+ <div className="flex items-center gap-2">
+ <CircleCheck className="size-5 fill-green-500 text-white" />
+ <span className="text-sm font-medium">
+ {alternative.domain}
+ </span>
+ </div>
+ <Button
+ text="Claim domain"
+ className="h-8 w-fit"
+ onClick={() => registerDomain(alternative.domain)}
+ />
</div>
- <Button
- text="Claim domain"
- className="h-8 w-fit"
- onClick={() => registerDomain(alternative.domain)}
- />
- </div>
- ))}
+ ))}
+ </div>
</div>
</div>
- </div>
- )}
+ )}
</form>
<div className="flex justify-end gap-2 border-t border-gray-200 px-4 py-4 sm:px-6">
<Button