-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathListingTabs.tsx
More file actions
92 lines (85 loc) · 2.62 KB
/
Copy pathListingTabs.tsx
File metadata and controls
92 lines (85 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { ExternalImage } from '@/components/ui/cloudinary-image';
import { cn } from '@/utils/cn';
import { HACKATHONS } from '@/features/hackathon/constants/hackathons';
import { type ListingContext, type ListingTab } from '../hooks/useListings';
const TABS = [
{ id: 'all', title: 'All', posthog: 'all_listings' },
{ id: 'bounties', title: 'Bounties', posthog: 'bounties_listings' },
{ id: 'projects', title: 'Projects', posthog: 'projects_listings' },
] as const;
interface ListingTabTriggerProps {
isActive: boolean;
onClick: () => void;
children: React.ReactNode;
isPro?: boolean;
}
const ListingTabTrigger = ({
isActive,
onClick,
children,
isPro,
}: ListingTabTriggerProps) => (
<button
onClick={onClick}
className={cn(
'group ring-offset-background relative inline-flex items-center justify-center rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-all',
isPro ? 'hover:text-zinc-700' : 'hover:text-brand-purple',
isActive && [
isPro ? 'text-zinc-700' : 'text-brand-purple',
isPro
? 'after:absolute after:bottom-[-5px] after:left-0 after:h-px after:w-full after:bg-zinc-700 md:after:bottom-[-9px]'
: 'after:bg-brand-purple/80 after:absolute after:bottom-[-5px] after:left-0 after:h-px after:w-full md:after:bottom-[-9px]',
],
!isActive && 'text-slate-500',
)}
>
{children}
</button>
);
interface ListingTabsProps {
type: ListingContext;
activeTab: ListingTab;
handleTabChange: (tabId: ListingTab, posthog: string) => void;
isPro?: boolean;
}
export const ListingTabs = ({
type,
activeTab,
handleTabChange,
isPro,
}: ListingTabsProps) => {
return (
<div className="flex items-center gap-2">
{TABS.map((tab) => (
<ListingTabTrigger
isPro={isPro}
key={tab.id}
isActive={activeTab === tab.id}
onClick={() => handleTabChange(tab.id, tab.posthog)}
>
<span>{tab.title}</span>
</ListingTabTrigger>
))}
{type === 'home' &&
HACKATHONS.map((hackathon) => (
<ListingTabTrigger
isPro={isPro}
key={hackathon.slug}
isActive={activeTab === hackathon.slug}
onClick={() =>
handleTabChange(
hackathon.slug as ListingTab,
`${hackathon.slug}_navpill`,
)
}
>
<ExternalImage
src={hackathon.logo}
alt={hackathon.label}
className="my-[0.10rem] h-3 scale-90 object-contain"
/>
</ListingTabTrigger>
))}
</div>
);
};