The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
simplify old components
Steven Tey067f81cb9c66
diff --git a/apps/web/lib/fetchers/get-content-api.ts b/apps/web/lib/fetchers/get-content-api.tsindex 0401b15917..b96c5a8675 100644--- a/apps/web/lib/fetchers/get-content-api.ts+++ b/apps/web/lib/fetchers/get-content-api.ts@@ -1,10 +1,7 @@-import { HelpArticle } from "@/ui/layout/help";import { NewsArticle } from "@/ui/layout/sidebar/news";import { cache } from "react";export const getContentAPI: () => Promise<{- allHelpArticles: HelpArticle[];- popularHelpArticles: HelpArticle[];latestNewsArticles: NewsArticle[];}> = cache(async () => {try {@@ -15,8 +12,6 @@ export const getContentAPI: () => Promise<{}).then((res) => res.json());} catch (e) {return {- allHelpArticles: [],- popularHelpArticles: [],latestNewsArticles: [],};}diff --git a/apps/web/ui/layout/page-content/page-content-old.tsx b/apps/web/ui/layout/page-content/page-content-old.tsxindex e3c0bc22d8..5fe4636a6f 100644--- a/apps/web/ui/layout/page-content/page-content-old.tsx+++ b/apps/web/ui/layout/page-content/page-content-old.tsx@@ -3,8 +3,8 @@ import { cn } from "@dub/utils";import { ChevronLeft } from "lucide-react";import Link from "next/link";import { PropsWithChildren, ReactNode } from "react";-import { HelpButtonRSC } from "../sidebar/help-button";-import UserDropdown from "../sidebar/user-dropdown";+import { HelpButton } from "../sidebar/help-button";+import { UserDropdown } from "../sidebar/user-dropdown";import { NavButton } from "./nav-button";/**@@ -73,7 +73,7 @@ export function PageContentOld({)}{showControls && (<div className="flex items-center gap-4 md:hidden">- <HelpButtonRSC />+ <HelpButton /><UserDropdown /></div>)}diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsxindex 287b005e15..d691136ef0 100644--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx@@ -23,7 +23,7 @@ import {useMemo,useState,} from "react";-import UserDropdown from "./user-dropdown";+import { UserDropdown } from "./user-dropdown";export type NavItemCommon = {name: string;diff --git a/apps/web/ui/layout/sidebar/user-dropdown.tsx b/apps/web/ui/layout/sidebar/user-dropdown.tsxindex 19804ccdde..ffc84490ef 100644--- a/apps/web/ui/layout/sidebar/user-dropdown.tsx+++ b/apps/web/ui/layout/sidebar/user-dropdown.tsx@@ -21,7 +21,7 @@ import {useState,} from "react";-export default function UserDropdown() {+export function UserDropdown() {const { data: session } = useSession();const { partner } = usePartnerProfile();const [openPopover, setOpenPopover] = useState(false);diff --git a/apps/web/ui/layout/toolbar/help-button.tsx b/apps/web/ui/layout/toolbar/help-button.tsxdeleted file mode 100644index 0db4e9032b..0000000000--- a/apps/web/ui/layout/toolbar/help-button.tsx+++ /dev/null@@ -1,54 +0,0 @@-"use client";--import { Popover } from "@dub/ui";-import { XIcon } from "lucide-react";-import { AnimatePresence, motion } from "motion/react";-import posthog from "posthog-js";-import { useState } from "react";-import { HelpArticle, HelpContext } from "../help";-import { HelpSection } from "../help/help-section";--export function HelpButton({- popularHelpArticles,- allHelpArticles,-}: {- popularHelpArticles: HelpArticle[];- allHelpArticles: HelpArticle[];-}) {- const [isOpen, setIsOpen] = useState(false);-- return (- <HelpContext.Provider value={{ popularHelpArticles, allHelpArticles }}>- <Popover- content={<HelpSection />}- openPopover={isOpen}- setOpenPopover={setIsOpen}- align="end"- >- <button- type="button"- onClick={() => {- if (!isOpen) {- posthog.capture("help_portal_opened");- }- setIsOpen((o) => !o);- }}- className="animate-fade-in font-lg relative h-12 w-12 overflow-hidden rounded-full border border-neutral-200 bg-white shadow-md active:bg-neutral-50"- >- <AnimatePresence>- <motion.div- key={isOpen ? "open" : "closed"}- className="absolute inset-0 flex items-center justify-center font-medium text-neutral-700 hover:text-neutral-700"- initial={{ opacity: 0, scale: 0 }}- animate={{ opacity: 1, scale: 1 }}- exit={{ opacity: 0, scale: 0 }}- transition={{ ease: "easeInOut", duration: 0.1 }}- >- {isOpen ? <XIcon className="h-4 w-4" strokeWidth={2} /> : "?"}- </motion.div>- </AnimatePresence>- </button>- </Popover>- </HelpContext.Provider>- );-}diff --git a/apps/web/ui/layout/toolbar/toolbar.tsx b/apps/web/ui/layout/toolbar/toolbar.tsxindex ddd23eb744..162e8f1451 100644--- a/apps/web/ui/layout/toolbar/toolbar.tsx+++ b/apps/web/ui/layout/toolbar/toolbar.tsx@@ -1,5 +1,4 @@-import { Suspense } from "react";-import { HelpButton } from "./help-button";+import { HelpButton } from "../sidebar/help-button";import { OnboardingButton } from "./onboarding/onboarding-button";const toolbarItems = ["onboarding", "help"] as const;@@ -10,43 +9,19 @@ type ToolbarProps = {export default function Toolbar(props: ToolbarProps) {return (- <Suspense fallback={null}>- <div className="fixed bottom-0 right-0 z-40 m-5">- <ToolbarRSC {...props} />+ <div className="fixed bottom-0 right-0 z-40 m-5">+ <div className="flex items-center gap-3">+ {props.show?.includes("onboarding") && (+ <div className="shrink-0">+ <OnboardingButton />+ </div>+ )}+ {props.show?.includes("help") && (+ <div className="shrink-0">+ <HelpButton />+ </div>+ )}</div>- </Suspense>- );-}--async function ToolbarRSC({ show = ["onboarding", "help"] }: ToolbarProps) {- const { popularHelpArticles, allHelpArticles } = await fetch(- "https://dub.co/api/content",- {- next: {- revalidate: 60 * 60 * 24, // cache for 24 hours- },- },- )- .then((res) => res.json())- .catch(() => {- return { popularHelpArticles: [], allHelpArticles: [] };- });-- return (- <div className="flex items-center gap-3">- {show.includes("onboarding") && (- <div className="shrink-0">- <OnboardingButton />- </div>- )}- {show.includes("help") && (- <div className="shrink-0">- <HelpButton- popularHelpArticles={popularHelpArticles}- allHelpArticles={allHelpArticles}- />- </div>- )}</div>);}