Skip to content

Commit 8a3d14b

Browse files
committed
Port ContextualHelp to phoenix components with new tooltip
1 parent 4eceee8 commit 8a3d14b

File tree

10 files changed

+138
-64
lines changed

10 files changed

+138
-64
lines changed

app/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ module.exports = {
278278
module: "@arizeai/components",
279279
use: "import { Select } from '@phoenix/components'",
280280
},
281+
{
282+
name: "ContextualHelp",
283+
module: "@arizeai/components",
284+
use: "import { ContextualHelp } from '@phoenix/components'",
285+
},
281286
],
282287
"no-duplicate-imports": "error",
283288
},

app/src/components/form/DimensionPicker.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { startTransition, useEffect, useState } from "react";
22
import { fetchQuery, graphql } from "react-relay";
33

4-
import { Content, ContextualHelp } from "@arizeai/components";
5-
64
import {
75
Button,
6+
ContextualHelp,
87
Flex,
98
Heading,
109
Label,
@@ -71,14 +70,12 @@ const contextualHelp = (
7170
<Heading weight="heavy" level={4}>
7271
Model Dimension
7372
</Heading>
74-
<Content>
75-
<Text>
76-
A dimension is a feature, tag, prediction, or actual value that is
77-
associated with a model inference. Features represent inputs, tags
78-
represent metadata, predictions represent outputs, and actuals represent
79-
ground truth.
80-
</Text>
81-
</Content>
73+
<Text>
74+
A dimension is a feature, tag, prediction, or actual value that is
75+
associated with a model inference. Features represent inputs, tags
76+
represent metadata, predictions represent outputs, and actuals represent
77+
ground truth.
78+
</Text>
8279
</ContextualHelp>
8380
);
8481

app/src/components/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export * from "./Empty";
3030
export * from "./exception";
3131
export * from "./KeyboardToken";
3232
export * from "./color/ColorSwatch";
33+
export * from "./tooltip/ContextualHelp";
3334

3435
// design system based components
3536
export * from "./alert";
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { PropsWithChildren } from "react";
2+
import { TooltipTrigger } from "react-aria-components";
3+
import { css } from "@emotion/react";
4+
5+
import {
6+
Button,
7+
Icon,
8+
Icons,
9+
Tooltip,
10+
TooltipProps,
11+
} from "@phoenix/components";
12+
13+
const getIconByVariant = (variant: ContextualHelpProps["variant"]) => {
14+
switch (variant) {
15+
case "info":
16+
return <Icons.InfoOutline />;
17+
case "help":
18+
default:
19+
return <Icons.QuestionOutline />;
20+
}
21+
};
22+
23+
export type ContextualHelpProps = PropsWithChildren<
24+
{
25+
variant?: "help" | "info";
26+
} & Partial<Omit<TooltipProps, "children">>
27+
>;
28+
29+
export const ContextualHelp = ({
30+
children,
31+
variant = "help",
32+
...tooltipProps
33+
}: ContextualHelpProps) => {
34+
return (
35+
<TooltipTrigger delay={0}>
36+
<Button
37+
// Special case styling to maintain compatability with arizeai/components contextual help
38+
css={css`
39+
& {
40+
all: unset;
41+
height: 14px !important;
42+
width: 14px !important;
43+
padding: var(--ac-global-dimension-size-50) !important;
44+
border-radius: var(--ac-global-rounding-small);
45+
svg {
46+
height: 14px;
47+
width: 14px;
48+
}
49+
}
50+
`}
51+
variant="quiet"
52+
size="S"
53+
leadingVisual={<Icon svg={getIconByVariant(variant)} />}
54+
/>
55+
<Tooltip {...tooltipProps}>{children}</Tooltip>
56+
</TooltipTrigger>
57+
);
58+
};

app/src/pages/dimension/DimensionDriftStats.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { graphql, useFragment } from "react-relay";
22

3-
import { Content, ContextualHelp } from "@arizeai/components";
4-
5-
import { ExternalLink, Flex, Heading, Text } from "@phoenix/components";
3+
import {
4+
ContextualHelp,
5+
ExternalLink,
6+
Flex,
7+
Heading,
8+
Text,
9+
} from "@phoenix/components";
610
import { floatFormatter } from "@phoenix/utils/numberFormatUtils";
711

812
import { DimensionDriftStats_dimension$key } from "./__generated__/DimensionDriftStats_dimension.graphql";
@@ -12,14 +16,12 @@ const contextualHelp = (
1216
<Heading weight="heavy" level={4}>
1317
Population Stability Index
1418
</Heading>
15-
<Content>
16-
<Text>
17-
PSI is a symmetric metric that measures the relative entropy, or
18-
difference in information represented by two distributions. It can be
19-
thought of as measuring the distance between two data distributions
20-
showing how different the two distributions are from each other.
21-
</Text>
22-
</Content>
19+
<Text>
20+
PSI is a symmetric metric that measures the relative entropy, or
21+
difference in information represented by two distributions. It can be
22+
thought of as measuring the distance between two data distributions
23+
showing how different the two distributions are from each other.
24+
</Text>
2325
<footer>
2426
<ExternalLink href="https://arize.com/blog-course/population-stability-index-psi/#:~:text=Population%20Stability%20Index%20(PSI)%20Overview,distributions%20are%20from%20each%20other.">
2527
Learn more

app/src/pages/embedding/MetricTimeSeries.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import {
1616
import { CategoricalChartFunc } from "recharts/types/chart/types";
1717
import { css } from "@emotion/react";
1818

19-
import { Content, ContextualHelp } from "@arizeai/components";
20-
21-
import { Heading, Icon, Icons, Text } from "@phoenix/components";
19+
import {
20+
ContextualHelp,
21+
Heading,
22+
Icon,
23+
Icons,
24+
Text,
25+
} from "@phoenix/components";
2226
import {
2327
ChartTooltip,
2428
ChartTooltipDivider,
@@ -360,7 +364,7 @@ export function MetricTimeSeries({
360364
{metricDescription != null ? (
361365
<ContextualHelp>
362366
<Heading level={4}>{metricShortName}</Heading>
363-
<Content>{metricDescription}</Content>
367+
<Text>{metricDescription}</Text>
364368
</ContextualHelp>
365369
) : null}
366370
</Heading>

app/src/pages/project/SessionsTable.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ import {
2121
} from "@tanstack/react-table";
2222
import { css } from "@emotion/react";
2323

24-
import { Content, ContextualHelp } from "@arizeai/components";
25-
26-
import { Flex, Heading, Icon, Icons, View } from "@phoenix/components";
24+
import {
25+
ContextualHelp,
26+
Flex,
27+
Heading,
28+
Icon,
29+
Icons,
30+
Text,
31+
View,
32+
} from "@phoenix/components";
2733
import { MeanScore } from "@phoenix/components/annotation/MeanScore";
2834
import { SessionAnnotationSummaryGroupTokens } from "@phoenix/components/annotation/SessionAnnotationSummaryGroup";
2935
import { selectableTableCSS } from "@phoenix/components/table/styles";
@@ -271,16 +277,16 @@ export function SessionsTable(props: SessionsTableProps) {
271277
const annotationColumns: ColumnDef<TableRow>[] = [
272278
{
273279
header: () => (
274-
<Flex direction="row" gap="size-50">
280+
<Flex direction="row" gap="size-50" alignItems="center">
275281
<span>annotations</span>
276282
<ContextualHelp>
277283
<Heading level={3} weight="heavy">
278284
Annotations
279285
</Heading>
280-
<Content>
286+
<Text>
281287
Evaluations and human annotations logged via the API or set via
282288
the UI.
283-
</Content>
289+
</Text>
284290
</ContextualHelp>
285291
</Flex>
286292
),

app/src/pages/project/SpansTable.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ import {
1919
} from "@tanstack/react-table";
2020
import { css } from "@emotion/react";
2121

22-
import { Content, ContextualHelp } from "@arizeai/components";
23-
2422
import {
2523
Flex,
2624
Heading,
2725
Icon,
2826
Icons,
2927
Link,
28+
Text,
3029
ToggleButton,
3130
ToggleButtonGroup,
3231
View,
@@ -38,6 +37,7 @@ import { IndeterminateCheckboxCell } from "@phoenix/components/table/Indetermina
3837
import { selectableTableCSS } from "@phoenix/components/table/styles";
3938
import { TextCell } from "@phoenix/components/table/TextCell";
4039
import { TimestampCell } from "@phoenix/components/table/TimestampCell";
40+
import { ContextualHelp } from "@phoenix/components/tooltip/ContextualHelp";
4141
import { TraceTokenCosts } from "@phoenix/components/trace";
4242
import { LatencyText } from "@phoenix/components/trace/LatencyText";
4343
import { SpanCumulativeTokenCount } from "@phoenix/components/trace/SpanCumulativeTokenCount";
@@ -335,10 +335,10 @@ export function SpansTable(props: SpansTableProps) {
335335
<Heading level={3} weight="heavy">
336336
Annotations
337337
</Heading>
338-
<Content>
338+
<Text>
339339
Evaluations and human annotations logged via the API or set via
340340
the UI.
341-
</Content>
341+
</Text>
342342
</ContextualHelp>
343343
</Flex>
344344
),

app/src/pages/project/TracesTable.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,23 @@ import {
2525
} from "@tanstack/react-table";
2626
import { css } from "@emotion/react";
2727

28-
import { Content, ContextualHelp } from "@arizeai/components";
29-
30-
import { Flex, Heading, Icon, Icons, Link, View } from "@phoenix/components";
28+
import {
29+
Flex,
30+
Heading,
31+
Icon,
32+
Icons,
33+
Link,
34+
Text,
35+
View,
36+
} from "@phoenix/components";
3137
import { AnnotationSummaryGroupTokens } from "@phoenix/components/annotation/AnnotationSummaryGroup";
3238
import { MeanScore } from "@phoenix/components/annotation/MeanScore";
3339
import { TextCell } from "@phoenix/components/table";
3440
import { IndeterminateCheckboxCell } from "@phoenix/components/table/IndeterminateCheckboxCell";
3541
import { selectableTableCSS } from "@phoenix/components/table/styles";
3642
import { TableExpandButton } from "@phoenix/components/table/TableExpandButton";
3743
import { TimestampCell } from "@phoenix/components/table/TimestampCell";
44+
import { ContextualHelp } from "@phoenix/components/tooltip/ContextualHelp";
3845
import { LatencyText } from "@phoenix/components/trace/LatencyText";
3946
import { SpanKindToken } from "@phoenix/components/trace/SpanKindToken";
4047
import { SpanStatusCodeIcon } from "@phoenix/components/trace/SpanStatusCodeIcon";
@@ -415,16 +422,16 @@ export function TracesTable(props: TracesTableProps) {
415422
() => [
416423
{
417424
header: () => (
418-
<Flex direction="row" gap="size-50">
425+
<Flex direction="row" gap="size-50" alignItems="center">
419426
<span>Annotations</span>
420427
<ContextualHelp>
421428
<Heading level={3} weight="heavy">
422429
Annotations
423430
</Heading>
424-
<Content>
431+
<Text>
425432
Evaluations and human annotations logged via the API or set via
426433
the UI.
427-
</Content>
434+
</Text>
428435
</ContextualHelp>
429436
</Flex>
430437
),

app/src/pages/trace/SpanDetails.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import CodeMirror, {
1616
} from "@uiw/react-codemirror";
1717
import { css } from "@emotion/react";
1818

19-
import { Content, ContextualHelp, TabbedCard } from "@arizeai/components";
19+
import { TabbedCard } from "@arizeai/components";
2020
import {
2121
DocumentAttributePostfixes,
2222
EmbeddingAttributePostfixes,
@@ -33,6 +33,7 @@ import {
3333
Button,
3434
Card,
3535
CardProps,
36+
ContextualHelp,
3637
CopyToClipboardButton,
3738
Counter,
3839
DialogTrigger,
@@ -2000,26 +2001,19 @@ function SpanEventsList({ events }: { events: Span["events"] }) {
20002001
}
20012002

20022003
const attributesContextualHelp = (
2003-
<Flex alignItems="center" justifyContent="center">
2004-
<View marginStart="size-100">
2005-
<ContextualHelp>
2006-
<Heading weight="heavy" level={4}>
2007-
Span Attributes
2008-
</Heading>
2009-
<Content>
2010-
<Text>
2011-
Attributes are key-value pairs that represent metadata associated
2012-
with a span. For detailed descriptions of specific attributes,
2013-
consult the semantic conventions section of the OpenInference
2014-
tracing specification.
2015-
</Text>
2016-
</Content>
2017-
<footer>
2018-
<ExternalLink href="https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md">
2019-
Semantic Conventions
2020-
</ExternalLink>
2021-
</footer>
2022-
</ContextualHelp>
2023-
</View>
2024-
</Flex>
2004+
<ContextualHelp>
2005+
<Heading weight="heavy" level={4}>
2006+
Span Attributes
2007+
</Heading>
2008+
<Text>
2009+
Attributes are key-value pairs that represent metadata associated with a
2010+
span. For detailed descriptions of specific attributes, consult the
2011+
semantic conventions section of the OpenInference tracing specification.
2012+
</Text>
2013+
<footer>
2014+
<ExternalLink href="https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md">
2015+
Semantic Conventions
2016+
</ExternalLink>
2017+
</footer>
2018+
</ContextualHelp>
20252019
);

0 commit comments

Comments
 (0)