perf: reduce widget and runtime overhead
This commit is contained in:
1 parent
5a7607ddf7
commit
14c7e58e17
33 files changed
+779
-339
No files matched your search
@@ -19,23 +19,35 @@ export function OverflowBadge({
|
||||
radius: "sm",
|
||||
...props,
|
||||
};
|
||||
return (
|
||||
<Popover width="content" shadow="md" disabled={disablePopover}>
|
||||
|
||||
const hasOverflow = data.length > overflowCount;
|
||||
const badges = data.slice(0, overflowCount).map((item) => (
|
||||
<Badge key={item} px="xs" {...badgeProps}>
|
||||
{item}
|
||||
</Badge>
|
||||
));
|
||||
const overflowTrigger = hasOverflow ? (
|
||||
<UnstyledButton display="flex">
|
||||
<Badge px="xs" style={{ cursor: "pointer", ...badgeProps.style }} {...badgeProps}>
|
||||
+{data.length - overflowCount}
|
||||
</Badge>
|
||||
</UnstyledButton>
|
||||
) : null;
|
||||
|
||||
if (disablePopover || !hasOverflow) {
|
||||
return (
|
||||
<Group gap={groupGap}>
|
||||
{data.slice(0, overflowCount).map((item) => (
|
||||
<Badge key={item} px="xs" {...badgeProps}>
|
||||
{item}
|
||||
</Badge>
|
||||
))}
|
||||
{data.length > overflowCount && (
|
||||
<Popover.Target>
|
||||
<UnstyledButton display="flex">
|
||||
<Badge px="xs" style={{ cursor: "pointer", ...badgeProps.style }} {...badgeProps}>
|
||||
+{data.length - overflowCount}
|
||||
</Badge>
|
||||
</UnstyledButton>
|
||||
</Popover.Target>
|
||||
)}
|
||||
{badges}
|
||||
{overflowTrigger}
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover width="content" shadow="md">
|
||||
<Group gap={groupGap}>
|
||||
{badges}
|
||||
<Popover.Target>{overflowTrigger}</Popover.Target>
|
||||
</Group>
|
||||
<Popover.Dropdown>
|
||||
<Stack>
|
||||
|
||||
Reference in new issue
Block a user