The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Migrate marketing site to App Router
Steven Tey4ff9cb0a693e
diff --git a/app/(marketing)/changelog/[slug]/page.tsx b/app/(marketing)/changelog/[slug]/page.tsxindex 71007719ce..45b4a5d18e 100644--- a/app/(marketing)/changelog/[slug]/page.tsx+++ b/app/(marketing)/changelog/[slug]/page.tsx@@ -1,12 +1,12 @@import type { Metadata } from "next";import { notFound } from "next/navigation";import { allChangelogPosts } from "contentlayer/generated";-import { MDX } from "@/ui/blog/mdx";+import { MDX } from "#/ui/blog/mdx";import Link from "next/link";import { formatDate } from "@/lib/utils";import { getBlurDataURL } from "@/lib/images";-import BlurImage from "@/components/shared/blur-image";-import Author from "@/ui/blog/author";+import BlurImage from "#/ui/blur-image";+import Author from "#/ui/blog/author";import { Facebook, LinkedIn, Twitter } from "@/components/shared/icons";export async function generateStaticParams() {diff --git a/app/(marketing)/changelog/page.tsx b/app/(marketing)/changelog/page.tsxindex 85d10afcd1..71e5f4f4c6 100644--- a/app/(marketing)/changelog/page.tsx+++ b/app/(marketing)/changelog/page.tsx@@ -1,10 +1,10 @@-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { getBlurDataURL } from "@/lib/images";import { allChangelogPosts } from "contentlayer/generated";import { Metadata } from "next";import { formatDate } from "@/lib/utils";import Link from "next/link";-import { MDX } from "@/ui/blog/mdx";+import { MDX } from "#/ui/blog/mdx";import { Twitter } from "@/components/shared/icons";import { Rss } from "lucide-react";diff --git a/app/(marketing)/navigation-menu.tsx b/app/(marketing)/navigation-menu.tsxindex a1cb70fd68..d791392ef7 100644--- a/app/(marketing)/navigation-menu.tsx+++ b/app/(marketing)/navigation-menu.tsx@@ -2,6 +2,7 @@import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";import clsx from "clsx";+import Link from "next/link";import React from "react";const comparisons = [@@ -88,7 +89,7 @@ export default function NavigationMenu() {<div className="w-[16rem] p-3 lg:w-[18rem]"><div className="grid w-full gap-2">{comparisons.map(({ title, slug }) => (- <NavigationMenuPrimitive.Link+ <Linkkey={slug}className={clsx("w-full rounded-md px-4 py-3 hover:bg-gray-100 dark:hover:bg-gray-900",@@ -103,7 +104,7 @@ export default function NavigationMenu() {<div className="mt-1 text-sm text-gray-500 dark:text-gray-400">Lorem ipsum dolor sit amet.</div>- </NavigationMenuPrimitive.Link>+ </Link>))}</div></div>@@ -111,7 +112,7 @@ export default function NavigationMenu() {</NavigationMenuPrimitive.Item> */}<NavigationMenuPrimitive.Item asChild>- <NavigationMenuPrimitive.Link+ <Linkhref="/#pricing"className={clsx("rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",@@ -119,11 +120,11 @@ export default function NavigationMenu() {)}>Pricing- </NavigationMenuPrimitive.Link>+ </Link></NavigationMenuPrimitive.Item>{/* <NavigationMenuPrimitive.Item asChild>- <NavigationMenuPrimitive.Link+ <Linkhref="/blog"className={clsx("rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",@@ -131,11 +132,11 @@ export default function NavigationMenu() {)}>Blog- </NavigationMenuPrimitive.Link>+ </Link></NavigationMenuPrimitive.Item> */}<NavigationMenuPrimitive.Item asChild>- <NavigationMenuPrimitive.Link+ <Linkhref="/changelog"className={clsx("rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",@@ -143,7 +144,7 @@ export default function NavigationMenu() {)}>Changelog- </NavigationMenuPrimitive.Link>+ </Link></NavigationMenuPrimitive.Item><NavigationMenuPrimitive.Indicatordiff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsxnew file mode 100644index 0000000000..201b272fca--- /dev/null+++ b/app/(marketing)/page.tsx@@ -0,0 +1,34 @@+import Background from "@/components/shared/background";+import Demo from "#/ui/home/demo";+import Features from "#/ui/home/features";+import Globe from "#/ui/home/globe";+import Hero from "#/ui/home/hero";+import Logos from "#/ui/home/logos";+import Pricing from "#/ui/home/pricing";+import OSS from "#/ui/home/oss";+import Testimonials from "#/ui/home/testimonials";+import { Suspense } from "react";++export default function Home() {+ return (+ <>+ <div className="z-10">+ <Hero />+ <Demo />+ <Logos />+ <Globe />+ <Features />+ <Suspense fallback="">+ {/* @ts-expect-error Async Server Component */}+ <Testimonials />+ </Suspense>+ <Pricing homePage />+ <Suspense fallback="">+ {/* @ts-expect-error Async Server Component */}+ <OSS />+ </Suspense>+ </div>+ <Background />+ </>+ );+}diff --git a/app/lib/hooks/use-domains.ts b/app/lib/hooks/use-domains.tsnew file mode 100644index 0000000000..e22047246a--- /dev/null+++ b/app/lib/hooks/use-domains.ts@@ -0,0 +1,45 @@+import { useParams } from "next/navigation";+import { useMemo } from "react";+import useSWR from "swr";+import { DomainProps } from "@/lib/types";+import { fetcher } from "@/lib/utils";++export default function useDomains({ domain }: { domain?: string } = {}) {+ const { slug } = useParams() as {+ slug: string;+ };++ const { data, error } = useSWR<DomainProps[]>(+ slug && `/api/projects/${slug}/domains`,+ fetcher,+ {+ dedupingInterval: 60000,+ },+ );++ const domains = useMemo(() => {+ return slug+ ? data+ : ([+ {+ slug: "dub.sh",+ verified: true,+ primary: true,+ target: "https://dub.sh",+ type: "redirect",+ },+ ] as DomainProps[]);+ }, [data]);++ return {+ domains,+ primaryDomain: domains?.find((domain) => domain.primary)?.slug,+ verified: domain+ ? // If a domain is passed, check if it's verified+ domains?.find((d) => d.slug === domain)?.verified+ : // If no domain is passed, check if any of the domains are verified+ domains?.some((d) => d.verified),+ loading: !domains && !error,+ error,+ };+}diff --git a/app/lib/hooks/use-project.ts b/app/lib/hooks/use-project.tsnew file mode 100644index 0000000000..6ed36c37ad--- /dev/null+++ b/app/lib/hooks/use-project.ts@@ -0,0 +1,29 @@+import { useParams } from "next/navigation";+import useSWR from "swr";+import { ProjectProps } from "@/lib/types";+import { fetcher } from "@/lib/utils";+import { useMemo } from "react";++export default function useProject() {+ const { slug } = useParams() as { slug?: string };++ const { data: project, error } = useSWR<ProjectProps>(+ slug && `/api/projects/${slug}`,+ fetcher,+ {+ dedupingInterval: 30000,+ },+ );++ const exceededUsage = useMemo(() => {+ if (project) {+ return project.usage > project.usageLimit;+ }+ }, [project]);++ return {+ ...project,+ exceededUsage,+ error,+ };+}diff --git a/components/shared/accordion.tsx b/app/ui/accordion.tsxsimilarity index 96%rename from components/shared/accordion.tsxrename to app/ui/accordion.tsxindex 2a019a6164..cf028f4dff 100644--- a/components/shared/accordion.tsx+++ b/app/ui/accordion.tsx@@ -1,6 +1,8 @@+"use client";+import React, { ReactNode } from "react";import { styled, keyframes } from "@stitches/react";-import { ChevronDown } from "./icons";+import { ChevronDown } from "lucide-react";import * as AccordionPrimitive from "@radix-ui/react-accordion";const slideDown = keyframes({diff --git a/app/ui/blog/author.tsx b/app/ui/blog/author.tsxindex 83d7a8ee36..a2bfc4cd24 100644--- a/app/ui/blog/author.tsx+++ b/app/ui/blog/author.tsx@@ -1,4 +1,4 @@-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import Link from "next/link";export default async function Author({diff --git a/app/ui/blog/mdx.tsx b/app/ui/blog/mdx.tsxindex ee08abe04f..9f43269d96 100644--- a/app/ui/blog/mdx.tsx+++ b/app/ui/blog/mdx.tsx@@ -4,7 +4,7 @@ import Link from "next/link";import { useMDXComponent } from "next-contentlayer/hooks";import Tweet from "../../../components/shared/tweet";import GithubRepo, { GithubRepoProps } from "@/components/shared/github-repo";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";const CustomLink = (props: any) => {const href = props.href;diff --git a/components/shared/blur-image.tsx b/app/ui/blur-image.tsxsimilarity index 100%rename from components/shared/blur-image.tsxrename to app/ui/blur-image.tsxdiff --git a/app/ui/button.tsx b/app/ui/button.tsxindex ef408242eb..cd7eed8f93 100644--- a/app/ui/button.tsx+++ b/app/ui/button.tsx@@ -1,7 +1,7 @@"use client";-import { LoadingDots } from "@/components/shared/icons";-import Tooltip from "@/components/shared/tooltip";+import { LoadingDots } from "#/ui/icons";+import Tooltip from "#/ui/tooltip";import clsx from "clsx";import { ReactNode } from "react";diff --git a/components/home/demo.tsx b/app/ui/home/demo.tsxsimilarity index 93%rename from components/home/demo.tsxrename to app/ui/home/demo.tsxindex b4262d0246..fd9ee2cdd4 100644--- a/components/home/demo.tsx+++ b/app/ui/home/demo.tsx@@ -3,10 +3,11 @@import { useState } from "react";import { motion } from "framer-motion";import { Toaster } from "react-hot-toast";-import LinkCard from "@/components/home/link-card";-import PlaceholderCard from "@/components/home/placeholder-card";-import { Link, LoadingDots } from "@/components/shared/icons";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import LinkCard from "#/ui/home/link-card";+import PlaceholderCard from "#/ui/home/placeholder-card";+import { LoadingDots } from "#/ui/icons";+import { Link2 } from "lucide-react";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import { FRAMER_MOTION_LIST_ITEM_VARIANTS } from "@/lib/constants";import useLocalStorage from "@/lib/hooks/use-local-storage";import { SimpleLinkProps } from "@/lib/types";@@ -61,7 +62,7 @@ const Demo = () => {</Tooltip>) : (<div className="relative flex items-center">- <Link className="absolute inset-y-0 left-0 my-2 ml-3 w-5 text-gray-400" />+ <Link2 className="absolute inset-y-0 left-0 my-2 ml-3 w-5 text-gray-400" /><inputtype="url"placeholder="Shorten your link"diff --git a/components/home/features.module.css b/app/ui/home/features.module.csssimilarity index 100%rename from components/home/features.module.cssrename to app/ui/home/features.module.cssdiff --git a/components/home/features.tsx b/app/ui/home/features.tsxsimilarity index 97%rename from components/home/features.tsxrename to app/ui/home/features.tsxindex cc427ebf4c..71863e3fef 100644--- a/components/home/features.tsx+++ b/app/ui/home/features.tsx@@ -4,11 +4,11 @@ import Link from "next/link";import { Airplay, Chart, QR, Users, Photo } from "@/components/shared/icons";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { useState } from "react";-import Accordion from "@/components/shared/accordion";+import Accordion from "#/ui/accordion";import { AnimatePresence, motion } from "framer-motion";-import { useLinkQRModal } from "../app/modals/link-qr-modal";+import { useLinkQRModal } from "#/ui/modals/link-qr-modal";import { DEFAULT_LINK_PROPS } from "@/lib/constants";-import { useAddEditLinkModal } from "../app/modals/add-edit-link-modal";+import { useAddEditLinkModal } from "#/ui/modals/add-edit-link-modal";import { Link2 } from "lucide-react";const featureList = [diff --git a/components/home/globe.tsx b/app/ui/home/globe.tsxsimilarity index 100%rename from components/home/globe.tsxrename to app/ui/home/globe.tsxdiff --git a/components/home/hero.tsx b/app/ui/home/hero.tsxsimilarity index 100%rename from components/home/hero.tsxrename to app/ui/home/hero.tsxdiff --git a/components/home/link-card.tsx b/app/ui/home/link-card.tsxsimilarity index 95%rename from components/home/link-card.tsxrename to app/ui/home/link-card.tsxindex 530d83d3f0..e81279c846 100644--- a/components/home/link-card.tsx+++ b/app/ui/home/link-card.tsx@@ -3,10 +3,12 @@ import { useEffect, useMemo, useRef, useState } from "react";import { motion, useAnimation, useMotionValue } from "framer-motion";import toast from "react-hot-toast";import useSWR from "swr";-import { useLinkQRModal } from "@/components/app/modals/link-qr-modal";-import BlurImage from "@/components/shared/blur-image";+import { useAddEditLinkModal } from "#/ui/modals/add-edit-link-modal";+import { useLinkQRModal } from "#/ui/modals/link-qr-modal";+import BlurImage from "#/ui/blur-image";import CopyButton from "@/components/shared/copy-button";-import { Chart, LoadingDots, QR, ThreeDots } from "@/components/shared/icons";+import { Chart, QR, ThreeDots } from "@/components/shared/icons";+import { LoadingDots } from "#/ui/icons";import {DEFAULT_LINK_PROPS,FRAMER_MOTION_LIST_ITEM_VARIANTS,@@ -19,7 +21,6 @@ import {linkConstructor,nFormatter,} from "@/lib/utils";-import { useAddEditLinkModal } from "@/components/app/modals/add-edit-link-modal";export default function LinkCard({_key: key,diff --git a/components/home/logos.tsx b/app/ui/home/logos.tsxsimilarity index 94%rename from components/home/logos.tsxrename to app/ui/home/logos.tsxindex 99be6d9427..9ac1ed0096 100644--- a/components/home/logos.tsx+++ b/app/ui/home/logos.tsx@@ -1,6 +1,6 @@import Link from "next/link";-import BlurImage from "../shared/blur-image";-import { ExpandingArrow } from "../shared/icons";+import BlurImage from "#/ui/blur-image";+import { ExpandingArrow } from "#/ui/icons";const logos = [{diff --git a/components/home/oss.tsx b/app/ui/home/oss.tsxsimilarity index 65%rename from components/home/oss.tsxrename to app/ui/home/oss.tsxindex 6a43aa74c8..b828b8977b 100644--- a/components/home/oss.tsx+++ b/app/ui/home/oss.tsx@@ -1,9 +1,25 @@-import { Github, UploadCloud } from "@/components/shared/icons";-import CountingNumbers from "../shared/counting-numbers";-import MaxWidthWrapper from "../shared/max-width-wrapper";+import { Github } from "@/components/shared/icons";+import CountingNumbers from "../../../components/shared/counting-numbers";+import MaxWidthWrapper from "../../../components/shared/max-width-wrapper";import styles from "./features.module.css";-export default function OSS({ stars }: { stars: number }) {+export default async function OSS() {+ const { stargazers_count: stars } = await fetch(+ "https://api.github.com/repos/steven-tey/dub",+ {+ // optional – feel free to remove if you don't want to display star count+ ...(process.env.GITHUB_OAUTH_TOKEN && {+ headers: {+ Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,+ "Content-Type": "application/json",+ },+ }),+ next: {+ revalidate: 60,+ },+ },+ ).then((res) => res.json());+return (<MaxWidthWrapper className="mb-20 py-20"><div className="mx-auto max-w-md text-center sm:max-w-xl">diff --git a/components/home/placeholder-card.tsx b/app/ui/home/placeholder-card.tsxsimilarity index 100%rename from components/home/placeholder-card.tsxrename to app/ui/home/placeholder-card.tsxdiff --git a/components/home/pricing.tsx b/app/ui/home/pricing.tsxsimilarity index 98%rename from components/home/pricing.tsxrename to app/ui/home/pricing.tsxindex 1469d641ef..2e0dd676e4 100644--- a/components/home/pricing.tsx+++ b/app/ui/home/pricing.tsx@@ -5,17 +5,17 @@ import { useMemo, useState } from "react";import Confetti from "react-dom-confetti";import {CheckCircleFill,- LoadingDots,QuestionCircle,XCircleFill,} from "@/components/shared/icons";+import { LoadingDots } from "#/ui/icons";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";-import Switch from "@/components/shared/switch";-import Tooltip from "@/components/shared/tooltip";+import Switch from "#/ui/switch";+import Tooltip from "#/ui/tooltip";import { getStripe } from "@/lib/stripe/client";import { PLANS } from "@/lib/stripe/constants";import { capitalize, nFormatter } from "@/lib/utils";-import useProject from "@/lib/swr/use-project";+import useProject from "#/lib/hooks/use-project";const pricingItems = [{diff --git a/components/home/testimonials.tsx b/app/ui/home/testimonials.tsxsimilarity index 83%rename from components/home/testimonials.tsxrename to app/ui/home/testimonials.tsxindex 2ade04ae34..affc53a0ea 100644--- a/components/home/testimonials.tsx+++ b/app/ui/home/testimonials.tsx@@ -1,14 +1,13 @@+import prisma from "@/lib/prisma";import { nFormatter } from "@/lib/utils";+import getTweetsMetadata, { homepageTweets } from "@/lib/twitter";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import Tweet from "@/components/shared/tweet";-export default function Testimonials({- userCount,- tweets,-}: {- userCount: number;- tweets: any[];-}) {+export default async function Testimonials() {+ const userCount = process.env.DATABASE_URL ? await prisma.user.count() : 5000;+ const tweets = await getTweetsMetadata(homepageTweets);+return (<MaxWidthWrapper className="pt-20"><div className="mx-auto max-w-md text-center sm:max-w-xl">diff --git a/components/shared/icons/expanding-arrow.tsx b/app/ui/icons/expanding-arrow.tsxsimilarity index 100%rename from components/shared/icons/expanding-arrow.tsxrename to app/ui/icons/expanding-arrow.tsxdiff --git a/app/ui/icons/index.tsx b/app/ui/icons/index.tsxnew file mode 100644index 0000000000..4d65d29b22--- /dev/null+++ b/app/ui/icons/index.tsx@@ -0,0 +1,4 @@+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";diff --git a/components/shared/icons/loading-circle.tsx b/app/ui/icons/loading-circle.tsxsimilarity index 100%rename from components/shared/icons/loading-circle.tsxrename to app/ui/icons/loading-circle.tsxdiff --git a/components/shared/icons/loading-dots.module.css b/app/ui/icons/loading-dots.module.csssimilarity index 100%rename from components/shared/icons/loading-dots.module.cssrename to app/ui/icons/loading-dots.module.cssdiff --git a/components/shared/icons/loading-dots.tsx b/app/ui/icons/loading-dots.tsxsimilarity index 100%rename from components/shared/icons/loading-dots.tsxrename to app/ui/icons/loading-dots.tsxdiff --git a/components/shared/icons/loading-spinner.module.css b/app/ui/icons/loading-spinner.module.csssimilarity index 100%rename from components/shared/icons/loading-spinner.module.cssrename to app/ui/icons/loading-spinner.module.cssdiff --git a/components/shared/icons/loading-spinner.tsx b/app/ui/icons/loading-spinner.tsxsimilarity index 100%rename from components/shared/icons/loading-spinner.tsxrename to app/ui/icons/loading-spinner.tsxdiff --git a/app/ui/modal.tsx b/app/ui/modal.tsxnew file mode 100644index 0000000000..f5e03f8052--- /dev/null+++ b/app/ui/modal.tsx@@ -0,0 +1,137 @@+"use client";++import {+ Dispatch,+ SetStateAction,+ useCallback,+ useEffect,+ useRef,+} from "react";+import FocusTrap from "focus-trap-react";+import { AnimatePresence, motion, useAnimation } from "framer-motion";+import { useParams, useRouter } from "next/navigation";++export default function Modal({+ children,+ showModal,+ setShowModal,+ bgColor = "bg-white",+ closeWithX,+ mobileOnly,+}: {+ children: React.ReactNode;+ showModal: boolean;+ setShowModal: Dispatch<SetStateAction<boolean>>;+ bgColor?: string;+ closeWithX?: boolean;+ mobileOnly?: boolean;+}) {+ const router = useRouter();+ const { key } = useParams() as { key?: string };+ const mobileModalRef = useRef<HTMLDivElement | null>(null);+ const desktopModalRef = useRef<HTMLDivElement | null>(null);++ const closeModal = useCallback(+ (closeWithX?: boolean) => {+ if (closeWithX) {+ return;+ } else if (key) {+ router.push("/");+ } else {+ setShowModal(false);+ }+ },+ [key, router, setShowModal],+ );++ const onKeyDown = useCallback((e: KeyboardEvent) => {+ if (e.key === "Escape" && !closeWithX) {+ setShowModal(false);+ }+ }, []);++ useEffect(() => {+ document.addEventListener("keydown", onKeyDown);+ return () => document.removeEventListener("keydown", onKeyDown);+ }, [onKeyDown]);++ const controls = useAnimation();+ const transitionProps = { type: "spring", stiffness: 500, damping: 30 };+ useEffect(() => {+ controls.start({+ y: 0,+ transition: transitionProps,+ });+ }, []);++ async function handleDragEnd(_, info) {+ const offset = info.offset.y;+ const velocity = info.velocity.y;+ const height = mobileModalRef.current?.getBoundingClientRect().height || 0;+ if (offset > height / 2 || velocity > 800) {+ await controls.start({ y: "100%", transition: transitionProps });+ closeModal();+ } else {+ controls.start({ y: 0, transition: transitionProps });+ }+ }++ return (+ <AnimatePresence>+ {showModal && (+ <FocusTrap focusTrapOptions={{ initialFocus: false }}>+ <div className="absolute">+ <motion.div+ ref={mobileModalRef}+ key="mobile-modal"+ className="group fixed inset-x-0 bottom-0 z-40 w-screen cursor-grab active:cursor-grabbing sm:hidden"+ initial={{ y: "100%" }}+ animate={controls}+ exit={{ y: "100%" }}+ transition={transitionProps}+ drag="y"+ dragDirectionLock+ onDragEnd={handleDragEnd}+ dragElastic={{ top: 0, bottom: 1 }}+ dragConstraints={{ top: 0, bottom: 0 }}+ >+ <div+ className={`h-7 ${bgColor} rounded-t-4xl -mb-1 flex 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>+ {!mobileOnly && (+ <motion.div+ ref={desktopModalRef}+ key="desktop-modal"+ className="fixed inset-0 z-40 hidden min-h-screen items-center justify-center sm:flex"+ initial={{ scale: 0.95 }}+ animate={{ scale: 1 }}+ exit={{ scale: 0.95 }}+ onMouseDown={(e) => {+ if (desktopModalRef.current === e.target) {+ closeModal(closeWithX);+ }+ }}+ >+ {children}+ </motion.div>+ )}+ <motion.div+ id="modal-backdrop"+ key="backdrop"+ className="fixed inset-0 z-30 bg-gray-100 bg-opacity-10 backdrop-blur"+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ onClick={() => closeModal(closeWithX)}+ />+ </div>+ </FocusTrap>+ )}+ </AnimatePresence>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/android-section.tsx b/app/ui/modals/add-edit-link-modal/android-section.tsxnew file mode 100644index 0000000000..1732cd764f--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/android-section.tsx@@ -0,0 +1,58 @@+import { Dispatch, SetStateAction, useEffect, useState } from "react";+import { LinkProps } from "@/lib/types";+import Switch from "#/ui/switch";+import { motion } from "framer-motion";+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";++export default function AndroidSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { android } = data;+ const [enabled, setEnabled] = useState(!!android);+ useEffect(() => {+ if (enabled) {+ // if enabling, add previous android link if exists+ setData({+ ...data,+ android: props?.android || android,+ });+ } else {+ // if disabling, remove android link+ setData({ ...data, android: null });+ }+ }, [enabled]);++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">Android Targeting</h2>+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} />+ </div>+ {enabled && (+ <motion.div+ className="mt-3 flex rounded-md shadow-sm"+ {...FADE_IN_ANIMATION_SETTINGS}+ >+ <input+ name="android-url"+ id="android-url"+ type="url"+ placeholder="https://play.google.com/store/apps/details?id=com.disney.disneyplus"+ value={android || ""}+ onChange={(e) => {+ setData({ ...data, android: e.target.value });+ }}+ className="block w-full rounded-md border-gray-300 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"+ aria-invalid="true"+ />+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/expiration-section.tsx b/app/ui/modals/add-edit-link-modal/expiration-section.tsxnew file mode 100644index 0000000000..a990643158--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/expiration-section.tsx@@ -0,0 +1,55 @@+import { Dispatch, SetStateAction, useEffect, useState } from "react";+import { LinkProps } from "@/lib/types";+import { getDateTimeLocal } from "@/lib/utils";+import Switch from "#/ui/switch";+import { motion } from "framer-motion";++export default function ExpirationSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { expiresAt } = data;+ const [enabled, setEnabled] = useState(!!expiresAt);+ useEffect(() => {+ if (enabled) {+ // if enabling, add previous expiration date if exists+ setData({+ ...data,+ expiresAt: props?.expiresAt || expiresAt,+ });+ } else {+ // if disabling, remove expiration date+ setData({ ...data, expiresAt: null });+ }+ }, [enabled]);++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">Expiration Date</h2>+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} />+ </div>+ {enabled && (+ <motion.div className="mt-3">+ <input+ type="datetime-local"+ id="expiresAt"+ name="expiresAt"+ min={getDateTimeLocal()}+ value={expiresAt ? getDateTimeLocal(expiresAt) : ""}+ step="60" // need to add step to prevent weird date bug (https://stackoverflow.com/q/19284193/10639526)+ onChange={(e) => {+ setData({ ...data, expiresAt: new Date(e.target.value) });+ }}+ className="flex w-full items-center justify-center space-x-2 rounded-md border border-gray-300 px-3 py-2 text-sm text-gray-500 shadow-sm transition-all hover:border-gray-800 focus:border-gray-800 focus:outline-none focus:ring-gray-500"+ />+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/index.tsx b/app/ui/modals/add-edit-link-modal/index.tsxnew file mode 100644index 0000000000..1b9f1a5503--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/index.tsx@@ -0,0 +1,679 @@+"use client";++import {+ useParams,+ usePathname,+ useRouter,+ useSearchParams,+} from "next/navigation";+import {+ Dispatch,+ SetStateAction,+ UIEvent,+ useCallback,+ useEffect,+ useMemo,+ useState,+} from "react";+import { mutate } from "swr";+import { useDebounce } from "use-debounce";+import BlurImage from "#/ui/blur-image";+import { AlertCircleFill, Lock, Random, X } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";+import Modal from "#/ui/modal";+import Tooltip, { TooltipContent } from "#/ui/tooltip";+import useProject from "#/lib/hooks/use-project";+import { LinkProps } from "@/lib/types";+import {+ getApexDomain,+ getUrlWithoutUTMParams,+ linkConstructor,+ truncate,+} from "@/lib/utils";+import ExpirationSection from "./expiration-section";+import OGSection from "./og-section";+import PasswordSection from "./password-section";+import UTMSection from "./utm-section";+import IOSSection from "./ios-section";+import Preview from "./preview";+import AndroidSection from "./android-section";+import { DEFAULT_LINK_PROPS, GOOGLE_FAVICON_URL } from "@/lib/constants";+import useDomains from "#/lib/hooks/use-domains";+import { toast } from "react-hot-toast";+import va from "@vercel/analytics";+import punycode from "punycode/";+import Button from "#/ui/button";++function AddEditLinkModal({+ showAddEditLinkModal,+ setShowAddEditLinkModal,+ props,+ duplicateProps,+ hideXButton,+ homepageDemo,+}: {+ showAddEditLinkModal: boolean;+ setShowAddEditLinkModal: Dispatch<SetStateAction<boolean>>;+ props?: LinkProps;+ duplicateProps?: LinkProps;+ hideXButton?: boolean;+ homepageDemo?: boolean;+}) {+ const { slug } = useParams() as { slug?: string };+ const searchParams = useSearchParams();+ const router = useRouter();+ const pathname = usePathname();++ const [keyExistsError, setKeyExistsError] = useState(false);+ const [urlError, setUrlError] = useState(false);+ const [generatingKey, setGeneratingKey] = useState(false);+ const [saving, setSaving] = useState(false);++ const { domains, primaryDomain } = useDomains();++ const [data, setData] = useState<LinkProps>(+ props ||+ duplicateProps || {+ ...DEFAULT_LINK_PROPS,+ domain: primaryDomain || "",+ key: "",+ url: "",+ },+ );++ const { domain, key, url, password, proxy } = data;++ const [debouncedKey] = useDebounce(key, 500);+ useEffect(() => {+ /**+ * Only check if key exists if:+ * - modal is open+ * - key is not empty+ * - key is not the same as the original key+ **/+ if (+ showAddEditLinkModal &&+ debouncedKey.length > 0 &&+ debouncedKey !== props?.key+ ) {+ fetch(+ slug+ ? `/api/projects/${slug}/links/${debouncedKey}/exists?domain=${domain}`+ : `/api/links/${debouncedKey}/exists`,+ ).then(async (res) => {+ if (res.status === 200) {+ const exists = await res.json();+ setKeyExistsError(exists);+ }+ });+ }+ }, [debouncedKey, domain]);++ const generateRandomKey = useCallback(async () => {+ setGeneratingKey(true);+ const res = await fetch(+ slug+ ? `/api/projects/${slug}/links/random?domain=${domain}`+ : `/api/links/random`,+ );+ const key = await res.json();+ setData((prev) => ({ ...prev, key }));+ setGeneratingKey(false);+ }, []);++ const [generatingMetatags, setGeneratingMetatags] = useState(+ props ? true : false,+ );+ const [debouncedUrl] = useDebounce(getUrlWithoutUTMParams(url), 500);+ useEffect(() => {+ // if there's a password, no need to generate metatags+ if (password) {+ setData((prev) => ({+ ...prev,+ title: "Password Required",+ description:+ "This link is password protected. Please enter the password to view it.",+ image: "/_static/password-protected.png",+ }));+ return;+ }+ /**+ * Only generate metatags if:+ * - modal is open+ * - custom OG proxy is not enabled+ **/+ if (showAddEditLinkModal && !proxy) {+ setData((prev) => ({+ ...prev,+ title: null,+ description: null,+ image: null,+ }));+ try {+ // if url is valid, continue to generate metatags, else return null+ new URL(debouncedUrl);+ setGeneratingMetatags(true);+ fetch(`/api/edge/metatags?url=${debouncedUrl}`).then(async (res) => {+ if (res.status === 200) {+ const results = await res.json();+ setData((prev) => ({+ ...prev,+ ...{+ title: truncate(results.title, 120),+ description: truncate(results.description, 240),+ image: results.image,+ },+ }));+ }+ // set timeout to prevent flickering+ setTimeout(() => setGeneratingMetatags(false), 200);+ });+ } catch (e) {+ console.log("not a valid url");+ }+ } else {+ setGeneratingMetatags(false);+ }+ }, [debouncedUrl, password, showAddEditLinkModal, proxy]);++ const logo = useMemo(() => {+ // if the link is password protected, or if it's a new link and there's no URL yet,+ // return the default Dub logo+ if (password || (!debouncedUrl && !props)) {+ return "/_static/logo.png";+ // otherwise, get the favicon of the URL+ } else {+ return `${GOOGLE_FAVICON_URL}${getApexDomain(+ debouncedUrl || props?.url || "https://dub.sh",+ )}`;+ }+ }, [password, debouncedUrl, props]);++ const endpoint = useMemo(() => {+ if (props?.key) {+ return {+ method: "PUT",+ url: slug+ ? `/api/projects/${slug}/links/${props.key}?domain=${domain}`+ : `/api/links/${props.key}`,+ };+ } else {+ return {+ method: "POST",+ url: slug+ ? `/api/projects/${slug}/links?domain=${domain}`+ : `/api/links`,+ };+ }+ }, [props]);++ const [atBottom, setAtBottom] = useState(false);+ const handleScroll = useCallback((event: UIEvent<HTMLDivElement>) => {+ const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;+ if (Math.abs(scrollHeight - scrollTop - clientHeight) < 5) {+ setAtBottom(true);+ } else {+ setAtBottom(false);+ }+ }, []);++ const saveDisabled = useMemo(() => {+ /*+ Disable save if:+ - modal is not open+ - saving is in progress+ - key is invalid+ - url is invalid+ - metatags is being generated+ - for an existing link, there's no changes+ */+ if (+ !showAddEditLinkModal ||+ saving ||+ keyExistsError ||+ urlError ||+ (props &&+ Object.entries(props).every(([key, value]) => {+ // If the key is "title" or "description" and proxy is not enabled, return true (skip the check)+ if (+ (key === "title" || key === "description" || key === "image") &&+ !proxy+ ) {+ return true;+ }+ // Otherwise, check for discrepancy in the current key-value pair+ return data[key] === value;+ }))+ ) {+ return true;+ } else {+ return false;+ }+ }, [showAddEditLinkModal, saving, keyExistsError, urlError, props, data]);++ const randomIdx = Math.floor(Math.random() * 100);++ const [lockKey, setLockKey] = useState(true);++ return (+ <Modal+ showModal={showAddEditLinkModal}+ setShowModal={setShowAddEditLinkModal}+ closeWithX={homepageDemo ? false : true}+ >+ <div className="relative grid max-h-[min(906px,_90vh)] w-full divide-x divide-gray-100 overflow-scroll bg-white shadow-xl transition-all scrollbar-hide sm:max-w-screen-lg sm:grid-cols-2 sm:rounded-2xl sm:border sm:border-gray-200">+ {!hideXButton && !homepageDemo && (+ <button+ onClick={() => setShowAddEditLinkModal(false)}+ className="group absolute right-0 top-0 z-20 m-3 hidden rounded-full p-2 text-gray-500 transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200 sm:block"+ >+ <X className="h-5 w-5" />+ </button>+ )}++ <div+ className="rounded-l-2xl sm:max-h-[min(906px,_90vh)] sm:overflow-scroll"+ onScroll={handleScroll}+ >+ <div className="z-10 flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 pb-8 pt-8 transition-all sm:sticky sm:top-0 sm:px-16">+ <BlurImage+ src={logo}+ alt="Logo"+ className="h-10 w-10 rounded-full"+ width={20}+ height={20}+ />+ <h3 className="text-lg font-medium">+ {props+ ? `Edit ${linkConstructor({+ key: props.key,+ domain: punycode.toUnicode(props.domain || ""),+ pretty: true,+ })}`+ : "Create a new link"}+ </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((res) => {+ setSaving(false);+ if (res.status === 200) {+ // track link creation event+ endpoint.method === "POST" &&+ va.track("Created Link", {+ type: slug ? "Custom Domain" : "Default Domain",+ });+ mutate(+ slug+ ? `/api/projects/${slug}/links${+ searchParams ? `?${searchParams.toString()}` : ""+ }`+ : `/api/links${+ searchParams ? `?${searchParams.toString()}` : ""+ }`,+ );+ mutate(+ (key) =>+ typeof key === "string" &&+ key.startsWith(+ slug+ ? `/api/projects/${slug}/links/count`+ : `/api/links/count`,+ ),+ undefined,+ { revalidate: true },+ );+ // for welcome page, redirect to links page after adding a link+ if (pathname === "/welcome") {+ router.push("/links");+ setShowAddEditLinkModal(false);+ } else {+ // copy shortlink to clipboard when adding a new link+ if (!props) {+ navigator.clipboard+ .writeText(+ linkConstructor({+ key: data.key,+ domain,+ }),+ )+ .then(() => {+ toast.success("Copied shortlink to clipboard");+ });+ }+ setShowAddEditLinkModal(false);+ }+ } else if (res.status === 403) {+ setKeyExistsError(true);+ } else if (res.status === 400) {+ setUrlError(true);+ } else {+ alert("Something went wrong");+ }+ });+ }}+ className="grid gap-6 bg-gray-50 pt-8"+ >+ <div className="grid gap-6 px-4 sm:px-16">+ <div>+ <div className="flex items-center justify-between">+ <label+ htmlFor={`url-${randomIdx}`}+ className="block text-sm font-medium text-gray-700"+ >+ Destination URL+ </label>+ {urlError && (+ <p className="text-sm text-red-600" id="key-error">+ Invalid url.+ </p>+ )}+ </div>+ <div className="relative mt-1 flex rounded-md shadow-sm">+ <input+ name="url"+ id={`url-${randomIdx}`}+ type="url"+ required+ placeholder="https://github.com/steven-tey/dub"+ value={url}+ onChange={(e) => {+ setUrlError(false);+ setData({ ...data, url: e.target.value });+ }}+ className={`${+ urlError+ ? "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 text-sm focus:outline-none`}+ aria-invalid="true"+ />+ {urlError && (+ <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>+ <div>+ <div className="flex items-center justify-between">+ <label+ htmlFor={`key-${randomIdx}`}+ className="block text-sm font-medium text-gray-700"+ >+ Short Link+ </label>+ {props && lockKey ? (+ <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(+ "Editing an existing short link will result in broken links and reset its analytics. Are you sure you want to continue?",+ ) && setLockKey(false);+ }}+ >+ <Lock className="h-3 w-3" />+ <p>Unlock</p>+ </button>+ ) : (+ <button+ className="flex items-center space-x-2 text-sm text-gray-500 transition-all duration-75 hover:text-black active:scale-95"+ onClick={generateRandomKey}+ disabled={generatingKey}+ type="button"+ >+ {generatingKey ? (+ <LoadingCircle />+ ) : (+ <Random className="h-3 w-3" />+ )}+ <p>{generatingKey ? "Generating" : "Randomize"}</p>+ </button>+ )}+ </div>+ <div className="relative mt-1 flex rounded-md shadow-sm">+ <select+ disabled={props && lockKey}+ value={domain}+ onChange={(e) => {+ setData({ ...data, domain: e.target.value });+ }}+ className={`${+ props && lockKey ? "cursor-not-allowed" : ""+ } w-40 rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-5 text-sm text-gray-500 focus:border-gray-300 focus:outline-none focus:ring-0`}+ >+ {domains?.map(({ slug }) => (+ <option key={slug} value={slug}>+ {punycode.toUnicode(slug || "")}+ </option>+ ))}+ </select>+ {props && lockKey ? (+ <div className="block w-full cursor-not-allowed select-none rounded-r-md border border-gray-300 bg-gray-100 px-3 py-2 text-sm text-gray-500">+ {props.key}+ </div>+ ) : (+ <input+ type="text"+ name="key"+ id={`key-${randomIdx}`}+ required+ pattern="[\p{Letter}\p{Mark}\d-]+" // Unicode regex to match characters from all languages and numbers (and omit all symbols except for dashes)+ className={`${+ keyExistsError+ ? "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-r-md pr-10 text-sm focus:outline-none`}+ placeholder="github"+ value={key}+ onChange={(e) => {+ setKeyExistsError(false);+ setData({ ...data, key: e.target.value });+ }}+ aria-invalid="true"+ aria-describedby="key-error"+ />+ )}+ {keyExistsError && (+ <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>+ {keyExistsError && (+ <p className="mt-2 text-sm text-red-600" id="key-error">+ Short link is already in use.+ </p>+ )}+ </div>+ </div>++ {/* Divider */}+ <div className="relative py-5">+ <div+ className="absolute inset-0 flex items-center px-4 sm:px-16"+ aria-hidden="true"+ >+ <div className="w-full border-t border-gray-300" />+ </div>+ <div className="relative flex justify-center">+ <span className="bg-gray-50 px-2 text-sm text-gray-500">+ Optional+ </span>+ </div>+ </div>++ <div className="grid gap-5 px-4 sm:px-16">+ <OGSection+ {...{ props, data, setData }}+ generatingMetatags={generatingMetatags}+ />+ <UTMSection {...{ props, data, setData }} />+ <PasswordSection {...{ props, data, setData }} />+ <ExpirationSection {...{ props, data, setData }} />+ <IOSSection {...{ props, data, setData }} />+ <AndroidSection {...{ props, data, setData }} />+ </div>++ <div+ className={`${+ atBottom ? "" : "sm:shadow-[0_-20px_30px_-10px_rgba(0,0,0,0.1)]"+ } z-10 bg-gray-50 px-4 py-8 transition-all sm:sticky sm:bottom-0 sm:px-16`}+ >+ {homepageDemo ? (+ <Button+ disabledTooltip="This is a demo link. You can't edit it."+ text="Save changes"+ />+ ) : (+ <Button+ disabled={saveDisabled}+ loading={saving}+ text={props ? "Save changes" : "Create link"}+ />+ )}+ </div>+ </form>+ </div>+ <div className="rounded-r-2xl sm:max-h-[min(906px,_90vh)] sm:overflow-scroll">+ <Preview data={data} generatingMetatags={generatingMetatags} />+ </div>+ </div>+ </Modal>+ );+}++function AddEditLinkButton({+ setShowAddEditLinkModal,+}: {+ setShowAddEditLinkModal: Dispatch<SetStateAction<boolean>>;+}) {+ const { slug } = useParams() as { slug?: string };++ const { exceededUsage } = useProject();++ const onKeyDown = useCallback((e: KeyboardEvent) => {+ const target = e.target as HTMLElement;+ const existingModalBackdrop = document.getElementById("modal-backdrop");+ // only open modal with keyboard shortcut if:+ // - c is pressed+ // - user is not pressing cmd/ctrl + c+ // - user is not typing in an input or textarea+ // - there is no existing modal backdrop (i.e. no other modal is open)+ if (+ e.key === "c" &&+ !e.metaKey &&+ !e.ctrlKey &&+ target.tagName !== "INPUT" &&+ target.tagName !== "TEXTAREA" &&+ !existingModalBackdrop+ ) {+ setShowAddEditLinkModal(true);+ }+ }, []);++ useEffect(() => {+ document.addEventListener("keydown", onKeyDown);+ return () => document.removeEventListener("keydown", onKeyDown);+ }, [onKeyDown]);++ return slug && exceededUsage ? ( // only show exceeded usage tooltip if user is on a project page+ <Tooltip+ content={+ <TooltipContent+ title="Your project has exceeded its usage limit. We're still collecting data on your existing links, but you need to upgrade to add more links."+ cta="Upgrade"+ ctaLink={`/${slug}/settings/billing`}+ />+ }+ >+ <div className="flex cursor-not-allowed items-center space-x-3 rounded-md border border-gray-200 px-3 py-2 text-sm font-medium text-gray-300">+ <p>Create link</p>+ <kbd className="hidden rounded bg-gray-100 px-2 py-0.5 text-xs font-light text-gray-300 sm:inline-block">+ C+ </kbd>+ </div>+ </Tooltip>+ ) : (+ <button+ onClick={() => setShowAddEditLinkModal(true)}+ className="group flex items-center space-x-3 rounded-md border border-black bg-black px-3 py-2 text-sm font-medium text-white transition-all duration-75 hover:bg-white hover:text-black active:scale-95"+ >+ <p>Create link</p>+ <kbd className="hidden rounded bg-zinc-700 px-2 py-0.5 text-xs font-light text-gray-400 transition-all duration-75 group-hover:bg-gray-100 group-hover:text-gray-500 sm:inline-block">+ C+ </kbd>+ </button>+ );+}++export function useAddEditLinkModal({+ props,+ duplicateProps,+ hideXButton,+ homepageDemo,+}: {+ props?: LinkProps;+ duplicateProps?: LinkProps;+ hideXButton?: boolean;+ homepageDemo?: boolean;+} = {}) {+ const [showAddEditLinkModal, setShowAddEditLinkModal] = useState(false);++ const AddEditLinkModalCallback = useCallback(() => {+ return (+ <AddEditLinkModal+ showAddEditLinkModal={showAddEditLinkModal}+ setShowAddEditLinkModal={setShowAddEditLinkModal}+ props={props}+ duplicateProps={duplicateProps}+ hideXButton={hideXButton}+ homepageDemo={homepageDemo}+ />+ );+ }, [+ showAddEditLinkModal,+ setShowAddEditLinkModal,+ props,+ duplicateProps,+ hideXButton,+ homepageDemo,+ ]);++ const AddEditLinkButtonCallback = useCallback(() => {+ return (+ <AddEditLinkButton setShowAddEditLinkModal={setShowAddEditLinkModal} />+ );+ }, [setShowAddEditLinkModal]);++ return useMemo(+ () => ({+ showAddEditLinkModal,+ setShowAddEditLinkModal,+ AddEditLinkModal: AddEditLinkModalCallback,+ AddEditLinkButton: AddEditLinkButtonCallback,+ }),+ [+ showAddEditLinkModal,+ setShowAddEditLinkModal,+ AddEditLinkModalCallback,+ AddEditLinkButtonCallback,+ ],+ );+}diff --git a/app/ui/modals/add-edit-link-modal/ios-section.tsx b/app/ui/modals/add-edit-link-modal/ios-section.tsxnew file mode 100644index 0000000000..102fe06898--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/ios-section.tsx@@ -0,0 +1,58 @@+import { Dispatch, SetStateAction, useEffect, useState } from "react";+import { LinkProps } from "@/lib/types";+import Switch from "#/ui/switch";+import { motion } from "framer-motion";+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";++export default function IOSSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { ios } = data;+ const [enabled, setEnabled] = useState(!!ios);+ useEffect(() => {+ if (enabled) {+ // if enabling, add previous ios link if exists+ setData({+ ...data,+ ios: props?.ios || ios,+ });+ } else {+ // if disabling, remove ios link+ setData({ ...data, ios: null });+ }+ }, [enabled]);++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">iOS Targeting</h2>+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} />+ </div>+ {enabled && (+ <motion.div+ className="mt-3 flex rounded-md shadow-sm"+ {...FADE_IN_ANIMATION_SETTINGS}+ >+ <input+ name="ios-url"+ id="ios-url"+ type="url"+ placeholder="https://apps.apple.com/app/1611158928"+ value={ios || ""}+ onChange={(e) => {+ setData({ ...data, ios: e.target.value });+ }}+ className="block w-full rounded-md border-gray-300 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"+ aria-invalid="true"+ />+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/og-section.tsx b/app/ui/modals/add-edit-link-modal/og-section.tsxnew file mode 100644index 0000000000..13d1ed7d8c--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/og-section.tsx@@ -0,0 +1,248 @@+import {+ Dispatch,+ SetStateAction,+ useCallback,+ useEffect,+ useState,+} from "react";+import { motion } from "framer-motion";+import TextareaAutosize from "react-textarea-autosize";+import { UploadCloud } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";+import { LinkProps } from "@/lib/types";+import Switch from "#/ui/switch";+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";++export default function OGSection({+ props,+ data,+ setData,+ generatingMetatags,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+ generatingMetatags: boolean;+}) {+ const { title, description, image, proxy } = data;++ const [fileSizeTooBig, setFileSizeTooBig] = useState(false);+ const [dragActive, setDragActive] = useState(false);++ const onChangePicture = useCallback(+ (e) => {+ setFileSizeTooBig(false);+ const file = e.target.files[0];+ if (file) {+ if (file.size / 1024 / 1024 > 1) {+ setFileSizeTooBig(true);+ } else {+ const reader = new FileReader();+ reader.onload = (e) => {+ setData((prev) => ({ ...prev, image: e.target?.result as string }));+ };+ reader.readAsDataURL(file);+ }+ }+ },+ [setData],+ );++ useEffect(() => {+ if (proxy && props) {+ // if custom OG is enabled+ setData((prev) => ({+ ...prev,+ title: props.title || title,+ description: props.description || description,+ image: props.image || image,+ }));+ }+ }, [proxy]);++ const randomIdx = Math.floor(Math.random() * 100);++ return (+ <div className="grid gap-5 border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">+ Custom Social Media Cards+ </h2>+ <Switch+ fn={() => setData((prev) => ({ ...prev, proxy: !proxy }))}+ checked={proxy}+ />+ </div>++ {proxy && (+ <motion.div+ key="og-options"+ {...FADE_IN_ANIMATION_SETTINGS}+ className="grid gap-5"+ >+ <div>+ <div className="flex items-center justify-between">+ <p className="block text-sm font-medium text-gray-700">Image</p>+ {fileSizeTooBig && (+ <p className="text-sm text-red-500">+ File size too big (max 1MB)+ </p>+ )}+ </div>+ <label+ htmlFor={`image-${randomIdx}`}+ className="group relative mt-1 flex h-[14rem] cursor-pointer flex-col items-center justify-center rounded-md border border-gray-300 bg-white shadow-sm transition-all hover:bg-gray-50"+ >+ {generatingMetatags && (+ <div className="absolute z-[5] flex h-full w-full items-center justify-center rounded-md bg-white">+ <LoadingCircle />+ </div>+ )}+ <div+ className="absolute z-[5] h-full w-full rounded-md"+ onDragOver={(e) => {+ e.preventDefault();+ e.stopPropagation();+ setDragActive(true);+ }}+ onDragEnter={(e) => {+ e.preventDefault();+ e.stopPropagation();+ setDragActive(true);+ }}+ onDragLeave={(e) => {+ e.preventDefault();+ e.stopPropagation();+ setDragActive(false);+ }}+ onDrop={(e) => {+ e.preventDefault();+ e.stopPropagation();+ setDragActive(false);+ setFileSizeTooBig(false);+ const file = e.dataTransfer.files && e.dataTransfer.files[0];+ if (file) {+ if (file.size / 1024 / 1024 > 5) {+ setFileSizeTooBig(true);+ } else {+ const reader = new FileReader();+ reader.onload = (e) => {+ setData((prev) => ({+ ...prev,+ image: e.target?.result as string,+ }));+ };+ reader.readAsDataURL(file);+ }+ }+ }}+ />+ <div+ className={`${+ dragActive+ ? "cursor-copy border-2 border-black bg-gray-50 opacity-100"+ : ""+ } absolute z-[3] flex h-full w-full flex-col items-center justify-center rounded-md bg-white transition-all ${+ image+ ? "opacity-0 group-hover:opacity-100"+ : "group-hover:bg-gray-50"+ }`}+ >+ <UploadCloud+ className={`${+ dragActive ? "scale-110" : "scale-100"+ } h-7 w-7 text-gray-500 transition-all duration-75 group-hover:scale-110 group-active:scale-95`}+ />+ <p className="mt-2 text-center text-sm text-gray-500">+ Drag and drop or click to upload.+ </p>+ <p className="mt-2 text-center text-sm text-gray-500">+ Recommended: 1200 x 627 pixels+ </p>+ <span className="sr-only">OG image upload</span>+ </div>+ {image && (+ <img+ src={image}+ alt="Preview"+ className="h-full w-full rounded-md object-cover"+ />+ )}+ </label>+ <div className="mt-1 flex rounded-md shadow-sm">+ <input+ id={`image-${randomIdx}`}+ name="image"+ type="file"+ accept="image/*"+ className="sr-only"+ onChange={onChangePicture}+ />+ </div>+ </div>++ <div>+ <div className="flex items-center justify-between">+ <p className="block text-sm font-medium text-gray-700">Title</p>+ <p className="text-sm text-gray-500">{title?.length || 0}/120</p>+ </div>+ <div className="relative mt-1 flex rounded-md shadow-sm">+ {generatingMetatags && (+ <div className="absolute flex h-full w-full items-center justify-center rounded-md border border-gray-300 bg-white">+ <LoadingCircle />+ </div>+ )}+ <TextareaAutosize+ name="title"+ id={`title-${randomIdx}`}+ minRows={3}+ maxLength={120}+ className="block w-full rounded-md border-gray-300 pr-10 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"+ placeholder="Dub - Open Source Bitly Alternative"+ value={title || ""}+ onChange={(e) => {+ setData({ ...data, title: e.target.value });+ }}+ aria-invalid="true"+ />+ </div>+ </div>++ <div>+ <div className="flex items-center justify-between">+ <p className="block text-sm font-medium text-gray-700">+ Description+ </p>+ <p className="text-sm text-gray-500">+ {description?.length || 0}/240+ </p>+ </div>+ <div className="relative mt-1 flex rounded-md shadow-sm">+ {generatingMetatags && (+ <div className="absolute flex h-full w-full items-center justify-center rounded-md border border-gray-300 bg-white">+ <LoadingCircle />+ </div>+ )}+ <TextareaAutosize+ name="description"+ id={`description-${randomIdx}`}+ minRows={3}+ maxLength={240}+ className="block w-full rounded-md border-gray-300 pr-10 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"+ placeholder="Dub is open-source link management tool for modern marketing teams to create, share, and track short links."+ value={description || ""}+ onChange={(e) => {+ setData({+ ...data,+ description: e.target.value,+ });+ }}+ aria-invalid="true"+ />+ </div>+ </div>+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/password-section.tsx b/app/ui/modals/add-edit-link-modal/password-section.tsxnew file mode 100644index 0000000000..6d38daa2b5--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/password-section.tsx@@ -0,0 +1,74 @@+import { Dispatch, SetStateAction, useEffect, useState } from "react";+import { LinkProps } from "@/lib/types";+import Switch from "#/ui/switch";+import { motion } from "framer-motion";+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";+import { Eye, EyeOff } from "@/components/shared/icons";++export default function PasswordSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { password } = data;+ const [enabled, setEnabled] = useState(!!password);+ useEffect(() => {+ if (enabled) {+ // if enabling, add previous password if exists+ setData({+ ...data,+ password: props?.password || password,+ });+ } else {+ // if disabling, remove password+ setData({ ...data, password: null });+ }+ }, [enabled]);++ const [showPassword, setShowPassword] = useState(false);++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">+ Password Protection+ </h2>+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} />+ </div>+ {enabled && (+ <motion.div+ className="relative mt-3 rounded-md shadow-sm"+ {...FADE_IN_ANIMATION_SETTINGS}+ >+ <input+ name="password"+ id="password"+ type={showPassword ? "text" : "password"}+ className="block w-full rounded-md border-gray-300 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"+ value={password || ""}+ placeholder="Enter password"+ onChange={(e) => {+ setData({ ...data, password: e.target.value });+ }}+ aria-invalid="true"+ />+ <button+ type="button"+ onClick={() => setShowPassword(!showPassword)}+ className="absolute inset-y-0 right-0 flex items-center pr-3"+ >+ {showPassword ? (+ <Eye className="h-4 w-4 text-gray-400" aria-hidden="true" />+ ) : (+ <EyeOff className="h-4 w-4 text-gray-400" aria-hidden="true" />+ )}+ </button>+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/preview.tsx b/app/ui/modals/add-edit-link-modal/preview.tsxnew file mode 100644index 0000000000..b4d3c47549--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/preview.tsx@@ -0,0 +1,196 @@+import BlurImage from "#/ui/blur-image";+import { Facebook, LinkedIn, Photo, Twitter } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";+import { LinkProps } from "@/lib/types";+import { getDomainWithoutWWW } from "@/lib/utils";+import { useMemo } from "react";+import { useDebounce } from "use-debounce";++export default function Preview({+ data,+ generatingMetatags,+}: {+ data: LinkProps;+ generatingMetatags: boolean;+}) {+ const { title, description, image, url, password } = data;+ const [debouncedUrl] = useDebounce(url, 500);+ const hostname = useMemo(() => {+ if (password) return "dub.sh";+ return getDomainWithoutWWW(debouncedUrl);+ }, [password, debouncedUrl]);++ const previewImage = useMemo(() => {+ if (generatingMetatags) {+ return (+ <div className="flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-100">+ <LoadingCircle />+ </div>+ );+ }+ if (image) {+ if (image.startsWith("https://res.cloudinary.com")) {+ return (+ <BlurImage+ src={image}+ alt="Preview"+ width={1200}+ height={627}+ className="h-[250px] w-full border-b border-gray-300 object-cover"+ />+ );+ } else {+ return (+ <img+ src={image}+ alt="Preview"+ className="h-[250px] w-full border-b border-gray-300 object-cover"+ />+ );+ }+ } else {+ return (+ <div className="flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-100">+ <Photo className="h-8 w-8 text-gray-400" />+ <p className="text-sm text-gray-400">+ Enter a link to generate a preview.+ </p>+ </div>+ );+ }+ }, [image, generatingMetatags]);++ return (+ <div>+ <div className="z-10 flex items-center justify-center border-b border-gray-200 bg-white px-5 py-10 sm:sticky sm:top-0">+ <h2 className="text-lg font-medium">Social Previews</h2>+ </div>+ <div className="grid gap-5 p-5">+ {/* Twitter */}+ <div>+ <div className="relative mb-2">+ <div+ className="absolute inset-0 flex items-center"+ aria-hidden="true"+ >+ <div className="w-full border-t border-gray-200" />+ </div>+ <div className="relative flex justify-center">+ <div className="flex items-center space-x-2 bg-white px-3">+ <Twitter className="h-4 w-4 text-[#1DA1F2]" />+ <p className="text-sm text-gray-400">Twitter</p>+ </div>+ </div>+ </div>+ <div className="overflow-hidden rounded-md border border-gray-300">+ {previewImage}+ <div className="grid gap-1 p-3">+ {hostname ? (+ <p className="text-sm text-[#536471]">{hostname}</p>+ ) : (+ <div className="mb-1 h-4 w-24 rounded-md bg-gray-100" />+ )}+ {title ? (+ <h3 className="truncate text-sm text-[#0f1419]">{title}</h3>+ ) : (+ <div className="mb-1 h-4 w-full rounded-md bg-gray-100" />+ )}+ {description ? (+ <p className="line-clamp-2 text-sm text-[#536471]">+ {description}+ </p>+ ) : (+ <div className="grid gap-2">+ <div className="h-4 w-full rounded-md bg-gray-100" />+ <div className="h-4 w-48 rounded-md bg-gray-100" />+ </div>+ )}+ </div>+ </div>+ </div>++ {/* Facebook */}+ <div>+ <div className="relative mb-2">+ <div+ className="absolute inset-0 flex items-center"+ aria-hidden="true"+ >+ <div className="w-full border-t border-gray-200" />+ </div>+ <div className="relative flex justify-center">+ <div className="flex items-center space-x-2 bg-white px-3">+ <Facebook className="h-4 w-4" />+ <p className="text-sm text-gray-400">Facebook</p>+ </div>+ </div>+ </div>+ <div className="border border-gray-300">+ {previewImage}+ <div className="grid gap-1 bg-[#f2f3f5] p-3">+ {hostname ? (+ <p className="text-[0.8rem] uppercase text-[#606770]">+ {hostname}+ </p>+ ) : (+ <div className="mb-1 h-4 w-24 rounded-md bg-gray-200" />+ )}+ {title ? (+ <h3 className="truncate font-semibold text-[#1d2129]">+ {title}+ </h3>+ ) : (+ <div className="mb-1 h-5 w-full rounded-md bg-gray-200" />+ )}+ {description ? (+ <p className="line-clamp-2 text-sm text-[#606770]">+ {description}+ </p>+ ) : (+ <div className="grid gap-2">+ <div className="h-4 w-full rounded-md bg-gray-200" />+ <div className="h-4 w-48 rounded-md bg-gray-200" />+ </div>+ )}+ </div>+ </div>+ </div>++ {/* LinkedIn */}+ <div>+ <div className="relative mb-2">+ <div+ className="absolute inset-0 flex items-center"+ aria-hidden="true"+ >+ <div className="w-full border-t border-gray-200" />+ </div>+ <div className="relative flex justify-center">+ <div className="flex items-center space-x-2 bg-white px-3">+ <LinkedIn className="h-4 w-4" />+ <p className="text-sm text-gray-400">LinkedIn</p>+ </div>+ </div>+ </div>+ <div className="overflow-hidden rounded-[2px] shadow-[0_0_0_1px_rgba(0,0,0,0.15),0_2px_3px_rgba(0,0,0,0.2)]">+ {previewImage}+ <div className="grid gap-1 bg-white p-3">+ {title ? (+ <h3 className="truncate font-semibold text-[#000000E6]">+ {title}+ </h3>+ ) : (+ <div className="mb-1 h-5 w-full rounded-md bg-gray-200" />+ )}+ {hostname ? (+ <p className="text-xs text-[#00000099]">{hostname}</p>+ ) : (+ <div className="mb-1 h-4 w-24 rounded-md bg-gray-200" />+ )}+ </div>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/app/ui/modals/add-edit-link-modal/utm-section.tsx b/app/ui/modals/add-edit-link-modal/utm-section.tsxnew file mode 100644index 0000000000..c4c9f889ee--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/utm-section.tsx@@ -0,0 +1,96 @@+import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";+import { LinkProps } from "@/lib/types";+import { motion } from "framer-motion";+import {+ constructURLFromUTMParams,+ getParamsFromURL,+ paramsMetadata,+ getUrlWithoutUTMParams,+} from "@/lib/utils";+import Switch from "#/ui/switch";+import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";++export default function UTMSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { url } = data;+ const isValidUrl = useMemo(() => {+ try {+ new URL(url);+ return true;+ } catch (e) {+ return false;+ }+ }, [url]);++ const params = useMemo(() => {+ return getParamsFromURL(url);+ }, [url]);++ const [enabled, setEnabled] = useState(+ paramsMetadata.some((param) => params[param.key]),+ );++ useEffect(() => {+ if (enabled) {+ // if enabling, add all params from props if exists && it's still the same URL+ setData({+ ...data,+ url:+ props?.url &&+ getUrlWithoutUTMParams(props?.url) === getUrlWithoutUTMParams(url)+ ? props?.url+ : url,+ });+ } else {+ // if disabling, remove all UTM params+ setData({ ...data, url: getUrlWithoutUTMParams(url) });+ }+ }, [enabled]);++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <h2 className="text-sm font-medium text-gray-900">UTM Builder</h2>+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} />+ </div>+ {enabled && (+ <motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}>+ {paramsMetadata.map(({ display, key, examples }) => (+ <div key={key} className="relative mt-1 flex rounded-md shadow-sm">+ <span className="flex w-60 items-center justify-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-sm text-gray-500">+ {display}+ </span>+ <input+ type="text"+ name={key}+ id={key}+ disabled={!isValidUrl}+ className={`${+ isValidUrl ? "" : "cursor-not-allowed bg-gray-100"+ } block w-full rounded-r-md border-gray-300 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500`}+ placeholder={examples}+ value={params[key] || ""}+ onChange={(e) => {+ setData({+ ...data,+ url: constructURLFromUTMParams(url, {+ ...params,+ [key]: e.target.value,+ }),+ });+ }}+ />+ </div>+ ))}+ </motion.div>+ )}+ </div>+ );+}diff --git a/app/ui/modals/link-qr-modal.tsx b/app/ui/modals/link-qr-modal.tsxnew file mode 100644index 0000000000..2229314edc--- /dev/null+++ b/app/ui/modals/link-qr-modal.tsx@@ -0,0 +1,376 @@+"use client";++import {+ Dispatch,+ SetStateAction,+ useCallback,+ useMemo,+ useRef,+ useState,+} from "react";+import { HexColorInput, HexColorPicker } from "react-colorful";+import BlurImage from "#/ui/blur-image";+import { ChevronRight, Clipboard, Logo } from "@/components/shared/icons";+import Modal from "#/ui/modal";+import Switch from "#/ui/switch";+import Tooltip, { TooltipContent } from "#/ui/tooltip";+import { QRCodeSVG, getQRAsCanvas, getQRAsSVGDataUri } from "@/lib/qr";+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 "react-hot-toast";+import { GOOGLE_FAVICON_URL } from "@/lib/constants";++function LinkQRModalHelper({+ showLinkQRModal,+ setShowLinkQRModal,+ props,+}: {+ showLinkQRModal: boolean;+ setShowLinkQRModal: Dispatch<SetStateAction<boolean>>;+ props: SimpleLinkProps;+}) {+ const anchorRef = useRef<HTMLAnchorElement>(null);+ const { logo } = useProject();+ const { avatarUrl, apexDomain } = useMemo(() => {+ try {+ const apexDomain = getApexDomain(props.url);+ return {+ avatarUrl: `${GOOGLE_FAVICON_URL}${apexDomain}`,+ apexDomain,+ };+ } catch (e) {+ return {+ avatarUrl: null,+ apexDomain: null,+ };+ }+ }, [props]);++ const qrLogoUrl = useMemo(() => {+ if (logo) return logo;+ return typeof window !== "undefined" && window.location.origin+ ? new URL("/_static/logo.svg", window.location.origin).href+ : "";+ }, [logo]);++ function download(url: string, extension: string) {+ if (!anchorRef.current) return;+ anchorRef.current.href = url;+ anchorRef.current.download = `${props.key}-qrcode.${extension}`;+ anchorRef.current.click();+ }++ const [showLogo, setShowLogo] = useState(true);+ const [fgColor, setFgColor] = useState("#000000");++ const qrData = useMemo(+ () => ({+ value: linkConstructor({+ key: props.key,+ domain: props.domain || "dub.sh",+ }),+ bgColor: "#ffffff",+ fgColor,+ size: 1024,+ level: "Q", // QR Code error correction level: https://blog.qrstuff.com/general/qr-code-error-correction+ ...(showLogo && {+ imageSettings: {+ src: qrLogoUrl,+ height: 256,+ width: 256,+ excavate: true,+ },+ }),+ }),+ [props, fgColor, showLogo, qrLogoUrl],+ );++ const copyToClipboard = async () => {+ try {+ const canvas = await getQRAsCanvas(qrData, "image/png", true);+ (canvas as HTMLCanvasElement).toBlob(async function (blob) {+ // @ts-ignore+ const item = new ClipboardItem({ "image/png": blob });+ await navigator.clipboard.write([item]);+ });+ } catch (e) {+ throw e;+ }+ };++ 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">+ {avatarUrl ? (+ <BlurImage+ src={avatarUrl}+ alt={apexDomain}+ className="h-10 w-10 rounded-full"+ width={40}+ height={40}+ />+ ) : (+ <Logo className="h-10 w-10" />+ )}+ <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>++ <AdvancedSettings+ qrData={qrData}+ setFgColor={setFgColor}+ showLogo={showLogo}+ setShowLogo={setShowLogo}+ />++ <div className="grid grid-cols-2 gap-2 px-4 sm:px-16">+ <button+ onClick={async () => {+ toast.promise(copyToClipboard(), {+ loading: "Copying...",+ success: "Copied!",+ 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>+ </div>+ </Modal>+ );+}++function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {+ const { plan } = useProject();+ const [expanded, setExpanded] = useState(false);++ const isApp = useMemo(() => {+ if (typeof window === "undefined") return false;+ return window.location.host.startsWith("app.");+ }, []);++ return (+ <div>+ <div className="px-4 sm:px-16">+ <button+ type="button"+ className="flex items-center"+ onClick={() => setExpanded(!expanded)}+ >+ <ChevronRight+ className={`h-5 w-5 text-gray-600 ${+ expanded ? "rotate-90" : ""+ } transition-all`}+ />+ <p className="text-sm text-gray-600">Advanced options</p>+ </button>+ </div>+ {expanded && (+ <div className="mt-4 grid gap-5 border-b border-t border-gray-200 bg-white px-4 py-8 sm:px-16">+ <div>+ <label+ htmlFor="logo-toggle"+ className="block text-sm font-medium text-gray-700"+ >+ Logo+ </label>+ {plan && plan !== "free" ? (+ <div className="mt-1 flex items-center space-x-2">+ <Switch+ fn={setShowLogo}+ checked={showLogo}+ trackDimensions="h-6 w-12"+ thumbDimensions="w-5 h-5"+ thumbTranslate="translate-x-6"+ />+ <p className="text-sm text-gray-600">Show Dub.sh Logo</p>+ </div>+ ) : (+ <Tooltip+ content={+ <TooltipContent+ title="As a freemium product, we rely on word of mouth to spread the word about Dub. If you'd like to remove the Dub logo/upload your own, please consider upgrading to a Pro plan."+ cta="Upgrade to Pro"+ ctaLink={isApp ? "/settings" : "/#pricing"}+ />+ }+ >+ <div className="pointer-events-none mt-1 flex cursor-not-allowed items-center space-x-2 sm:pointer-events-auto">+ <Switch+ fn={setShowLogo}+ checked={showLogo}+ trackDimensions="h-6 w-12"+ thumbDimensions="w-5 h-5"+ thumbTranslate="translate-x-6"+ disabled={true}+ />+ <p className="text-sm text-gray-600">Show Dub.sh Logo</p>+ </div>+ </Tooltip>+ )}+ </div>+ <div>+ <label+ htmlFor="color"+ className="block text-sm font-medium text-gray-700"+ >+ Foreground Color+ </label>+ <div className="relative mt-1 flex h-9 w-48 rounded-md shadow-sm">+ <Tooltip+ content={+ <div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">+ <HexColorPicker+ color={qrData.fgColor}+ onChange={(color) => setFgColor(color)}+ />+ </div>+ }+ >+ <div+ className="h-full w-12 rounded-l-md border"+ style={{+ backgroundColor: qrData.fgColor,+ borderColor: qrData.fgColor,+ }}+ />+ </Tooltip>+ <HexColorInput+ id="color"+ name="color"+ color={qrData.fgColor}+ onChange={(color) => setFgColor(color)}+ prefixed+ style={{ borderColor: qrData.fgColor }}+ className={`block w-full rounded-r-md border-2 border-l-0 pl-3 text-gray-900 placeholder-gray-300 focus:outline-none focus:ring-black sm:text-sm`}+ />+ </div>+ </div>+ </div>+ )}+ </div>+ );+}++function QrDropdown({ download, qrData, showLogo, logo }) {+ const [openPopover, setOpenPopover] = useState(false);+ return (+ <>+ <Popover+ content={+ <div className="grid w-full gap-1 p-2 sm:w-40">+ <button+ onClick={() => {+ download(+ getQRAsSVGDataUri({+ ...qrData,+ ...(showLogo && {+ imageSettings: {+ ...qrData.imageSettings,+ src: logo || "https://dub.sh/_static/logo.svg",+ },+ }),+ }),+ "svg",+ );+ }}+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"+ >+ <IconMenu text="SVG" icon={<Photo className="h-4 w-4" />} />+ </button>+ <button+ onClick={async () => {+ download(await getQRAsCanvas(qrData, "image/png"), "png");+ }}+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"+ >+ <IconMenu text="PNG" icon={<Photo className="h-4 w-4" />} />+ </button>+ <button+ onClick={async () => {+ download(await getQRAsCanvas(qrData, "image/jpeg"), "jpg");+ }}+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"+ >+ <IconMenu text="JPEG" icon={<Photo className="h-4 w-4" />} />+ </button>+ </div>+ }+ align="center"+ openPopover={openPopover}+ setOpenPopover={setOpenPopover}+ >+ <button+ onClick={() => setOpenPopover(!openPopover)}+ className="flex w-full 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"+ >+ <Download />+ Export+ </button>+ </Popover>+ </>+ );+}++export function useLinkQRModal({ props }: { props: SimpleLinkProps }) {+ const [showLinkQRModal, setShowLinkQRModal] = useState(false);++ const LinkQRModal = useCallback(() => {+ return (+ <LinkQRModalHelper+ showLinkQRModal={showLinkQRModal}+ setShowLinkQRModal={setShowLinkQRModal}+ props={props}+ />+ );+ }, [showLinkQRModal, setShowLinkQRModal, props]);++ return useMemo(+ () => ({ showLinkQRModal, setShowLinkQRModal, LinkQRModal }),+ [showLinkQRModal, setShowLinkQRModal, LinkQRModal],+ );+}diff --git a/app/ui/popover.tsx b/app/ui/popover.tsxnew file mode 100644index 0000000000..76d8ed1f8e--- /dev/null+++ b/app/ui/popover.tsx@@ -0,0 +1,109 @@+"use client";++import { useParams } from "next/navigation";+import { ReactNode, useEffect, useRef } from "react";+import * as PopoverPrimitive from "@radix-ui/react-popover";+import { AnimatePresence, motion, useAnimation } from "framer-motion";+import useViewportSize from "@/lib/hooks/use-viewport-size";++export default function Popover({+ children,+ content,+ align = "center",+ openPopover,+ setOpenPopover,+}: {+ children: ReactNode;+ content: ReactNode | string;+ align?: "center" | "start" | "end";+ openPopover;+ setOpenPopover;+}) {+ const { slug } = useParams() as { slug?: string };++ const mobileTooltipRef = useRef<HTMLDivElement | null>(null);+ const controls = useAnimation();+ const transitionProps = { type: "spring", stiffness: 500, damping: 30 };++ async function handleDragEnd(_, info) {+ const offset = info.offset.y;+ const velocity = info.velocity.y;+ const height =+ mobileTooltipRef.current?.getBoundingClientRect().height || 0;+ if (offset > height / 2 || velocity > 800) {+ await controls.start({ y: "100%", transition: transitionProps });+ setOpenPopover(false);+ } else {+ controls.start({ y: 0, transition: transitionProps });+ }+ }+ const { width } = useViewportSize();++ // workaround to make popover close when route changes on desktop+ useEffect(() => {+ setOpenPopover(false);+ }, [slug]);++ return (+ <>+ <div className="md:hidden">{children}</div>+ <AnimatePresence>+ {openPopover && (+ <>+ <motion.div+ ref={mobileTooltipRef}+ key="mobile-tooltip"+ className="group fixed inset-x-0 bottom-0 z-40 w-screen cursor-grab active:cursor-grabbing md:hidden"+ initial={{ y: "100%" }}+ animate={{+ y: openPopover ? 0 : "100%",+ transition: transitionProps,+ }}+ exit={{ y: "100%" }}+ transition={transitionProps}+ drag="y"+ dragDirectionLock+ onDragEnd={handleDragEnd}+ dragElastic={{ top: 0, bottom: 1 }}+ dragConstraints={{ top: 0, bottom: 0 }}+ >+ <div+ className={`rounded-t-4xl -mb-1 flex h-7 w-full items-center justify-center border-t border-gray-200 bg-white`}+ >+ <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>+ <div className="flex min-h-[150px] w-full items-center justify-center overflow-hidden bg-white align-middle shadow-xl">+ {content}+ </div>+ </motion.div>+ <motion.div+ key="mobile-tooltip-backdrop"+ className="fixed inset-0 z-30 bg-gray-100 bg-opacity-10 backdrop-blur md:hidden"+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ onClick={() => setOpenPopover(false)}+ />+ </>+ )}+ </AnimatePresence>+ <PopoverPrimitive.Root+ // workaround to make popover work on mobile (without this it'll automatically close on click without changing route)+ open={width > 640 && openPopover}+ onOpenChange={width > 640 && setOpenPopover}+ >+ <PopoverPrimitive.Trigger className="hidden md:inline-flex" asChild>+ {children}+ </PopoverPrimitive.Trigger>+ <PopoverPrimitive.Content+ sideOffset={4}+ align={align}+ className="z-20 hidden animate-slide-up-fade items-center rounded-md border border-gray-200 bg-white drop-shadow-lg md:block"+ >+ {content}+ </PopoverPrimitive.Content>+ </PopoverPrimitive.Root>+ </>+ );+}diff --git a/components/shared/switch.tsx b/app/ui/switch.tsxsimilarity index 98%rename from components/shared/switch.tsxrename to app/ui/switch.tsxindex a911280acb..4d5d54204d 100644--- a/components/shared/switch.tsx+++ b/app/ui/switch.tsx@@ -1,3 +1,5 @@+"use client";+import { Dispatch, SetStateAction } from "react";import * as SwitchPrimitive from "@radix-ui/react-switch";import clsx from "clsx";diff --git a/components/shared/tooltip.tsx b/app/ui/tooltip.tsxsimilarity index 99%rename from components/shared/tooltip.tsxrename to app/ui/tooltip.tsxindex 6c2a222965..f82e4a46ec 100644--- a/components/shared/tooltip.tsx+++ b/app/ui/tooltip.tsx@@ -1,3 +1,5 @@+"use client";+/***********************************//* Tooltip Contents */@@ -5,7 +7,7 @@ import Link from "next/link";import { ReactNode, useRef, useState } from "react";import * as TooltipPrimitive from "@radix-ui/react-tooltip";import { AnimatePresence, motion, useAnimation } from "framer-motion";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";export default function Tooltip({children,diff --git a/components/app/domains/domain-card.tsx b/components/app/domains/domain-card.tsxindex fd76dcd339..0c3a3bb315 100644--- a/components/app/domains/domain-card.tsx+++ b/components/app/domains/domain-card.tsx@@ -5,10 +5,9 @@ import {Chart,CheckCircleFill,ExternalLink,- LoadingCircle,- LoadingDots,XCircleFill,} from "@/components/shared/icons";+import { LoadingCircle, LoadingDots } from "#/ui/icons";import { DomainProps, DomainVerificationStatusProps } from "@/lib/types";import { capitalize, fetcher, nFormatter, truncate } from "@/lib/utils";import { useAddEditDomainModal } from "../modals/add-edit-domain-modal";diff --git a/components/app/domains/no-domains-placeholder.tsx b/components/app/domains/no-domains-placeholder.tsxindex 8b94f3ba04..bf53de439a 100644--- a/components/app/domains/no-domains-placeholder.tsx+++ b/components/app/domains/no-domains-placeholder.tsx@@ -1,4 +1,4 @@-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";export default function NoDomainsPlaceholder({AddEditDomainButton,diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsxindex b95d616061..cd40ce0d59 100644--- a/components/app/links/link-card.tsx+++ b/components/app/links/link-card.tsx@@ -7,7 +7,7 @@ import { useArchiveLinkModal } from "@/components/app/modals/archive-link-modal"import { useDeleteLinkModal } from "@/components/app/modals/delete-link-modal";import { useLinkQRModal } from "@/components/app/modals/link-qr-modal";import IconMenu from "@/components/shared/icon-menu";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import CopyButton from "@/components/shared/copy-button";import {Archive,@@ -17,7 +17,7 @@ import {ThreeDots,} from "@/components/shared/icons";import Popover from "@/components/shared/popover";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import useProject from "@/lib/swr/use-project";import { LinkProps } from "@/lib/types";import {diff --git a/components/app/links/link-filters.tsx b/components/app/links/link-filters.tsxindex 3a263e4f71..2083f48591 100644--- a/components/app/links/link-filters.tsx+++ b/components/app/links/link-filters.tsx@@ -11,7 +11,7 @@ import useLinks from "@/lib/swr/use-links";import { LoadingSpinner } from "@/components/shared/icons";import useLinksCount from "@/lib/swr/use-links-count";import punycode from "punycode/";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { useSession } from "next-auth/react";export default function LinkFilters() {diff --git a/components/app/links/no-links-placeholder.tsx b/components/app/links/no-links-placeholder.tsxindex 51f6a3e6a2..4b8c3ee1c6 100644--- a/components/app/links/no-links-placeholder.tsx+++ b/components/app/links/no-links-placeholder.tsx@@ -1,4 +1,4 @@-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";export default function NoLinksPlaceholder({AddEditLinkButton,diff --git a/components/app/modals/accept-invite-modal.tsx b/components/app/modals/accept-invite-modal.tsxindex b1c3be793c..2e3bbc3f7d 100644--- a/components/app/modals/accept-invite-modal.tsx+++ b/components/app/modals/accept-invite-modal.tsx@@ -8,8 +8,8 @@ import {useState,} from "react";import { mutate } from "swr";-import BlurImage from "@/components/shared/blur-image";-import LoadingDots from "@/components/shared/icons/loading-dots";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Modal from "@/components/shared/modal";import useProject from "@/lib/swr/use-project";import toast from "react-hot-toast";diff --git a/components/app/modals/add-edit-domain-modal.tsx b/components/app/modals/add-edit-domain-modal.tsxindex 6b068ee62e..df0ca5e250 100644--- a/components/app/modals/add-edit-domain-modal.tsx+++ b/components/app/modals/add-edit-domain-modal.tsx@@ -9,17 +9,17 @@ import {} from "react";import { mutate } from "swr";import { useDebounce } from "use-debounce";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { AlertCircleFill, Lock } from "@/components/shared/icons";import Modal from "@/components/shared/modal";import { DomainProps } from "@/lib/types";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import useProject from "@/lib/swr/use-project";import { AnimatePresence, motion } from "framer-motion";import { SWIPE_REVEAL_ANIMATION_SETTINGS } from "@/lib/constants";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import useDomains from "@/lib/swr/use-domains";-import Button from "@/ui/button";+import Button from "#/ui/button";function AddEditDomainModal({showAddEditDomainModal,diff --git a/components/app/modals/add-edit-link-modal/android-section.tsx b/components/app/modals/add-edit-link-modal/android-section.tsxindex deb0e3eafe..1732cd764f 100644--- a/components/app/modals/add-edit-link-modal/android-section.tsx+++ b/components/app/modals/add-edit-link-modal/android-section.tsx@@ -1,6 +1,6 @@import { Dispatch, SetStateAction, useEffect, useState } from "react";import { LinkProps } from "@/lib/types";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { motion } from "framer-motion";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";diff --git a/components/app/modals/add-edit-link-modal/expiration-section.tsx b/components/app/modals/add-edit-link-modal/expiration-section.tsxindex d01c3f44f2..84b94bd956 100644--- a/components/app/modals/add-edit-link-modal/expiration-section.tsx+++ b/components/app/modals/add-edit-link-modal/expiration-section.tsx@@ -1,7 +1,7 @@import { Dispatch, SetStateAction, useEffect, useState } from "react";import { LinkProps } from "@/lib/types";import { getDateTimeLocal } from "@/lib/utils";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { motion } from "framer-motion";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsxindex c0c44e933e..e8c4d92bec 100644--- a/components/app/modals/add-edit-link-modal/index.tsx+++ b/components/app/modals/add-edit-link-modal/index.tsx@@ -10,17 +10,11 @@ import {} from "react";import { mutate } from "swr";import { useDebounce } from "use-debounce";-import BlurImage from "@/components/shared/blur-image";-import {- AlertCircleFill,- LoadingCircle,- LoadingDots,- Lock,- Random,- X,-} from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { AlertCircleFill, Lock, Random, X } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import Modal from "@/components/shared/modal";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import useProject from "@/lib/swr/use-project";import { LinkProps } from "@/lib/types";import {@@ -42,7 +36,7 @@ import useDomains from "@/lib/swr/use-domains";import { toast } from "react-hot-toast";import va from "@vercel/analytics";import punycode from "punycode/";-import Button from "@/ui/button";+import Button from "#/ui/button";function AddEditLinkModal({showAddEditLinkModal,diff --git a/components/app/modals/add-edit-link-modal/ios-section.tsx b/components/app/modals/add-edit-link-modal/ios-section.tsxindex 4ddbbedb7b..102fe06898 100644--- a/components/app/modals/add-edit-link-modal/ios-section.tsx+++ b/components/app/modals/add-edit-link-modal/ios-section.tsx@@ -1,6 +1,6 @@import { Dispatch, SetStateAction, useEffect, useState } from "react";import { LinkProps } from "@/lib/types";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { motion } from "framer-motion";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";diff --git a/components/app/modals/add-edit-link-modal/og-section.tsx b/components/app/modals/add-edit-link-modal/og-section.tsxindex 9a444fcdf3..13d1ed7d8c 100644--- a/components/app/modals/add-edit-link-modal/og-section.tsx+++ b/components/app/modals/add-edit-link-modal/og-section.tsx@@ -7,9 +7,10 @@ import {} from "react";import { motion } from "framer-motion";import TextareaAutosize from "react-textarea-autosize";-import { LoadingCircle, UploadCloud } from "@/components/shared/icons";+import { UploadCloud } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import { LinkProps } from "@/lib/types";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";export default function OGSection({diff --git a/components/app/modals/add-edit-link-modal/password-section.tsx b/components/app/modals/add-edit-link-modal/password-section.tsxindex 2465ccd30e..6d38daa2b5 100644--- a/components/app/modals/add-edit-link-modal/password-section.tsx+++ b/components/app/modals/add-edit-link-modal/password-section.tsx@@ -1,6 +1,6 @@import { Dispatch, SetStateAction, useEffect, useState } from "react";import { LinkProps } from "@/lib/types";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { motion } from "framer-motion";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";import { Eye, EyeOff } from "@/components/shared/icons";diff --git a/components/app/modals/add-edit-link-modal/preview.tsx b/components/app/modals/add-edit-link-modal/preview.tsxindex 5390963395..b4d3c47549 100644--- a/components/app/modals/add-edit-link-modal/preview.tsx+++ b/components/app/modals/add-edit-link-modal/preview.tsx@@ -1,12 +1,6 @@-import BlurImage from "@/components/shared/blur-image";-import {- ExternalLink,- Facebook,- LinkedIn,- LoadingCircle,- Photo,- Twitter,-} from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { Facebook, LinkedIn, Photo, Twitter } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import { LinkProps } from "@/lib/types";import { getDomainWithoutWWW } from "@/lib/utils";import { useMemo } from "react";@@ -102,7 +96,7 @@ export default function Preview({<div className="mb-1 h-4 w-full rounded-md bg-gray-100" />)}{description ? (- <p className="text-sm text-[#536471] line-clamp-2">+ <p className="line-clamp-2 text-sm text-[#536471]">{description}</p>) : (@@ -149,7 +143,7 @@ export default function Preview({<div className="mb-1 h-5 w-full rounded-md bg-gray-200" />)}{description ? (- <p className="text-sm text-[#606770] line-clamp-2">+ <p className="line-clamp-2 text-sm text-[#606770]">{description}</p>) : (diff --git a/components/app/modals/add-edit-link-modal/utm-section.tsx b/components/app/modals/add-edit-link-modal/utm-section.tsxindex 226c62b621..c4c9f889ee 100644--- a/components/app/modals/add-edit-link-modal/utm-section.tsx+++ b/components/app/modals/add-edit-link-modal/utm-section.tsx@@ -7,7 +7,7 @@ import {paramsMetadata,getUrlWithoutUTMParams,} from "@/lib/utils";-import Switch from "@/components/shared/switch";+import Switch from "#/ui/switch";import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";export default function UTMSection({diff --git a/components/app/modals/add-project-modal.tsx b/components/app/modals/add-project-modal.tsxindex 824ca3b339..35d79af6c3 100644--- a/components/app/modals/add-project-modal.tsx+++ b/components/app/modals/add-project-modal.tsx@@ -10,12 +10,12 @@ import {} from "react";import { mutate } from "swr";import { useDebounce } from "use-debounce";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { AlertCircleFill } from "@/components/shared/icons";import Modal from "@/components/shared/modal";import { generateDomainFromName } from "@/lib/utils";import va from "@vercel/analytics";-import Button from "@/ui/button";+import Button from "#/ui/button";function AddProjectModalHelper({showAddProjectModal,diff --git a/components/app/modals/archive-link-modal.tsx b/components/app/modals/archive-link-modal.tsxindex 6bc92dfbd8..856f8adba9 100644--- a/components/app/modals/archive-link-modal.tsx+++ b/components/app/modals/archive-link-modal.tsx@@ -7,10 +7,9 @@ import {useState,} from "react";import { mutate } from "swr";-import BlurImage from "@/components/shared/blur-image";-import LoadingDots from "@/components/shared/icons/loading-dots";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Modal from "@/components/shared/modal";-import useProject from "@/lib/swr/use-project";import { LinkProps } from "@/lib/types";import { getApexDomain, getQueryString, linkConstructor } from "@/lib/utils";import { GOOGLE_FAVICON_URL } from "@/lib/constants";diff --git a/components/app/modals/complete-setup-modal.tsx b/components/app/modals/complete-setup-modal.tsxindex 304d2829eb..f2599d426b 100644--- a/components/app/modals/complete-setup-modal.tsx+++ b/components/app/modals/complete-setup-modal.tsx@@ -7,9 +7,10 @@ import {useMemo,useState,} from "react";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import Modal from "@/components/shared/modal";-import { CheckCircleFill, ExpandingArrow } from "@/components/shared/icons";+import { CheckCircleFill } from "@/components/shared/icons";+import { ExpandingArrow } from "#/ui/icons";function CompleteSetupModal({showCompleteSetupModal,diff --git a/components/app/modals/delete-link-modal.tsx b/components/app/modals/delete-link-modal.tsxindex 987e12a1a9..e47ed3cfe5 100644--- a/components/app/modals/delete-link-modal.tsx+++ b/components/app/modals/delete-link-modal.tsx@@ -7,8 +7,8 @@ import {useState,} from "react";import { mutate } from "swr";-import BlurImage from "@/components/shared/blur-image";-import LoadingDots from "@/components/shared/icons/loading-dots";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Modal from "@/components/shared/modal";import { LinkProps } from "@/lib/types";import { getApexDomain, getQueryString, linkConstructor } from "@/lib/utils";diff --git a/components/app/modals/delete-project-modal.tsx b/components/app/modals/delete-project-modal.tsxindex 9794e0d254..55544e309c 100644--- a/components/app/modals/delete-project-modal.tsx+++ b/components/app/modals/delete-project-modal.tsx@@ -8,8 +8,8 @@ import {} from "react";import toast from "react-hot-toast";import { mutate } from "swr";-import BlurImage from "@/components/shared/blur-image";-import LoadingDots from "@/components/shared/icons/loading-dots";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Modal from "@/components/shared/modal";import useProject from "@/lib/swr/use-project";diff --git a/components/app/modals/invite-teammate-modal.tsx b/components/app/modals/invite-teammate-modal.tsxindex 1150f65626..16635a6d61 100644--- a/components/app/modals/invite-teammate-modal.tsx+++ b/components/app/modals/invite-teammate-modal.tsx@@ -7,8 +7,8 @@ import {useState,} from "react";import { mutate } from "swr";-import BlurImage from "@/components/shared/blur-image";-import LoadingDots from "@/components/shared/icons/loading-dots";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Modal from "@/components/shared/modal";import useProject from "@/lib/swr/use-project";import toast from "react-hot-toast";@@ -95,7 +95,7 @@ function InviteTeammateModal({state === "inviting"? "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400": "border-black bg-black text-white hover:bg-white hover:text-black"- } mt-4 mb-2 flex h-10 w-full items-center justify-center rounded-md border text-sm transition-all focus:outline-none`}+ } mb-2 mt-4 flex h-10 w-full items-center justify-center rounded-md border text-sm transition-all focus:outline-none`}>{state === "inviting" ? (<LoadingDots color="#808080" />diff --git a/components/app/modals/link-qr-modal.tsx b/components/app/modals/link-qr-modal.tsxindex dfc984a060..556925c5ed 100644--- a/components/app/modals/link-qr-modal.tsx+++ b/components/app/modals/link-qr-modal.tsx@@ -7,11 +7,11 @@ import {useState,} from "react";import { HexColorInput, HexColorPicker } from "react-colorful";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { ChevronRight, Clipboard, Logo } from "@/components/shared/icons";import Modal from "@/components/shared/modal";-import Switch from "@/components/shared/switch";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import Switch from "#/ui/switch";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import { QRCodeSVG, getQRAsCanvas, getQRAsSVGDataUri } from "@/lib/qr";import useProject from "@/lib/swr/use-project";import { SimpleLinkProps } from "@/lib/types";diff --git a/components/app/modals/upgrade-plan-modal.tsx b/components/app/modals/upgrade-plan-modal.tsxindex 049f130a6e..ab19a7d947 100644--- a/components/app/modals/upgrade-plan-modal.tsx+++ b/components/app/modals/upgrade-plan-modal.tsx@@ -6,7 +6,7 @@ import {useState,} from "react";import Modal from "@/components/shared/modal";-import Pricing from "@/components/home/pricing";+import Pricing from "#/ui/home/pricing";function UpgradePlanModal({showUpgradePlanModal,diff --git a/components/app/projects/no-projects-placeholder.tsx b/components/app/projects/no-projects-placeholder.tsxindex b3eccef87e..cf538d8d3a 100644--- a/components/app/projects/no-projects-placeholder.tsx+++ b/components/app/projects/no-projects-placeholder.tsx@@ -1,5 +1,5 @@import Link from "next/link";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";export default function NoProjectsPlaceholder({setShowAddProjectModal,diff --git a/components/app/projects/project-card.tsx b/components/app/projects/project-card.tsxindex 82cc2af694..4b500c04db 100644--- a/components/app/projects/project-card.tsx+++ b/components/app/projects/project-card.tsx@@ -1,8 +1,8 @@import Link from "next/link";import useSWR from "swr";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { CheckCircleFill, XCircleFill } from "@/components/shared/icons";-import Tooltip, { TooltipContent } from "@/components/shared/tooltip";+import Tooltip, { TooltipContent } from "#/ui/tooltip";import { ProjectWithDomainProps } from "@/lib/types";import { fetcher, nFormatter } from "@/lib/utils";import { BarChart2, Globe, Link2 } from "lucide-react";diff --git a/components/app/settings/plan-usage.tsx b/components/app/settings/plan-usage.tsxindex 2a096dd7cc..42f1f7948f 100644--- a/components/app/settings/plan-usage.tsx+++ b/components/app/settings/plan-usage.tsx@@ -8,7 +8,7 @@ import {LoadingDots,QuestionCircle,} from "@/components/shared/icons";-import Tooltip from "@/components/shared/tooltip";+import Tooltip from "#/ui/tooltip";import { getFirstAndLastDay, nFormatter } from "@/lib/utils";import useProject from "@/lib/swr/use-project";import useDomains from "@/lib/swr/use-domains";diff --git a/components/app/settings/project-name.tsx b/components/app/settings/project-name.tsxindex fae9551896..f01a69c969 100644--- a/components/app/settings/project-name.tsx+++ b/components/app/settings/project-name.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import { useEffect, useMemo, useState } from "react";import toast from "react-hot-toast";-import { LoadingDots } from "@/components/shared/icons";+import { LoadingDots } from "#/ui/icons";import useProject from "@/lib/swr/use-project";import { mutate } from "swr";diff --git a/components/app/settings/project-slug.tsx b/components/app/settings/project-slug.tsxindex e3bae54339..d1a54192ca 100644--- a/components/app/settings/project-slug.tsx+++ b/components/app/settings/project-slug.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import { useEffect, useMemo, useState } from "react";import toast from "react-hot-toast";-import { LoadingDots } from "@/components/shared/icons";+import { LoadingDots } from "#/ui/icons";import { mutate } from "swr";export default function ProjectSlug() {diff --git a/components/app/welcome/interim.tsx b/components/app/welcome/interim.tsxindex d1702f3451..d3a2ef361e 100644--- a/components/app/welcome/interim.tsx+++ b/components/app/welcome/interim.tsx@@ -1,6 +1,6 @@import { Dispatch, SetStateAction, useState } from "react";import { motion } from "framer-motion";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { Logo } from "@/components/shared/icons";import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";@@ -11,7 +11,7 @@ export default function Interim({}) {return (<motion.div- className="z-10 my-auto mx-5 flex flex-col items-center space-y-10 text-center sm:mx-auto"+ className="z-10 mx-5 my-auto flex flex-col items-center space-y-10 text-center sm:mx-auto"variants={{hidden: { opacity: 0, scale: 0.95 },show: {@@ -66,7 +66,7 @@ export default function Interim({alt="No links yet"width={250}height={250}- className="pointer-events-none -mt-8 -mb-3 w-48 sm:w-60"+ className="pointer-events-none -mb-3 -mt-8 w-48 sm:w-60"/><p>I have a domain</p></button>@@ -79,7 +79,7 @@ export default function Interim({alt="No links yet"width={250}height={250}- className="pointer-events-none -mt-8 -mb-3 w-48 sm:w-60"+ className="pointer-events-none -mb-3 -mt-8 w-48 sm:w-60"/><p>I don't have a domain</p></button>diff --git a/components/layout/app/project-select.tsx b/components/layout/app/project-select.tsxindex 7919a24521..c35f22c7b4 100644--- a/components/layout/app/project-select.tsx+++ b/components/layout/app/project-select.tsx@@ -2,7 +2,7 @@ import { useRouter } from "next/router";import { useMemo, useState } from "react";import { useSession } from "next-auth/react";import { useAddProjectModal } from "@/components/app/modals/add-project-modal";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { ChevronUpDown, PlusCircle, Tick } from "@/components/shared/icons";import Popover from "@/components/shared/popover";import { PlanProps, ProjectWithDomainProps } from "@/lib/types";diff --git a/components/shared/icons/index.tsx b/components/shared/icons/index.tsxindex edc6c079c3..1c2e685e9c 100644--- a/components/shared/icons/index.tsx+++ b/components/shared/icons/index.tsx@@ -1,9 +1,5 @@// Most of these icons are gotten from Vercel's open-sourced icons library: https://vercel.com/design/icons-export { default as LoadingDots } from "./loading-dots";-export { default as LoadingCircle } from "./loading-circle";-export { default as LoadingSpinner } from "./loading-spinner";-export { default as ExpandingArrow } from "./expanding-arrow";export { default as Tick } from "./tick";export { default as Copy } from "./copy";export { default as X } from "./x";diff --git a/components/shared/tweet.tsx b/components/shared/tweet.tsxindex 66f6d07313..a99f3adb59 100644--- a/components/shared/tweet.tsx+++ b/components/shared/tweet.tsx@@ -1,6 +1,6 @@"use client";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { nFormatter, truncate } from "@/lib/utils";import { Heart, Message, Repeat, Twitter } from "./icons";import Tilt from "react-parallax-tilt";@@ -187,13 +187,13 @@ export default function Tweet({</div>)}<div- className="mt-4 mb-2 truncate whitespace-pre-wrap text-[15px] text-gray-700"+ className="mb-2 mt-4 truncate whitespace-pre-wrap text-[15px] text-gray-700"dangerouslySetInnerHTML={{ __html: formattedText }}/></div>{/* Images, Preview images, videos, polls, etc. */}- <div className="mt-3 -mb-2">+ <div className="-mb-2 mt-3">{media && media.length ? (<divclassName={@@ -254,10 +254,10 @@ export default function Tweet({className="h-40 object-cover"/><div className="w-full bg-white p-3">- <p className="text-sm font-semibold line-clamp-1">+ <p className="line-clamp-1 text-sm font-semibold">{url_meta.title}</p>- <p className="text-sm text-gray-500 line-clamp-2">+ <p className="line-clamp-2 text-sm text-gray-500">{url_meta.description}</p></div>@@ -315,7 +315,7 @@ export default function Tweet({? "bg-[#1da1f2] font-bold": "bg-gray-300"}- absolute top-0 left-0 h-full w-full rounded-md+ absolute left-0 top-0 h-full w-full rounded-md`}style={{width: `${Math.round(diff --git a/components/stats/bar-chart.tsx b/components/stats/bar-chart.tsxindex dc24c99dec..b2c6ff8fe6 100644--- a/components/stats/bar-chart.tsx+++ b/components/stats/bar-chart.tsx@@ -12,7 +12,7 @@ import { nFormatter } from "@/lib/utils";import styles from "./bar-chart.module.css";import useSWR from "swr";import { fetcher } from "@/lib/utils";-import { LoadingCircle } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import useEndpoint from "@/lib/hooks/use-endpoint";const LEFT_AXIS_WIDTH = 30;diff --git a/components/stats/device-icon.tsx b/components/stats/device-icon.tsxindex 82a8167266..56ab54e507 100644--- a/components/stats/device-icon.tsx+++ b/components/stats/device-icon.tsx@@ -1,4 +1,4 @@-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { Apple, Chrome, Safari } from "@/components/shared/icons/devices";import { DeviceTabs } from "@/lib/stats";diff --git a/components/stats/devices.tsx b/components/stats/devices.tsxindex e8c75b2896..c9490e2840 100644--- a/components/stats/devices.tsx+++ b/components/stats/devices.tsx@@ -2,7 +2,7 @@ import { useMemo, useState } from "react";import { useRouter } from "next/router";import { motion } from "framer-motion";import BadgeSelect from "@/components/shared/badge-select";-import { LoadingCircle } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import { DeviceTabs, uaToBot } from "@/lib/stats";import { nFormatter } from "@/lib/utils";import DeviceIcon from "./device-icon";diff --git a/components/stats/feedback.tsx b/components/stats/feedback.tsxindex f72b3857f5..3a02d89275 100644--- a/components/stats/feedback.tsx+++ b/components/stats/feedback.tsx@@ -1,7 +1,7 @@import { useState } from "react";import { AnimatePresence, motion } from "framer-motion";import { useSession } from "next-auth/react";-import LoadingDots from "@/components/shared/icons/loading-dots";+import { LoadingDots } from "#/ui/icons";import { CheckCircleFill } from "../shared/icons";import { useDebouncedCallback } from "use-debounce";diff --git a/components/stats/locations.tsx b/components/stats/locations.tsxindex 0fc038aea2..ae498890bc 100644--- a/components/stats/locations.tsx+++ b/components/stats/locations.tsx@@ -4,7 +4,7 @@ import BadgeSelect from "@/components/shared/badge-select";import { COUNTRIES } from "@/lib/constants";import { LocationTabs } from "@/lib/stats";import { nFormatter } from "@/lib/utils";-import { LoadingCircle } from "../shared/icons";+import { LoadingCircle } from "#/ui/icons";import { useRouter } from "next/router";import useSWR from "swr";import { fetcher } from "@/lib/utils";diff --git a/components/stats/referer.tsx b/components/stats/referer.tsxindex f8fbad9f50..594a36f655 100644--- a/components/stats/referer.tsx+++ b/components/stats/referer.tsx@@ -1,7 +1,8 @@import { useRouter } from "next/router";import { motion } from "framer-motion";-import BlurImage from "@/components/shared/blur-image";-import { Link, LoadingCircle } from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { Link2 } from "lucide-react";+import { LoadingCircle } from "#/ui/icons";import { nFormatter } from "@/lib/utils";import useSWR from "swr";import { fetcher } from "@/lib/utils";@@ -42,7 +43,7 @@ export default function Referer() {<div className="relative z-10 flex w-full max-w-[calc(100%-3rem)] items-center"><span className="z-10 flex items-center space-x-2 px-2">{referer === "(direct)" ? (- <Link className="h-4 w-4" />+ <Link2 className="h-4 w-4" />) : (<BlurImagesrc={`${GOOGLE_FAVICON_URL}${referer}`}diff --git a/components/stats/toggle.tsx b/components/stats/toggle.tsxindex a82b7386e3..35f4c939eb 100644--- a/components/stats/toggle.tsx+++ b/components/stats/toggle.tsx@@ -4,10 +4,10 @@ import {Calendar,ChevronDown,Copy,- ExpandingArrow,Share,Tick,} from "@/components/shared/icons";+import { ExpandingArrow } from "#/ui/icons";import { INTERVALS } from "@/lib/constants";import useScroll from "@/lib/hooks/use-scroll";import { linkConstructor } from "@/lib/utils";@@ -16,7 +16,7 @@ import Popover from "@/components/shared/popover";import useSWR, { mutate } from "swr";import { fetcher } from "@/lib/utils";import { toast } from "react-hot-toast";-import Switch from "../shared/switch";+import Switch from "#/ui/switch";import useEndpoint from "@/lib/hooks/use-endpoint";export default function Toggle({diff --git a/lib/twitter/get-tweet.ts b/lib/twitter/get-tweet.tsindex 742ef8a565..4499047779 100644--- a/lib/twitter/get-tweet.ts+++ b/lib/twitter/get-tweet.ts@@ -21,6 +21,9 @@ export const getTweet = async (id: string) => {headers: {Authorization: `Bearer ${process.env.TWITTER_AUTH_TOKEN}`,},+ next: {+ revalidate: 3600, // revalidate every 1 hour+ },},);const tweet = await response.json();diff --git a/pages/_auth/[domain]/[key].tsx b/pages/_auth/[domain]/[key].tsxindex 550570fd70..92b27ee582 100644--- a/pages/_auth/[domain]/[key].tsx+++ b/pages/_auth/[domain]/[key].tsx@@ -1,8 +1,9 @@import Head from "next/head";import { useRouter } from "next/router";import { useState } from "react";-import BlurImage from "@/components/shared/blur-image";-import { AlertCircleFill, LoadingDots } from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { AlertCircleFill } from "@/components/shared/icons";+import { LoadingDots } from "#/ui/icons";import { FAVICON_FOLDER } from "@/lib/constants";const title = "Password Required";diff --git a/pages/app/[slug]/[domain]/[key].tsx b/pages/app/[slug]/[domain]/[key].tsxindex 2882df5446..c8fbae759d 100644--- a/pages/app/[slug]/[domain]/[key].tsx+++ b/pages/app/[slug]/[domain]/[key].tsx@@ -1,7 +1,7 @@import ErrorPage from "next/error";import Link from "next/link";import AppLayout from "@/components/layout/app";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { Lock } from "@/components/shared/icons";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import Stats from "@/components/stats";diff --git a/pages/app/[slug]/settings/people.tsx b/pages/app/[slug]/settings/people.tsxindex 3d10e611e9..7aa37cc5d9 100644--- a/pages/app/[slug]/settings/people.tsx+++ b/pages/app/[slug]/settings/people.tsx@@ -3,7 +3,7 @@ import { useInviteTeammateModal } from "components/app/modals/invite-teammate-moimport { useState } from "react";import { useRouter } from "next/router";import useSWR from "swr";-import BlurImage from "@/components/shared/blur-image";+import BlurImage from "#/ui/blur-image";import { UserProps } from "@/lib/types";import { fetcher, timeAgo } from "@/lib/utils";diff --git a/pages/app/login.tsx b/pages/app/login.tsxindex 9c44446df3..d16c9217be 100644--- a/pages/app/login.tsx+++ b/pages/app/login.tsx@@ -2,8 +2,8 @@ import Link from "next/link";import { useState } from "react";import { signIn } from "next-auth/react";import Meta from "@/components/layout/meta";-import BlurImage from "@/components/shared/blur-image";-import { LoadingDots } from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Background from "@/components/shared/background";import { toast, Toaster } from "react-hot-toast";diff --git a/pages/app/register.tsx b/pages/app/register.tsxindex acb51ed967..c6b86b794b 100644--- a/pages/app/register.tsx+++ b/pages/app/register.tsx@@ -2,8 +2,8 @@ import Link from "next/link";import { useState } from "react";import { signIn } from "next-auth/react";import Meta from "@/components/layout/meta";-import BlurImage from "@/components/shared/blur-image";-import { LoadingDots } from "@/components/shared/icons";+import BlurImage from "#/ui/blur-image";+import { LoadingDots } from "#/ui/icons";import Background from "@/components/shared/background";import { toast, Toaster } from "react-hot-toast";import va from "@vercel/analytics";diff --git a/pages/metatags.tsx b/pages/metatags.tsxindex 47c0e1477f..07419ce10b 100644--- a/pages/metatags.tsx+++ b/pages/metatags.tsx@@ -1,12 +1,6 @@import HomeLayout from "@/components/layout/home";-import {- Copy,- Github,- LoadingCircle,- Photo,- Tick,- Twitter,-} from "@/components/shared/icons";+import { Copy, Github, Photo, Tick, Twitter } from "@/components/shared/icons";+import { LoadingCircle } from "#/ui/icons";import getTweetsMetadata from "@/lib/twitter";import Tweet from "@/components/shared/tweet";import { useMemo, useState } from "react";diff --git a/pages/index.tsx b/pages/old-index.tsxsimilarity index 85%rename from pages/index.tsxrename to pages/old-index.tsxindex b086eff4cc..d1a3920914 100644--- a/pages/index.tsx+++ b/pages/old-index.tsx@@ -3,15 +3,15 @@ import { useCallback, useEffect } from "react";import prisma from "@/lib/prisma";import { useStatsModal } from "@/components/app/modals/stats-modal";import Background from "@/components/shared/background";-import Demo from "@/components/home/demo";-import Features from "@/components/home/features";-import Globe from "@/components/home/globe";-import Hero from "@/components/home/hero";-import Logos from "@/components/home/logos";-import Pricing from "@/components/home/pricing";+import Demo from "#/ui/home/demo";+import Features from "#/ui/home/features";+import Globe from "#/ui/home/globe";+import Hero from "#/ui/home/hero";+import Logos from "#/ui/home/logos";+import Pricing from "#/ui/home/pricing";import HomeLayout from "@/components/layout/home";-import OSS from "@/components/home/oss";-import Testimonials from "@/components/home/testimonials";+import OSS from "#/ui/home/oss";+import Testimonials from "#/ui/home/testimonials";import getTweetsMetadata, { homepageTweets } from "@/lib/twitter";export default function Home({diff --git a/tsconfig.json b/tsconfig.jsonindex d0398e529e..1f28e1285a 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -10,7 +10,8 @@"@/pages/*": ["pages/*"],"@/lib/*": ["lib/*"],"@/styles/*": ["styles/*"],- "@/ui/*": ["app/ui/*"],+ "#/ui/*": ["app/ui/*"],+ "#/lib/*": ["app/lib/*"],"contentlayer/generated": ["./.contentlayer/generated"]},"downlevelIteration": true,