Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add `BackLink` component

Tim Wilsone927a55a5c71
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/manage/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/manage/page.tsx
index 4175f10d0e..57014035c2 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/manage/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/manage/page.tsx
@@ -1,8 +1,7 @@
import AddEditIntegrationForm from "@/ui/oauth-apps/add-edit-integration-form";
+import { BackLink } from "@/ui/shared/back-link";
import { prisma } from "@dub/prisma";
import { MaxWidthWrapper } from "@dub/ui";
-import { ChevronLeft } from "lucide-react";
-import Link from "next/link";
import { notFound } from "next/navigation";
export default async function IntegrationManagePage({
@@ -25,15 +24,9 @@ export default async function IntegrationManagePage({
}
return (
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <Link
- href={`/${params.slug}/settings/integrations`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">
- Back to integrations
- </p>
- </Link>
+ <BackLink href={`/${params.slug}/settings/integrations`}>
+ Back to integrations
+ </BackLink>
<AddEditIntegrationForm
integration={{
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/new/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/new/page.tsx
index be0e39ab53..70efe32f5d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/new/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/new/page.tsx
@@ -1,7 +1,6 @@
import AddEditIntegrationForm from "@/ui/oauth-apps/add-edit-integration-form";
+import { BackLink } from "@/ui/shared/back-link";
import { MaxWidthWrapper } from "@dub/ui";
-import { ChevronLeft } from "lucide-react";
-import Link from "next/link";
import { notFound } from "next/navigation";
export default function NewIntegrationsPage({
@@ -16,15 +15,9 @@ export default function NewIntegrationsPage({
}
return (
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <Link
- href={`/${params.slug}/settings/integrations`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">
- Back to integrations
- </p>
- </Link>
+ <BackLink href={`/${params.slug}/settings/integrations`}>
+ Back to integrations
+ </BackLink>
<AddEditIntegrationForm
integration={{
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
index 8830bf7373..4e49dfb825 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
@@ -8,6 +8,7 @@ import { useRemoveOAuthAppModal } from "@/ui/modals/remove-oauth-app-modal";
import { useSubmitOAuthAppModal } from "@/ui/modals/submit-oauth-app-modal";
import AddOAuthAppForm from "@/ui/oauth-apps/add-edit-app-form";
import OAuthAppCredentials from "@/ui/oauth-apps/oauth-app-credentials";
+import { BackLink } from "@/ui/shared/back-link";
import { ThreeDots } from "@/ui/shared/icons";
import {
BlurImage,
@@ -17,9 +18,8 @@ import {
TokenAvatar,
} from "@dub/ui";
import { fetcher } from "@dub/utils";
-import { ChevronLeft, RefreshCcw, Trash, Upload } from "lucide-react";
+import { RefreshCcw, Trash, Upload } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
import { notFound, useSearchParams } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
@@ -67,15 +67,9 @@ export default function OAuthAppManagePageClient({ appId }: { appId: string }) {
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
<RemoveOAuthAppModal />
<SubmitOAuthAppModal />
- <Link
- href={`/${slug}/settings/oauth-apps`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">
- Back to OAuth Apps
- </p>
- </Link>
+ <BackLink href={`/${slug}/settings/oauth-apps`}>
+ Back to OAuth Apps
+ </BackLink>
<div className="flex justify-between gap-2 sm:items-center">
{isLoading ? (
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
index 50ed9e706e..5dd8151bc6 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
@@ -3,9 +3,8 @@
import { clientAccessCheck } from "@/lib/api/tokens/permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import AddOAuthAppForm from "@/ui/oauth-apps/add-edit-app-form";
+import { BackLink } from "@/ui/shared/back-link";
import { MaxWidthWrapper } from "@dub/ui";
-import { ChevronLeft } from "lucide-react";
-import Link from "next/link";
import { redirect } from "next/navigation";
export default function NewOAuthAppPageClient() {
@@ -23,15 +22,9 @@ export default function NewOAuthAppPageClient() {
return (
<>
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <Link
- href={`/${slug}/settings/oauth-apps`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">
- Back to OAuth Apps
- </p>
- </Link>
+ <BackLink href={`/${slug}/settings/oauth-apps`}>
+ Back to OAuth Apps
+ </BackLink>
</MaxWidthWrapper>
<MaxWidthWrapper className="max-w-screen-lg space-y-6">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx
index f1f14c9a00..cfa60ea92d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx
@@ -1,10 +1,9 @@
"use client";
import useWorkspace from "@/lib/swr/use-workspace";
+import { BackLink } from "@/ui/shared/back-link";
import AddEditWebhookForm from "@/ui/webhooks/add-edit-webhook-form";
import { MaxWidthWrapper } from "@dub/ui";
-import { ChevronLeft } from "lucide-react";
-import Link from "next/link";
import { redirect } from "next/navigation";
export default function NewWebhookPageClient({
@@ -23,13 +22,9 @@ export default function NewWebhookPageClient({
return (
<>
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <Link
- href={`/${slug}/settings/webhooks`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">Back to webhooks</p>
- </Link>
+ <BackLink href={`/${slug}/settings/webhooks`}>
+ Back to webhooks
+ </BackLink>
</MaxWidthWrapper>
<MaxWidthWrapper className="max-w-screen-lg space-y-6">
diff --git a/apps/web/ui/shared/back-link.tsx b/apps/web/ui/shared/back-link.tsx
new file mode 100644
index 0000000000..4350ad100a
--- /dev/null
+++ b/apps/web/ui/shared/back-link.tsx
@@ -0,0 +1,26 @@
+import { cn } from "@dub/utils";
+import { ChevronLeft } from "lucide-react";
+import Link from "next/link";
+import { ComponentProps } from "react";
+
+export function BackLink({
+ children,
+ className,
+ ...rest
+}: ComponentProps<typeof Link>) {
+ return (
+ <Link
+ className={cn(
+ "group flex items-center gap-1 text-neutral-600 transition-colors duration-100 hover:text-neutral-700",
+ className,
+ )}
+ {...rest}
+ >
+ <ChevronLeft
+ className="size-3.5 transition-transform duration-100 group-hover:-translate-x-0.5"
+ strokeWidth={2}
+ />
+ <span className="text-sm">{children}</span>
+ </Link>
+ );
+}
diff --git a/apps/web/ui/webhooks/webhook-header.tsx b/apps/web/ui/webhooks/webhook-header.tsx
index 138c215672..03ebce5050 100644
--- a/apps/web/ui/webhooks/webhook-header.tsx
+++ b/apps/web/ui/webhooks/webhook-header.tsx
@@ -15,14 +15,14 @@ import {
TokenAvatar,
useCopyToClipboard,
} from "@dub/ui";
-import { ChevronLeft, CircleX, Send, Trash } from "lucide-react";
+import { CircleX, Send, Trash } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
import { notFound, useRouter, useSelectedLayoutSegment } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
import { useDeleteWebhookModal } from "../modals/delete-webhook-modal";
import { useSendTestWebhookModal } from "../modals/send-test-webhook-modal";
+import { BackLink } from "../shared/back-link";
import { WebhookStatus } from "./webhook-status";
export default function WebhookHeader({ webhookId }: { webhookId: string }) {
@@ -84,13 +84,9 @@ export default function WebhookHeader({ webhookId }: { webhookId: string }) {
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
<SendTestWebhookModal />
<DeleteWebhookModal />
- <Link
- href={`/${slug}/settings/webhooks`}
- className="flex items-center gap-x-1"
- >
- <ChevronLeft className="size-4" />
- <p className="text-sm font-medium text-gray-500">Back to webhooks</p>
- </Link>
+ <BackLink href={`/${slug}/settings/webhooks`}>
+ Back to webhooks
+ </BackLink>
<div className="flex justify-between gap-8 sm:items-center">
{isLoading || !webhook ? (
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">