Skip to content

Commit 94fb773

Browse files
committed
PERFORMANCE_SCOPE_DESCRIPTIONS
1 parent 34821bc commit 94fb773

2 files changed

Lines changed: 75 additions & 17 deletions

File tree

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-logic.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { Controller } from "react-hook-form";
1313
import { BountyAmountInput } from "./bounty-amount-input";
1414
import { useBountyFormContext } from "./bounty-form-context";
1515

16+
const PERFORMANCE_SCOPE_DESCRIPTIONS = {
17+
new: "Only net-new stats after the bounty start date will be counted",
18+
lifetime: "Include the partner's historical stats in your program",
19+
} as const;
20+
1621
export function BountyLogic({ className }: { className?: string }) {
1722
const { control, watch } = useBountyFormContext();
1823

@@ -33,13 +38,25 @@ export function BountyLogic({ className }: { className?: string }) {
3338
control={control}
3439
name="performanceScope"
3540
render={({ field }) => (
36-
<InlineBadgePopover text={field.value} invalid={!field.value}>
41+
<InlineBadgePopover
42+
text={field.value}
43+
invalid={!field.value}
44+
align="center"
45+
>
3746
<InlineBadgePopoverMenu
3847
selectedValue={field.value}
3948
onSelect={field.onChange}
4049
items={[
41-
{ text: "new", value: "new" },
42-
{ text: "lifetime", value: "lifetime" },
50+
{
51+
text: "new",
52+
value: "new",
53+
description: PERFORMANCE_SCOPE_DESCRIPTIONS.new,
54+
},
55+
{
56+
text: "lifetime",
57+
value: "lifetime",
58+
description: PERFORMANCE_SCOPE_DESCRIPTIONS.lifetime,
59+
},
4360
]}
4461
/>
4562
</InlineBadgePopover>
@@ -58,6 +75,7 @@ export function BountyLogic({ className }: { className?: string }) {
5875
: "activity"
5976
}
6077
invalid={!field.value}
78+
align="center"
6179
>
6280
<InlineBadgePopoverMenu
6381
selectedValue={field.value}

apps/web/ui/shared/inline-badge-popover.tsx

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
MarkdownIcon,
88
Plus,
99
Popover,
10+
PopoverProps,
1011
RichTextArea,
1112
RichTextProvider,
1213
RichTextToolbar,
@@ -41,6 +42,7 @@ export function InlineBadgePopover({
4142
text,
4243
invalid,
4344
showOptional,
45+
align = "start",
4446
disabled,
4547
children,
4648
buttonClassName,
@@ -49,6 +51,7 @@ export function InlineBadgePopover({
4951
text: ReactNode;
5052
invalid?: boolean;
5153
showOptional?: boolean;
54+
align?: PopoverProps["align"];
5255
disabled?: boolean;
5356
buttonClassName?: string;
5457
contentClassName?: string;
@@ -59,7 +62,7 @@ export function InlineBadgePopover({
5962
<Popover
6063
openPopover={isOpen}
6164
setOpenPopover={setIsOpen}
62-
align="start"
65+
align={align}
6366
content={
6467
<InlineBadgePopoverContext.Provider value={{ isOpen, setIsOpen }}>
6568
<AnimatedSizeContainer height width>
@@ -95,9 +98,10 @@ export function InlineBadgePopover({
9598
);
9699
}
97100

98-
type MenuItem<T> = {
101+
export type InlineBadgePopoverMenuItem<T> = {
99102
icon?: ReactNode;
100103
text: string;
104+
description?: string;
101105
value: T;
102106
onSelect?: () => void;
103107
preventClose?: boolean;
@@ -109,7 +113,7 @@ export function InlineBadgePopoverMenu<T extends any>({
109113
selectedValue,
110114
search,
111115
}: {
112-
items: MenuItem<T>[];
116+
items: InlineBadgePopoverMenuItem<T>[];
113117
onSelect?: (value: T) => void;
114118
selectedValue?: T | T[];
115119
search?: boolean;
@@ -146,7 +150,9 @@ export function InlineBadgePopoverMenu<T extends any>({
146150
);
147151

148152
const [displayedItems, setDisplayedItems] =
149-
useState<MenuItem<T>[]>(sortedItems);
153+
useState<InlineBadgePopoverMenuItem<T>[]>(sortedItems);
154+
155+
const hasDescriptions = items.some((item) => item.description);
150156

151157
// Update the displayed items to sorted when closed
152158
useEffect(() => {
@@ -166,32 +172,66 @@ export function InlineBadgePopoverMenu<T extends any>({
166172
<AnimatedSizeContainer height>
167173
<div className="relative">
168174
<Command.List
169-
className="scrollbar-hide flex max-h-64 max-w-52 flex-col gap-1 overflow-y-auto transition-all"
175+
className={cn(
176+
"scrollbar-hide flex max-h-64 flex-col gap-1 overflow-y-auto transition-all",
177+
hasDescriptions ? "max-w-72" : "max-w-52",
178+
)}
170179
ref={scrollRef}
171180
onScroll={updateScrollProgress}
172181
>
173182
{displayedItems.map(
174-
({ icon, text, value, onSelect: itemOnSelect, preventClose }) => (
183+
({
184+
icon,
185+
text,
186+
description,
187+
value,
188+
onSelect: itemOnSelect,
189+
preventClose,
190+
}) => (
175191
<Command.Item
176-
key={text}
177-
value={`${text} ${value}`}
192+
key={String(value)}
193+
value={`${text} ${description ?? ""} ${value}`}
178194
onSelect={() => {
179195
itemOnSelect?.();
180196
onSelect?.(value);
181197
!isMultiSelect && !preventClose && setIsOpen(false);
182198
}}
183-
className="flex cursor-pointer items-center justify-between rounded-md px-1.5 py-1 transition-colors duration-150 data-[selected=true]:bg-neutral-100"
199+
className={cn(
200+
"flex cursor-pointer justify-between rounded-md px-1.5 py-1 transition-colors duration-150 data-[selected=true]:bg-neutral-100",
201+
description ? "items-start gap-2 py-1.5" : "items-center",
202+
)}
184203
>
185-
<div className="flex items-center gap-2">
204+
<div
205+
className={cn(
206+
"flex min-w-0 gap-2",
207+
description ? "items-start" : "items-center",
208+
)}
209+
>
186210
{icon}
187-
<span className="text-content-default pr-3 text-left text-sm font-medium">
188-
{text}
189-
</span>
211+
{description ? (
212+
<div className="flex min-w-0 flex-col gap-0.5 pr-2">
213+
<span className="text-content-default text-left text-sm font-medium">
214+
{text}
215+
</span>
216+
<span className="text-content-subtle text-left text-xs font-normal leading-snug">
217+
{description}
218+
</span>
219+
</div>
220+
) : (
221+
<span className="text-content-default pr-3 text-left text-sm font-medium">
222+
{text}
223+
</span>
224+
)}
190225
</div>
191226
{(Array.isArray(selectedValue)
192227
? selectedValue.includes(value)
193228
: selectedValue === value) && (
194-
<Check2 className="text-content-emphasis size-3.5 shrink-0" />
229+
<Check2
230+
className={cn(
231+
"text-content-emphasis size-3.5 shrink-0",
232+
description && "mt-0.5",
233+
)}
234+
/>
195235
)}
196236
</Command.Item>
197237
),

0 commit comments

Comments
 (0)