Skip to content

Commit 26ac991

Browse files
committed
add category backlinks from partner page
1 parent ab8309a commit 26ac991

2 files changed

Lines changed: 48 additions & 27 deletions

File tree

apps/web/ui/program-marketplace/marketplace-program-hero.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { NetworkProgramExtendedProps } from "@/lib/types";
44
import { marketplaceProgramDetailsColumnClassName } from "@/ui/program-marketplace/marketplace-program-details-layout";
55
import { ProgramCategory } from "@/ui/program-marketplace/program-category";
6+
import { getMarketplaceCategoryHref } from "@/ui/program-marketplace/utils/urls";
67
import { Globe } from "@dub/ui/icons";
78
import { OG_AVATAR_URL, cn, getDomainWithoutWWW } from "@dub/utils";
89
import Link from "next/link";
@@ -89,6 +90,7 @@ export function MarketplaceProgramHero({
8990
key={category}
9091
category={category}
9192
variant="surface"
93+
href={getMarketplaceCategoryHref(category)}
9294
/>
9395
))}
9496
</div>

apps/web/ui/program-marketplace/program-category.tsx

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ import { PROGRAM_CATEGORIES_MAP } from "@/lib/network/program-categories";
22
import { Category } from "@dub/prisma/client";
33
import { CircleInfo } from "@dub/ui";
44
import { cn } from "@dub/utils";
5+
import Link from "next/link";
56

67
export const programCategorySurfaceClassName =
78
"inline-flex h-5 max-h-5 min-w-0 items-center gap-1 rounded-full bg-neutral-900/[0.06] px-2 text-xs font-medium text-neutral-900 shadow-[0_0.5px_1px_0_rgba(0,0,0,0.03)] ring-1 ring-inset ring-neutral-900/[0.05] backdrop-blur-[3px] backdrop-saturate-150 transition-[background-color,transform] duration-150 ease-out [@media(hover:hover)]:hover:bg-neutral-900/[0.09] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 [@media(hover:none)]:hover:bg-neutral-900/[0.06]";
89

910
export const ProgramCategory = ({
1011
category,
1112
onClick,
13+
href,
1214
variant = "default",
1315
className,
1416
}: {
1517
category: Category;
1618
onClick?: () => void;
19+
href?: string;
1720
variant?: "default" | "pill" | "surface";
1821
className?: string;
1922
}) => {
@@ -23,33 +26,23 @@ export const ProgramCategory = ({
2326
label: category.replaceAll("_", " "),
2427
};
2528

26-
const As = onClick ? "button" : "div";
29+
const sharedClassName = cn(
30+
variant === "surface"
31+
? programCategorySurfaceClassName
32+
: variant === "pill"
33+
? "inline-flex min-w-0 items-center gap-1.5 rounded-full bg-neutral-100 px-2 py-0.5 text-xs font-medium text-neutral-600"
34+
: "text-content-default -ml-1 flex h-6 min-w-0 items-center gap-1 rounded-md px-1",
35+
(href || onClick) &&
36+
(variant === "pill"
37+
? "hover:bg-neutral-200/80 active:bg-neutral-200"
38+
: variant === "default"
39+
? "hover:bg-bg-subtle active:bg-bg-emphasis"
40+
: undefined),
41+
className,
42+
);
2743

28-
return (
29-
<As
30-
{...(onClick && {
31-
type: "button",
32-
onClick: (e) => {
33-
e.preventDefault();
34-
e.stopPropagation();
35-
onClick?.();
36-
},
37-
})}
38-
className={cn(
39-
variant === "surface"
40-
? programCategorySurfaceClassName
41-
: variant === "pill"
42-
? "inline-flex min-w-0 items-center gap-1.5 rounded-full bg-neutral-100 px-2 py-0.5 text-xs font-medium text-neutral-600"
43-
: "text-content-default -ml-1 flex h-6 min-w-0 items-center gap-1 rounded-md px-1",
44-
onClick &&
45-
(variant === "pill"
46-
? "hover:bg-neutral-200/80 active:bg-neutral-200"
47-
: variant === "default"
48-
? "hover:bg-bg-subtle active:bg-bg-emphasis"
49-
: undefined),
50-
className,
51-
)}
52-
>
44+
const content = (
45+
<>
5346
<Icon
5447
className={cn(
5548
"shrink-0",
@@ -72,6 +65,32 @@ export const ProgramCategory = ({
7265
>
7366
{label}
7467
</span>
75-
</As>
68+
</>
7669
);
70+
71+
if (href) {
72+
return (
73+
<Link href={href} className={sharedClassName}>
74+
{content}
75+
</Link>
76+
);
77+
}
78+
79+
if (onClick) {
80+
return (
81+
<button
82+
type="button"
83+
onClick={(e) => {
84+
e.preventDefault();
85+
e.stopPropagation();
86+
onClick?.();
87+
}}
88+
className={sharedClassName}
89+
>
90+
{content}
91+
</button>
92+
);
93+
}
94+
95+
return <div className={sharedClassName}>{content}</div>;
7796
};

0 commit comments

Comments
 (0)