Skip to content

Commit 6f18466

Browse files
committed
feat: add tooltip for website share feature when feed is disabled
1 parent 0803aae commit 6f18466

3 files changed

Lines changed: 46 additions & 23 deletions

File tree

src/client/components/ui/tooltip.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ const TooltipContent = React.forwardRef<
2525
));
2626
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
2727

28+
interface SimpleTooltipProps {
29+
children: React.ReactNode;
30+
content: React.ReactNode;
31+
tooltipProps?: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>;
32+
}
33+
2834
export const SimpleTooltip = React.memo(
29-
({
30-
children,
31-
content,
32-
}: {
33-
children: React.ReactNode;
34-
content: React.ReactNode;
35-
}) => {
35+
({ children, content, tooltipProps }: SimpleTooltipProps) => {
3636
return (
37-
<Tooltip>
37+
<Tooltip {...tooltipProps}>
3838
<TooltipTrigger>{children}</TooltipTrigger>
3939
<TooltipContent>{content}</TooltipContent>
4040
</Tooltip>

src/client/routes/feed/$channelId/index.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { toast } from 'sonner';
3434
import { FeedStateList } from '@/components/feed/FeedStateList';
3535
import copy from 'copy-to-clipboard';
3636
import {
37+
SimpleTooltip,
3738
Tooltip,
3839
TooltipContent,
3940
TooltipProvider,
@@ -153,21 +154,17 @@ function PageComponent() {
153154
}}
154155
/>
155156
) : (
156-
<TooltipProvider delayDuration={0}>
157-
<Tooltip>
158-
<TooltipTrigger className="cursor-not-allowed">
159-
<Button
160-
variant="outline"
161-
size="icon"
162-
Icon={LuShare2}
163-
disabled
164-
/>
165-
</TooltipTrigger>
166-
<TooltipContent side="bottom">
167-
{t('Public share is disabled for this feed')}
168-
</TooltipContent>
169-
</Tooltip>
170-
</TooltipProvider>
157+
<SimpleTooltip
158+
content={t('Public share is disabled for this feed')}
159+
tooltipProps={{ delayDuration: 0 }}
160+
>
161+
<Button
162+
variant="outline"
163+
size="icon"
164+
Icon={LuShare2}
165+
disabled
166+
/>
167+
</SimpleTooltip>
171168
)}
172169

173170
<Button

src/client/routes/website/$websiteId/index.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { LuCompass, LuSettings, LuShare2 } from 'react-icons/lu';
2525
import copy from 'copy-to-clipboard';
2626
import { toast } from 'sonner';
2727
import { useMemo } from 'react';
28+
import { SimpleTooltip } from '@/components/ui/tooltip';
2829

2930
export const Route = createFileRoute('/website/$websiteId/')({
3031
beforeLoad: routeAuthBeforeLoad,
@@ -111,6 +112,31 @@ function PageComponent() {
111112
/>
112113
)}
113114

115+
{website.shareId ? (
116+
<Button
117+
size="icon"
118+
variant="outline"
119+
Icon={LuShare2}
120+
onClick={() => {
121+
copy(shareLink);
122+
toast.success(t('Public share link copied to clipboard'));
123+
}}
124+
aria-label={t('Public share link copied to clipboard')}
125+
/>
126+
) : (
127+
<SimpleTooltip
128+
content={t('Public share is disabled for this website')}
129+
tooltipProps={{ delayDuration: 0 }}
130+
>
131+
<Button
132+
variant="outline"
133+
size="icon"
134+
Icon={LuShare2}
135+
disabled
136+
/>
137+
</SimpleTooltip>
138+
)}
139+
114140
<WebsiteCodeBtn websiteId={website.id} />
115141
</div>
116142
}

0 commit comments

Comments
 (0)