Skip to content

Commit

Permalink
feat(annotations): default collapse annotation explanations (#4081)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking authored Jul 30, 2024
1 parent cf3b37c commit dbf3ee4
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions app/src/pages/trace/SpanAnnotationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export type CreateAnnotationInput = {
explanation?: string | null;
};

const detailsCSS = css`
color: var(--ac-global-text-color-900);
font-size: 12px;
`;
export type SpanAnnotationFormProps = {
/**
* The initial data to populate the form with
Expand Down Expand Up @@ -69,6 +73,7 @@ export function SpanAnnotationForm(props: SpanAnnotationFormProps) {
[onSubmit, setError]
);

const defaultDetailsCollapsed = isReadOnly;
return (
<form onSubmit={handleSubmit(_onSubmit)} ref={formRef}>
<View padding="size-200">
Expand Down Expand Up @@ -130,26 +135,31 @@ export function SpanAnnotationForm(props: SpanAnnotationFormProps) {
)}
/>
</div>
<Controller
name="explanation"
control={control}
render={({
field: { onChange, onBlur, value },
fieldState: { invalid, error },
}) => (
<TextArea
label="Explanation"
height={70}
isReadOnly={isReadOnly}
description="Why this score or label was given"
errorMessage={error?.message}
validationState={invalid ? "invalid" : "valid"}
onChange={onChange}
onBlur={onBlur}
value={value?.toString() || ""}
<details open={!defaultDetailsCollapsed} css={detailsCSS}>
<summary>Annotation Details</summary>
<View paddingTop="size-50">
<Controller
name="explanation"
control={control}
render={({
field: { onChange, onBlur, value },
fieldState: { invalid, error },
}) => (
<TextArea
label="Explanation"
height={70}
isReadOnly={isReadOnly}
description="Why this score or label was given"
errorMessage={error?.message}
validationState={invalid ? "invalid" : "valid"}
onChange={onChange}
onBlur={onBlur}
value={value?.toString() || ""}
/>
)}
/>
)}
/>
</View>
</details>
</Flex>
</View>
<>
Expand Down

0 comments on commit dbf3ee4

Please sign in to comment.