The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
improved styles
Steven Teyda8c4e967ed0
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsxindex 69ee8b7b78..021ab8660e 100644--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx@@ -1,4 +1,4 @@-import HelpButton from "@/ui/layout/help-button";+import { HelpButton } from "@/ui/layout/help";import NavTabs from "@/ui/layout/nav-tabs";import UpgradeBanner from "@/ui/layout/upgrade-banner";import UserDropdown from "@/ui/layout/user-dropdown";diff --git a/apps/web/ui/layout/help-button.tsx b/apps/web/ui/layout/help-button.tsxdeleted file mode 100644index d24ebdee5e..0000000000--- a/apps/web/ui/layout/help-button.tsx+++ /dev/null@@ -1,172 +0,0 @@-"use client";--import { Button, Popover } from "@dub/ui";-import { cn } from "@dub/utils";-import { AnimatePresence, motion } from "framer-motion";-import {- BookOpenText,- ChevronLeft,- LucideIcon,- MessageSquareText,- Upload,- XIcon,-} from "lucide-react";-import Link from "next/link";-import { ElementType, useEffect, useRef, useState } from "react";-import TextareaAutosize from "react-textarea-autosize";--export default function HelpButton() {- const [isOpen, setIsOpen] = useState(false);-- return (- <Popover- content={- <div className="w-full overflow-hidden px-6 py-5 text-sm">- <HelpSection onClose={() => setIsOpen(false)} />- </div>- }- openPopover={isOpen}- setOpenPopover={setIsOpen}- align="end"- >- <button- type="button"- onClick={() => setIsOpen((o) => !o)}- className="font-lg relative h-12 w-12 overflow-hidden rounded-full border border-gray-200 bg-white shadow-md active:bg-gray-50"- >- <AnimatePresence>- <motion.div- key={isOpen ? "open" : "closed"}- className="absolute inset-0 flex items-center justify-center text-base font-medium text-gray-700 hover:text-gray-700"- initial={{ opacity: 0, scale: 0 }}- animate={{ opacity: 1, scale: 1 }}- exit={{ opacity: 0, scale: 0 }}- >- {isOpen ? <XIcon className="h-4 w-4" strokeWidth={2} /> : "?"}- </motion.div>- </AnimatePresence>- </button>- </Popover>- );-}--function HelpSection({ onClose }: { onClose: () => void }) {- const [screen, setScreen] = useState<"main" | "contact">("main");- const [message, setMessage] = useState("");-- const ref = useRef<HTMLDivElement>(null);- const [contentHeight, setContentHeight] = useState(0);-- useEffect(() => {- if (ref.current) {- setContentHeight(ref.current.offsetHeight);- }- });-- return (- <motion.div- className="max-w-full sm:w-[20rem]"- animate={{ height: contentHeight }}- transition={{ ease: "easeInOut" }}- >- <div ref={ref}>- {screen === "main" && (- <div className="w-full">- <h3 className="text-base font-semibold">Need help?</h3>- <p className="mt-2 text-gray-600">- Check out our help center or get in touch for more assistance.- </p>- <div className="mt-3 flex flex-col space-y-1">- <HelpLink- icon={BookOpenText}- label="Help center"- href="https://dub.co/help"- />- <HelpLink- as="button"- type="button"- icon={MessageSquareText}- label="Get in touch"- onClick={() => setScreen("contact")}- />- </div>- </div>- )}- {screen === "contact" && (- <div className="w-full">- <button- type="button"- className="-ml-2 flex items-center space-x-2 rounded-md px-2 py-1 hover:bg-gray-100"- onClick={() => setScreen("main")}- >- <ChevronLeft className="h-4 w-4" />- <h3 className="flex items-center gap-0.5 text-base font-semibold">- Contact support- </h3>- </button>- <label className="mt-5 block w-full">- <span className="block text-sm font-medium text-gray-700">- Your message- </span>- <TextareaAutosize- name="message"- required- placeholder="E.g. My custom domain is not working."- value={message}- autoComplete="off"- onChange={(e) => setMessage(e.target.value)}- rows={3}- className={`${- false- ? "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"- } mt-1 block w-full resize-none rounded-md focus:outline-none sm:text-sm`}- />- </label>- {/* TODO */}- <label className="mt-3 flex cursor-pointer items-center space-x-1 py-1">- <p className="text-gray-500 hover:text-gray-700 hover:underline">- Upload attachment- </p>- <Upload className="h-3 w-3" />- </label>- <Button- className="mt-3 h-9"- disabled={!message}- text="Send message"- />- </div>- )}- </div>- </motion.div>- );-}--function HelpLink<T extends ElementType = typeof Link>({- as,- icon: Icon,- label,- href,- onClick,-}: {- as?: T;- icon: LucideIcon;- label: string;-} & React.ComponentPropsWithoutRef<T>) {- const Component = as || Link;-- return (- <Component- href={href}- target="_blank"- className={cn(- "-mx-2 flex items-center gap-1.5 rounded-md px-2 py-1.5 font-medium text-gray-800",- "transition-colors duration-75 hover:bg-gray-100 hover:text-gray-800 active:bg-gray-200",- )}- onClick={onClick}- >- <Icon className="h-4 w-4" />- {label}- </Component>- );-}diff --git a/apps/web/ui/layout/help/contact-form.tsx b/apps/web/ui/layout/help/contact-form.tsxnew file mode 100644index 0000000000..c1494bbdbb--- /dev/null+++ b/apps/web/ui/layout/help/contact-form.tsx@@ -0,0 +1,52 @@+import { Button } from "@dub/ui";+import { ChevronLeft, Upload } from "lucide-react";+import { Dispatch, SetStateAction, useState } from "react";+import TextareaAutosize from "react-textarea-autosize";++export function ContactForm({+ setScreen,+}: {+ setScreen: Dispatch<SetStateAction<"main" | "contact">>;+}) {+ const [message, setMessage] = useState("");++ return (+ <div className="w-full px-6 py-5">+ <button+ type="button"+ className="-ml-2 flex items-center space-x-1 rounded-md px-2 py-1"+ onClick={() => setScreen("main")}+ >+ <ChevronLeft className="h-4 w-4" />+ <h3 className="font-semibold">Contact support</h3>+ </button>+ <label className="mt-5 block w-full">+ <span className="block text-sm font-medium text-gray-700">+ Your message+ </span>+ <TextareaAutosize+ name="message"+ required+ placeholder="E.g. My custom domain is not working."+ value={message}+ autoComplete="off"+ onChange={(e) => setMessage(e.target.value)}+ minRows={8}+ className={`${+ false+ ? "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"+ } mt-1 block w-full resize-none rounded-md focus:outline-none sm:text-sm`}+ />+ </label>+ {/* TODO */}+ <label className="mt-3 flex cursor-pointer items-center space-x-1 py-1">+ <p className="text-sm text-gray-500 hover:text-gray-700 hover:underline">+ Upload attachment+ </p>+ <Upload className="h-3 w-3" />+ </label>+ <Button className="mt-3 h-9" disabled={!message} text="Send message" />+ </div>+ );+}diff --git a/apps/web/ui/layout/help/index.tsx b/apps/web/ui/layout/help/index.tsxnew file mode 100644index 0000000000..e65beac466--- /dev/null+++ b/apps/web/ui/layout/help/index.tsx@@ -0,0 +1,69 @@+"use client";++import { Popover } from "@dub/ui";+import { AnimatePresence, motion } from "framer-motion";+import { XIcon } from "lucide-react";+import { useEffect, useRef, useState } from "react";+import { ContactForm } from "./contact-form";+import { MainScreen } from "./main-screen";++export function HelpButton() {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <Popover+ content={+ <div className="w-full overflow-hidden">+ <HelpSection />+ </div>+ }+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ align="end"+ >+ <button+ type="button"+ onClick={() => setIsOpen((o) => !o)}+ className="font-lg relative h-12 w-12 overflow-hidden rounded-full border border-gray-200 bg-white shadow-md active:bg-gray-50"+ >+ <AnimatePresence>+ <motion.div+ key={isOpen ? "open" : "closed"}+ className="absolute inset-0 flex items-center justify-center font-medium text-gray-700 hover:text-gray-700"+ initial={{ opacity: 0, scale: 0 }}+ animate={{ opacity: 1, scale: 1 }}+ exit={{ opacity: 0, scale: 0 }}+ >+ {isOpen ? <XIcon className="h-4 w-4" strokeWidth={2} /> : "?"}+ </motion.div>+ </AnimatePresence>+ </button>+ </Popover>+ );+}++function HelpSection() {+ const [screen, setScreen] = useState<"main" | "contact">("main");++ const ref = useRef<HTMLDivElement>(null);+ const [contentHeight, setContentHeight] = useState(0);++ useEffect(() => {+ if (ref.current) {+ setContentHeight(ref.current.offsetHeight);+ }+ });++ return (+ <motion.div+ className="max-w-full sm:w-[24rem]"+ animate={{ height: contentHeight }}+ transition={{ ease: "easeInOut" }}+ >+ <div ref={ref}>+ {screen === "main" && <MainScreen setScreen={setScreen} />}+ {screen === "contact" && <ContactForm setScreen={setScreen} />}+ </div>+ </motion.div>+ );+}diff --git a/apps/web/ui/layout/help/main-screen.tsx b/apps/web/ui/layout/help/main-screen.tsxnew file mode 100644index 0000000000..a3ff051b6b--- /dev/null+++ b/apps/web/ui/layout/help/main-screen.tsx@@ -0,0 +1,37 @@+import { ExternalLink, MessageSquareText } from "lucide-react";+import { Dispatch, SetStateAction } from "react";++export function MainScreen({+ setScreen,+}: {+ setScreen: Dispatch<SetStateAction<"main" | "contact">>;+}) {+ return (+ <div className="w-full">+ <div className="px-6 py-5">+ <h3 className="font-semibold">Need help?</h3>+ <p className="mt-2 text-sm text-gray-600">+ Check out our help center or get in touch for more assistance.+ </p>+ <div className="mt-3 flex h-[200px] flex-col space-y-1"></div>+ </div>+ <div className="flex justify-between border-t border-gray-200 px-5 py-4">+ <button+ onClick={() => setScreen("contact")}+ className="flex items-center space-x-2 hover:underline"+ >+ <MessageSquareText className="h-4 w-4" />+ <p className="text-sm">Contact us</p>+ </button>+ <a+ href="https://dub.co/help"+ target="_blank"+ className="flex items-center space-x-2 hover:underline"+ >+ <p className="text-sm">Help center</p>+ <ExternalLink className="h-4 w-4" />+ </a>+ </div>+ </div>+ );+}