Skip to content

Commit 85b7580

Browse files
committed
add GuideContextDetails to V2 toolbar
1 parent aacbb41 commit 85b7580

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { useGuideContext, useStore } from "@knocklabs/react-core";
2+
import { Box, Stack } from "@telegraph/layout";
3+
import { Text } from "@telegraph/typography";
4+
import { ChevronDown, ChevronRight } from "lucide-react";
5+
import * as React from "react";
6+
7+
export const GuideContextDetails = () => {
8+
const { client } = useGuideContext();
9+
const [isExpanded, setIsExpanded] = React.useState(false);
10+
11+
const defaultGroup = useStore(client.store, (state) => state.guideGroups[0]);
12+
const displayInterval = defaultGroup?.display_interval ?? null;
13+
14+
return (
15+
<Stack direction="column" borderTop="px">
16+
<Stack
17+
h="5"
18+
px="2"
19+
bg="gray-3"
20+
align="center"
21+
gap="1"
22+
style={{ cursor: "pointer" }}
23+
onClick={() => setIsExpanded((prev) => !prev)}
24+
>
25+
<Text as="span" size="0" weight="medium">
26+
Details
27+
</Text>
28+
{isExpanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
29+
</Stack>
30+
31+
{isExpanded && (
32+
<Stack direction="column">
33+
<Stack direction="column" gap="0_5" py="1" px="2" borderTop="px">
34+
<Text as="span" size="0" weight="medium">
35+
Throttle
36+
</Text>
37+
<Text as="code" size="0">
38+
{displayInterval === null ? "-" : `Every ${displayInterval}s`}
39+
</Text>
40+
</Stack>
41+
42+
<Stack direction="column" py="1" px="2" borderTop="px">
43+
<Text as="span" size="0" weight="medium">
44+
Target params
45+
</Text>
46+
<Stack direction="column" gap="0_5" mt="1">
47+
<Text as="span" size="0" color="gray">
48+
Tenant
49+
</Text>
50+
<Text as="code" size="0">
51+
{client.targetParams.tenant ? (
52+
<Box
53+
rounded="2"
54+
overflow="auto"
55+
backgroundColor="gray-2"
56+
border="px"
57+
style={{ maxHeight: "200px" }}
58+
>
59+
<pre style={{ fontSize: "11px", margin: 0 }}>
60+
<code>{client.targetParams.tenant}</code>
61+
</pre>
62+
</Box>
63+
) : (
64+
<Text as="code" size="0">
65+
-
66+
</Text>
67+
)}
68+
</Text>
69+
</Stack>
70+
71+
<Stack direction="column" gap="0_5">
72+
<Text as="span" size="0" color="gray">
73+
Data
74+
</Text>
75+
{client.targetParams.data ? (
76+
<Box
77+
rounded="2"
78+
overflow="auto"
79+
backgroundColor="gray-2"
80+
border="px"
81+
style={{ maxHeight: "200px" }}
82+
>
83+
<pre style={{ fontSize: "11px", margin: 0 }}>
84+
<code>
85+
{JSON.stringify(client.targetParams.data, null, 2)}
86+
</code>
87+
</pre>
88+
</Box>
89+
) : (
90+
<Text as="code" size="0">
91+
-
92+
</Text>
93+
)}
94+
</Stack>
95+
</Stack>
96+
</Stack>
97+
)}
98+
</Stack>
99+
);
100+
};

packages/react/src/modules/guide/components/Toolbar/V2/V2.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { KnockButton } from "../KnockButton";
88
import { TOOLBAR_Z_INDEX } from "../shared";
99
import "../styles.css";
1010

11+
import { GuideContextDetails } from "./GuideContextDetails";
1112
import { GuideRow } from "./GuideRow";
1213
import {
1314
DisplayOption,
@@ -119,6 +120,7 @@ export const V2 = () => {
119120

120121
<Box w="full">
121122
{result.error && <Box>{result.error}</Box>}
123+
<GuideContextDetails />
122124
<GuidesList
123125
guides={result.guides}
124126
displayOption={guidesListDisplayOption}

0 commit comments

Comments
 (0)