Skip to content

Commit 7fc3e5d

Browse files
committed
Replace the collapsed text preview icon with a numerical character count indicator
1 parent 3307814 commit 7fc3e5d

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
}
1818

1919
code {
20+
font-family: monospace;
2021
font-size: var(--font-size-11px);
2122
background-color: var(--vscode-textCodeBlock-background);
2223
padding: 2px 4px;
@@ -34,6 +35,17 @@
3435
align-items: center;
3536
margin: 0 var(--padding-12px);
3637
gap: var(--padding-8px);
38+
font-size: var(--font-size-12px);
39+
color: var(--cwc-text-color-dimmed);
40+
padding-right: var(--padding-9px);
41+
42+
&:hover {
43+
color: var(--cwc-text-color);
44+
45+
& .line {
46+
background-color: var(--cwc-border-color) !important;
47+
}
48+
}
3749
}
3850

3951
.line {

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
import { FC, useRef } from 'react'
22
import ReactMarkdown from 'react-markdown'
33
import styles from './TextItem.module.scss'
4-
import { IconButton } from '../../IconButton'
54

65
type Props = {
76
content: string
87
is_expanded: boolean
98
on_toggle: (element: HTMLDivElement) => void
109
}
1110

12-
export const TextItem: FC<Props> = ({ content, is_expanded, on_toggle }) => {
11+
export const TextItem: FC<Props> = (props) => {
1312
const ref = useRef<HTMLDivElement>(null)
1413

1514
return (
1615
<>
17-
{is_expanded ? (
16+
{props.is_expanded ? (
1817
<div
1918
ref={ref}
2019
className={styles.text}
21-
onClick={() => ref.current && on_toggle(ref.current)}
20+
onClick={() => ref.current && props.on_toggle(ref.current)}
2221
>
23-
<ReactMarkdown disallowedElements={['hr']}>{content}</ReactMarkdown>
22+
<ReactMarkdown disallowedElements={['hr']}>
23+
{props.content}
24+
</ReactMarkdown>
2425
</div>
2526
) : (
2627
<div
2728
ref={ref}
2829
className={styles.hidden}
29-
onClick={() => ref.current && on_toggle(ref.current)}
30+
onClick={() => ref.current && props.on_toggle(ref.current)}
31+
title={props.content}
32+
role="button"
3033
>
3134
<div className={styles.line} />
32-
<IconButton codicon_icon="list-selection" title="Show text" />
33-
<div className={styles.line} />
35+
{Math.floor(props.content.length * 0.25)}
3436
</div>
3537
)}
3638
</>

0 commit comments

Comments
 (0)