🧹 Remove legacy tooltip (#838)

This commit is contained in:
Luke Vella 2023-09-05 18:06:08 +01:00 committed by GitHub
parent 7a49c18477
commit 7e3932d99f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 42 deletions

View file

@ -7,7 +7,6 @@ import { DateIcon } from "@/components/date-icon";
import { ParticipantAvatarBar } from "@/components/participant-avatar-bar"; import { ParticipantAvatarBar } from "@/components/participant-avatar-bar";
import { useParticipants } from "@/components/participants-provider"; import { useParticipants } from "@/components/participants-provider";
import { PollStatusBadge } from "@/components/poll-status"; import { PollStatusBadge } from "@/components/poll-status";
import { TextSummary } from "@/components/text-summary";
import { Trans } from "@/components/trans"; import { Trans } from "@/components/trans";
import { IfParticipantsVisible } from "@/components/visibility"; import { IfParticipantsVisible } from "@/components/visibility";
import { usePoll } from "@/contexts/poll"; import { usePoll } from "@/contexts/poll";
@ -110,10 +109,8 @@ export const EventCard = () => {
{poll.description ? ( {poll.description ? (
<div className="flex gap-4"> <div className="flex gap-4">
<TextIcon className="h-4 w-4 shrink-0 translate-y-1" /> <TextIcon className="h-4 w-4 shrink-0 translate-y-1" />
<div className="border-primary whitespace-pre-line leading-relaxed"> <div className="whitespace-pre-line leading-relaxed">
<TruncatedLinkify> <TruncatedLinkify>{poll.description}</TruncatedLinkify>
<TextSummary text={preventWidows(poll.description)} />
</TruncatedLinkify>
</div> </div>
</div> </div>
) : null} ) : null}

View file

@ -2,11 +2,10 @@ import { trpc } from "@rallly/backend";
import { HelpCircleIcon } from "@rallly/icons"; import { HelpCircleIcon } from "@rallly/icons";
import { cn } from "@rallly/ui"; import { cn } from "@rallly/ui";
import { Button } from "@rallly/ui/button"; import { Button } from "@rallly/ui/button";
import { TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip"; import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip";
import Script from "next/script"; import Script from "next/script";
import React from "react"; import React from "react";
import Tooltip from "@/components/tooltip";
import { Trans } from "@/components/trans"; import { Trans } from "@/components/trans";
import { isFeedbackEnabled } from "@/utils/constants"; import { isFeedbackEnabled } from "@/utils/constants";

View file

@ -1,9 +1,8 @@
import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip";
import Link from "next/link"; import Link from "next/link";
import * as React from "react"; import * as React from "react";
import ReactLinkify from "react-linkify"; import ReactLinkify from "react-linkify";
import LegacyTooltip from "../tooltip";
export const truncateLink = (href: string, text: string, key: number) => { export const truncateLink = (href: string, text: string, key: number) => {
const textWithoutProtocol = text.replace(/^https?:\/\//i, ""); const textWithoutProtocol = text.replace(/^https?:\/\//i, "");
const beginningOfPath = textWithoutProtocol.indexOf("/"); const beginningOfPath = textWithoutProtocol.indexOf("/");
@ -17,6 +16,7 @@ export const truncateLink = (href: string, text: string, key: number) => {
<Link <Link
className="text-link" className="text-link"
key={key} key={key}
target="_blank"
href={href} href={href}
rel="nofollow noreferrer" rel="nofollow noreferrer"
> >
@ -26,16 +26,21 @@ export const truncateLink = (href: string, text: string, key: number) => {
} else { } else {
finalText += "…"; finalText += "…";
return ( return (
<LegacyTooltip <Tooltip>
key={key} <TooltipTrigger asChild>
content={ <Link
<div className="max-w-md break-all font-mono text-xs">{href}</div> className="text-link"
} target="_blank"
> href={href}
<Link className="text-link" href={href} rel="nofollow noreferrer"> rel="nofollow noreferrer"
{finalText} >
</Link> {finalText}
</LegacyTooltip> </Link>
</TooltipTrigger>
<TooltipContent className="max-w-md break-all font-mono text-xs">
{href}
</TooltipContent>
</Tooltip>
); );
} }
}; };

View file

@ -1,23 +0,0 @@
import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip";
import * as React from "react";
export interface TooltipProps {
children?: React.ReactNode;
content?: React.ReactNode;
className?: string;
}
const LegacyTooltip: React.FunctionComponent<TooltipProps> = ({
className,
children,
content,
}) => {
return (
<Tooltip>
<TooltipTrigger className={className}>{children}</TooltipTrigger>
<TooltipContent>{content}</TooltipContent>
</Tooltip>
);
};
export default React.memo(LegacyTooltip);