Skip to content

Commit 888d3ac

Browse files
committed
Add a loading state to the FileItem component in the ResponsePreview panel with corresponding styles and spinner icon
1 parent 77958d2 commit 888d3ac

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@
171171
}
172172
}
173173

174+
&--loading {
175+
color: var(--cwc-text-color);
176+
background-color: var(--cwc-bg-tertiary);
177+
}
178+
174179
&__content {
175180
flex: 1;
176181
overflow: hidden;
@@ -180,9 +185,9 @@
180185
padding: 3px 0 3px 6px;
181186

182187
> span:first-child {
183-
font-size: 13px !important;
188+
font-size: 14px !important;
184189
margin-right: 4px;
185-
transform: translateY(2px);
190+
vertical-align: middle;
186191
}
187192
}
188193

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ type FileMessage =
2323
| { type: 'success'; text: string; show_actions?: boolean }
2424
| { type: 'error'; text: string; show_actions: boolean }
2525
| { type: 'warning'; text: string; show_actions: boolean }
26+
| { type: 'loading'; text: string; show_actions?: boolean }
2627

2728
const get_file_message = (file: FileInPreview): FileMessage | null => {
28-
if (file.applied_with_intelligent_update) {
29+
if (file.is_applying) {
30+
return {
31+
type: 'loading',
32+
text: 'Applying...',
33+
show_actions: false
34+
}
35+
} else if (file.applied_with_intelligent_update) {
2936
return {
3037
type: 'success',
3138
text: 'Applied with Intelligent Update',
@@ -224,7 +231,8 @@ export const FileItem: FC<Props> = (props) => {
224231
className={cn(styles.message, {
225232
[styles['message--error']]: message_obj.type == 'error',
226233
[styles['message--warning']]: message_obj.type == 'warning',
227-
[styles['message--success']]: message_obj.type == 'success'
234+
[styles['message--success']]: message_obj.type == 'success',
235+
[styles['message--loading']]: message_obj.type == 'loading'
228236
})}
229237
>
230238
<div className={styles['message__content']}>
@@ -237,6 +245,9 @@ export const FileItem: FC<Props> = (props) => {
237245
{message_obj.type == 'warning' && (
238246
<span className="codicon codicon-warning" />
239247
)}
248+
{message_obj.type == 'loading' && (
249+
<span className="codicon codicon-loading codicon-modifier-spin" />
250+
)}
240251
<span>{message_obj.text}</span>
241252
</div>
242253
{'show_actions' in message_obj && message_obj.show_actions && (

0 commit comments

Comments
 (0)