Skip to content

Commit a27dcfd

Browse files
committed
Update UI components for modern theme support and add instruction expansion in response preview
- remove the left-right-left animation as intelligent update runs - disable instruction truncation through click, allow text selection - don't show token count on text item - line in text item should use gradient so that on the right side it's transparent
1 parent 13d4ed2 commit a27dcfd

6 files changed

Lines changed: 67 additions & 36 deletions

File tree

‎packages/ui/src/components/editor/panel/Page/Page.module.scss‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
margin: 6px 12px;
1414
position: relative;
1515

16+
:global([data-modern-ui='true']) & {
17+
margin: 6px 10px;
18+
}
19+
1620
&__title {
1721
position: absolute;
1822
left: 50%;
@@ -28,6 +32,6 @@
2832
border-top: 1px solid var(--cwc-border-color-dimmed);
2933

3034
:global([data-modern-ui='true']) & {
31-
padding: 10px 12px 5px 12px;
35+
padding: 10px 10px 5px 10px;
3236
}
3337
}

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

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
flex-direction: column;
44
padding: 4px 0 12px 0;
55
gap: 8px;
6+
7+
:global([data-modern-ui='true']) & {
8+
padding: 4px 0 10px 0;
9+
}
610
}
711

812
.info {
@@ -15,6 +19,10 @@
1519
border-radius: 8px;
1620
overflow: hidden;
1721

22+
:global([data-modern-ui='true']) & {
23+
margin: 0 10px;
24+
}
25+
1826
&--error {
1927
color: var(--cwc-text-color-red);
2028
background-color: var(--cwc-bg-red);
@@ -79,6 +87,16 @@
7987
font-size: 14px;
8088
line-height: 1.3;
8189
font-weight: 500;
90+
user-select: text;
91+
92+
&--expanded {
93+
display: block;
94+
-webkit-line-clamp: unset;
95+
}
96+
97+
:global([data-modern-ui='true']) & {
98+
margin: 0 10px;
99+
}
82100

83101
&--large {
84102
font-size: 16px;
@@ -97,14 +115,10 @@
97115
padding: 7px 9px 9px 9px;
98116
border-radius: 6px;
99117
background-color: var(--cwc-bg-tertiary);
100-
background-image: linear-gradient(
101-
to right,
102-
var(--cwc-bg-secondary),
103-
var(--cwc-bg-secondary)
104-
);
105-
background-repeat: no-repeat;
106-
background-size: 0% 100%;
107-
animation: breathe 10s infinite linear;
118+
119+
:global([data-modern-ui='true']) & {
120+
margin: 0 10px;
121+
}
108122

109123
&__item {
110124
display: flex;
@@ -170,16 +184,8 @@
170184
white-space: nowrap;
171185
overflow: hidden;
172186
text-overflow: ellipsis;
173-
}
174187

175-
@keyframes breathe {
176-
0% {
177-
background-size: 0% 100%;
178-
}
179-
50% {
180-
background-size: 100% 100%;
181-
}
182-
100% {
183-
background-size: 0% 100%;
188+
:global([data-modern-ui='true']) & {
189+
margin: 4px 10px 0 10px;
184190
}
185191
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const ResponsePreview: FC<Props> = (props) => {
6161
)
6262
const [is_fixing_all, set_is_fixing_all] = useState(false)
6363
const [has_attempted_auto_fix, set_has_attempted_auto_fix] = useState(false)
64+
const [instructions_expanded, set_instructions_expanded] = useState(false)
6465
const scroll_top_ref = useRef(0)
6566
const scrollable_ref = useRef<any>(null)
6667

@@ -228,9 +229,20 @@ export const ResponsePreview: FC<Props> = (props) => {
228229
<div
229230
className={cn(
230231
styles.instructions,
231-
get_instructions_font_size_class(simplified_instructions)
232+
get_instructions_font_size_class(simplified_instructions),
233+
{
234+
[styles['instructions--expanded']]: instructions_expanded
235+
}
232236
)}
233237
title={props.raw_instructions}
238+
onClick={() => {
239+
if (
240+
typeof window !== 'undefined' &&
241+
window.getSelection()?.toString()
242+
)
243+
return
244+
set_instructions_expanded(!instructions_expanded)
245+
}}
234246
>
235247
{simplified_instructions}
236248
</div>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
border-radius: 8px;
3737
cursor: pointer;
3838

39+
:global([data-modern-ui='true']) & {
40+
margin: 0 10px;
41+
}
42+
3943
&:hover {
4044
background-color: var(--vscode-list-hoverBackground);
4145
border-color: var(--cwc-border-color);

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
}
55

66
.text {
7-
margin: 6px 12px;
7+
margin: 3px 12px 6px 12px;
88
word-wrap: break-word;
99
user-select: text;
1010

11+
:global([data-modern-ui='true']) & {
12+
margin: 3px 10px 6px 10px;
13+
}
14+
1115
> * {
1216
margin: 0;
1317
font-size: 13px;
@@ -55,27 +59,33 @@
5559
display: flex;
5660
align-items: center;
5761
margin: 0 12px;
58-
padding-right: 9px;
5962
position: relative;
6063
cursor: pointer;
6164

65+
:global([data-modern-ui='true']) & {
66+
margin: 0 10px;
67+
}
68+
6269
&:hover {
6370
color: var(--cwc-text-color);
6471

6572
& .header__line {
66-
background-color: var(--cwc-border-color) !important;
73+
background: linear-gradient(
74+
to right,
75+
var(--cwc-border-color),
76+
transparent
77+
) !important;
6778
}
6879
}
6980

7081
&__line {
7182
flex: 1;
7283
height: 1px;
73-
background-color: var(--cwc-border-color-dimmed);
74-
margin: 0 10px 0 4px;
75-
}
76-
77-
&__tokens {
78-
font-size: 12px;
79-
color: var(--cwc-text-color-dimmed);
84+
background: linear-gradient(
85+
to right,
86+
var(--cwc-border-color-dimmed),
87+
transparent
88+
);
89+
margin: 0 0 0 4px;
8090
}
8191
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@ export const TextItem: FC<Props> = (props) => {
2323
codicon_icon={props.is_expanded ? 'chevron-down' : 'chevron-right'}
2424
/>
2525
<div className={styles.header__line} />
26-
<span className={styles.header__tokens}>
27-
{Math.floor(props.content.length * 0.25) || 1}
28-
</span>
2926
</div>
3027
{props.is_expanded && (
31-
<div
32-
className={styles.text}
33-
>
28+
<div className={styles.text}>
3429
<ReactMarkdown>{props.content}</ReactMarkdown>
3530
<div
3631
className={styles.text__collapse}

0 commit comments

Comments
 (0)