Skip to content

Commit 330c63f

Browse files
authored
fix: prevent Nudge hover card to hide while hover (#1067)
fix: drop ariakit hovercard
1 parent 0bf6d75 commit 330c63f

1 file changed

Lines changed: 55 additions & 47 deletions

File tree

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { Hovercard, HovercardAnchor, HovercardProvider } from '@ariakit/react/hovercard';
1+
import {
2+
HoverCard,
3+
HoverCardContent,
4+
HoverCardPortal,
5+
HoverCardTrigger,
6+
} from '@radix-ui/react-hover-card';
27
import { type FeatureAccessLevelDto } from 'marble-api/generated/feature-access-api';
38
import { useTranslation } from 'react-i18next';
49
import { match } from 'ts-pattern';
@@ -17,8 +22,8 @@ export const Nudge = ({ content, link, className, kind = 'restricted', iconClass
1722
const { t } = useTranslation(['common']);
1823

1924
return (
20-
<HovercardProvider showTimeout={0} hideTimeout={0} placement="right">
21-
<HovercardAnchor
25+
<HoverCard>
26+
<HoverCardTrigger
2227
tabIndex={-1}
2328
className={cn(
2429
'text-grey-100 flex flex-row items-center justify-center rounded-sm',
@@ -27,7 +32,6 @@ export const Nudge = ({ content, link, className, kind = 'restricted', iconClass
2732
{ 'bg-yellow-50': kind === 'missing_configuration' },
2833
className,
2934
)}
30-
render={<div />}
3135
>
3236
<Icon
3337
icon={match<typeof kind, IconName>(kind)
@@ -38,55 +42,59 @@ export const Nudge = ({ content, link, className, kind = 'restricted', iconClass
3842
className={cn('size-3.5', iconClass)}
3943
aria-hidden
4044
/>
41-
</HovercardAnchor>
42-
<Hovercard
43-
portal
44-
gutter={8}
45-
className={cn(
46-
'bg-grey-100 z-50 flex w-60 flex-col items-center gap-6 rounded-sm border p-4 shadow-lg',
47-
{
48-
'border-purple-82': kind !== 'missing_configuration',
49-
'border-yellow-50': kind === 'missing_configuration',
50-
},
51-
)}
52-
>
53-
<span className="text-m font-bold">
54-
{match<typeof kind, string>(kind)
55-
.with('missing_configuration', () => t('common:missing_configuration_title'))
56-
.otherwise(() => t('common:premium'))}
57-
</span>
58-
<div className="flex w-full flex-col items-center gap-2">
59-
<p className="text-s w-full text-center font-medium">
45+
</HoverCardTrigger>
46+
<HoverCardPortal>
47+
<HoverCardContent
48+
side="right"
49+
align="start"
50+
sideOffset={8}
51+
alignOffset={-8}
52+
className={cn(
53+
'bg-grey-100 z-50 flex w-60 flex-col items-center gap-6 rounded-sm border p-4 shadow-lg',
54+
{
55+
'border-purple-82': kind !== 'missing_configuration',
56+
'border-yellow-50': kind === 'missing_configuration',
57+
},
58+
)}
59+
>
60+
<span className="text-m font-bold">
6061
{match<typeof kind, string>(kind)
61-
.with('missing_configuration', () => t('common:missing_configuration'))
62-
.otherwise(() => content)}
63-
</p>
64-
{link ? (
62+
.with('missing_configuration', () => t('common:missing_configuration_title'))
63+
.otherwise(() => t('common:premium'))}
64+
</span>
65+
<div className="flex w-full flex-col items-center gap-2">
66+
<p className="text-s w-full text-center font-medium">
67+
{match<typeof kind, string>(kind)
68+
.with('missing_configuration', () => t('common:missing_configuration'))
69+
.otherwise(() => content)}
70+
</p>
71+
{link ? (
72+
<a
73+
className="text-s text-purple-65 inline-block w-full text-center hover:underline"
74+
target="_blank"
75+
rel="noreferrer"
76+
href={link}
77+
>
78+
{t('common:check_on_docs')}
79+
</a>
80+
) : null}
81+
</div>
82+
{kind !== 'missing_configuration' ? (
6583
<a
66-
className="text-s text-purple-65 inline-block w-full text-center hover:underline"
84+
className={CtaClassName({
85+
variant: 'primary',
86+
color: 'purple',
87+
className: 'mt-4 text-center',
88+
})}
89+
href="https://checkmarble.com/upgrade"
6790
target="_blank"
6891
rel="noreferrer"
69-
href={link}
7092
>
71-
{t('common:check_on_docs')}
93+
{t('common:upgrade')}
7294
</a>
7395
) : null}
74-
</div>
75-
{kind !== 'missing_configuration' ? (
76-
<a
77-
className={CtaClassName({
78-
variant: 'primary',
79-
color: 'purple',
80-
className: 'mt-4 text-center',
81-
})}
82-
href="https://checkmarble.com/upgrade"
83-
target="_blank"
84-
rel="noreferrer"
85-
>
86-
{t('common:upgrade')}
87-
</a>
88-
) : null}
89-
</Hovercard>
90-
</HovercardProvider>
96+
</HoverCardContent>
97+
</HoverCardPortal>
98+
</HoverCard>
9199
);
92100
};

0 commit comments

Comments
 (0)