-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathGuideHoverCard.tsx
More file actions
88 lines (83 loc) · 2.35 KB
/
GuideHoverCard.tsx
File metadata and controls
88 lines (83 loc) · 2.35 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as HoverCard from "@radix-ui/react-hover-card";
import { Button } from "@telegraph/button";
import { Box, Stack } from "@telegraph/layout";
import { ExternalLink, RotateCcw } from "lucide-react";
import * as React from "react";
import {
AnnotatedGuide,
UncommittedGuide,
isUncommittedGuide,
} from "./useInspectGuideClientStore";
type Props = {
guide: AnnotatedGuide | UncommittedGuide;
};
export const GuideHoverCard = ({
children,
guide,
}: React.PropsWithChildren<Props>) => {
if (isUncommittedGuide(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={16} side="left">
<Box
px="2"
shadow="2"
rounded="3"
border="px"
overflow="auto"
backgroundColor="surface-2"
style={{
width: "450px",
maxHeight: "600px",
}}
>
<Stack justify="flex-end" gap="1" pt="2">
<Button
size="0"
variant="soft"
color="default"
leadingIcon={{ icon: RotateCcw, alt: "Reset engagement" }}
// TODO(KNO-11468): Placeholder button
onClick={() => {}}
>
Reset engagement
</Button>
<Button
size="0"
variant="soft"
color="default"
leadingIcon={{ icon: ExternalLink, alt: "Go to dashboard" }}
onClick={() =>
window.open(guide.dashboard_url, "_blank", "noopener")
}
>
Go to dashboard
</Button>
</Stack>
<pre
style={{
fontSize: "11px",
}}
>
<code>{JSON.stringify(rest, null, 2)}</code>
</pre>
</Box>
<HoverCard.Arrow />
</HoverCard.Content>
</HoverCard.Portal>
</HoverCard.Root>
);
};