| ... | @@ -15,6 +15,7 @@ import { useAtomQueryRunner } from "~/state/use-atom-query-runner"; | ... | @@ -15,6 +15,7 @@ import { useAtomQueryRunner } from "~/state/use-atom-query-runner"; |
| 15 | import { useEnvironmentQuery } from "~/state/query"; | 15 | import { useEnvironmentQuery } from "~/state/query"; |
| 16 | | 16 | |
| 17 | import { PreviewCard, PreviewCardPopup, PreviewCardTrigger } from "../ui/preview-card"; | 17 | import { PreviewCard, PreviewCardPopup, PreviewCardTrigger } from "../ui/preview-card"; |
| | 18 | import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; |
| 18 | import { PullRequestActorAvatar, resolvePullRequestState } from "./pullRequestPresentation"; | 19 | import { PullRequestActorAvatar, resolvePullRequestState } from "./pullRequestPresentation"; |
| 19 | | 20 | |
| 20 | interface PullRequestLinkPreviewTarget { | 21 | interface PullRequestLinkPreviewTarget { |
| ... | @@ -81,6 +82,8 @@ export function PullRequestLinkPreview({ | ... | @@ -81,6 +82,8 @@ export function PullRequestLinkPreview({ |
| 81 | }) | 82 | }) |
| 82 | : link; | 83 | : link; |
| 83 | const detail = detailQuery.data; | 84 | const detail = detailQuery.data; |
| | 85 | const showCard = detail !== null || (detailQuery.error !== null && fallback !== undefined); |
| | 86 | const showUrlTooltip = open && detailQuery.error !== null && !showCard; |
| 84 | const state = | 87 | const state = |
| 85 | detail === null | 88 | detail === null |
| 86 | ? null | 89 | ? null |
| ... | @@ -94,16 +97,19 @@ export function PullRequestLinkPreview({ | ... | @@ -94,16 +97,19 @@ export function PullRequestLinkPreview({ |
| 94 | | 97 | |
| 95 | return ( | 98 | return ( |
| 96 | <PreviewCard open={open} onOpenChange={setOpen}> | 99 | <PreviewCard open={open} onOpenChange={setOpen}> |
| 97 | <PreviewCardTrigger render={trigger} delay={350} closeDelay={120} /> | 100 | <Tooltip open={showUrlTooltip}> |
| 98 | {detail !== null || detailQuery.error !== null ? ( | 101 | <PreviewCardTrigger |
| | 102 | render={<TooltipTrigger render={trigger} />} |
| | 103 | delay={350} |
| | 104 | closeDelay={120} |
| | 105 | /> |
| | 106 | <TooltipPopup side="top">{originalUrl}</TooltipPopup> |
| | 107 | </Tooltip> |
| | 108 | {showCard ? ( |
| 99 | <PreviewCardPopup align="center" className="w-80 max-w-[calc(100vw-2rem)]"> | 109 | <PreviewCardPopup align="center" className="w-80 max-w-[calc(100vw-2rem)]"> |
| 100 | <div className="p-3"> | 110 | <div className="p-3"> |
| 101 | {detail === null ? ( | 111 | {detail === null ? ( |
| 102 | (fallback ?? ( | 112 | fallback |
| 103 | <p className="text-xs leading-relaxed text-muted-foreground wrap-anywhere"> | | |
| 104 | {originalUrl} | | |
| 105 | </p> | | |
| 106 | )) | | |
| 107 | ) : ( | 113 | ) : ( |
| 108 | <div className="min-w-0"> | 114 | <div className="min-w-0"> |
| 109 | <div className="flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground"> | 115 | <div className="flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground"> |