Skip to content

Commit 1a63653

Browse files
committed
Implement toggling functionality to allow users to expand and collapse the response preview text item
1 parent 892d5b9 commit 1a63653

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

‎packages/ui/src/components/editor/panel/ResponsePreview/components/TextItem.module.scss‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,21 @@
2929
position: relative;
3030
}
3131

32-
&--overflowing {
32+
&--expandable {
3333
cursor: pointer;
34-
&::after {
35-
content: '';
36-
position: absolute;
37-
bottom: 0;
38-
left: 0;
39-
width: 100%;
40-
height: 20px;
41-
background: linear-gradient(
42-
to bottom,
43-
transparent,
44-
var(--vscode-list-hoverBackground)
45-
);
46-
}
34+
}
35+
36+
&--overflowing::after {
37+
content: '';
38+
position: absolute;
39+
bottom: 0;
40+
left: 0;
41+
width: 100%;
42+
height: 20px;
43+
background: linear-gradient(
44+
to bottom,
45+
transparent,
46+
var(--vscode-list-hoverBackground)
47+
);
4748
}
4849
}

‎packages/ui/src/components/editor/panel/ResponsePreview/components/TextItem.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ export const TextItem: FC<Props> = ({ content }) => {
2424
<div
2525
ref={ref}
2626
className={cn(styles.text, {
27+
[styles['text--expandable']]: is_expanded || is_overflowing,
2728
[styles['text--collapsed']]: !is_expanded,
2829
[styles['text--overflowing']]: !is_expanded && is_overflowing
2930
})}
30-
onClick={is_overflowing ? () => set_is_expanded(true) : undefined}
31+
onClick={
32+
is_overflowing || is_expanded
33+
? () => set_is_expanded((prev) => !prev)
34+
: undefined
35+
}
3136
>
3237
<ReactMarkdown>{content}</ReactMarkdown>
3338
</div>

0 commit comments

Comments
 (0)