-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathGuideHoverCard.tsx
More file actions
63 lines (58 loc) · 1.45 KB
/
GuideHoverCard.tsx
File metadata and controls
63 lines (58 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as HoverCard from "@radix-ui/react-hover-card";
import { Box, Stack } from "@telegraph/layout";
import * as React from "react";
import {
AnnotatedGuide,
UnknownGuide,
isUnknownGuide,
} from "./useInspectGuideClientStore";
type Props = {
guide: AnnotatedGuide | UnknownGuide;
};
export const GuideHoverCard = ({
children,
guide,
}: React.PropsWithChildren<Props>) => {
if (isUnknownGuide(guide)) {
return <Stack align="center">{children}</Stack>;
}
// Prune out internal or legacy fields.
const {
annotation: _annotation,
activation_location_rules: _activation_location_rules,
priority: _priority,
...rest
} = guide;
return (
<HoverCard.Root>
<HoverCard.Trigger>
<Stack align="center">{children}</Stack>
</HoverCard.Trigger>
<HoverCard.Portal>
<HoverCard.Content sideOffset={44} side="left">
<Box
px="2"
shadow="2"
rounded="3"
border="px"
overflow="auto"
backgroundColor="surface-2"
style={{
width: "450px",
maxHeight: "600px",
}}
>
<pre
style={{
fontSize: "11px",
}}
>
<code>{JSON.stringify(rest, null, 2)}</code>
</pre>
</Box>
<HoverCard.Arrow />
</HoverCard.Content>
</HoverCard.Portal>
</HoverCard.Root>
);
};