Skip to content

Commit b7a7001

Browse files
committed
Refactor variable naming conventions and component prop handling across FileItem and StatusBar components
- should accept 'props' variable, don't destructure
1 parent 081dce5 commit b7a7001

2 files changed

Lines changed: 35 additions & 40 deletions

File tree

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,24 @@ export const FileItem: FC<Props> = (props) => {
232232
</div>
233233
{message_obj &&
234234
(() => {
235-
let statusBarTheme: 'success' | 'error' | 'warning' | 'default' =
235+
let status_bar_theme: 'success' | 'error' | 'warning' | 'default' =
236236
'default'
237-
let statusBarIcon = ''
238-
let statusBarIconSpin = false
237+
let status_bar_icon = ''
238+
let status_bar_icon_spin = false
239239

240-
if (message_obj.type === 'success') {
241-
statusBarTheme = 'success'
242-
statusBarIcon = 'codicon-check'
243-
} else if (message_obj.type === 'error') {
244-
statusBarTheme = 'error'
245-
statusBarIcon = 'codicon-error'
246-
} else if (message_obj.type === 'warning') {
247-
statusBarTheme = 'warning'
248-
statusBarIcon = 'codicon-warning'
249-
} else if (message_obj.type === 'loading') {
250-
statusBarTheme = 'default'
251-
statusBarIcon = 'codicon-loading'
252-
statusBarIconSpin = true
240+
if (message_obj.type == 'success') {
241+
status_bar_theme = 'success'
242+
status_bar_icon = 'codicon-check'
243+
} else if (message_obj.type == 'error') {
244+
status_bar_theme = 'error'
245+
status_bar_icon = 'codicon-error'
246+
} else if (message_obj.type == 'warning') {
247+
status_bar_theme = 'warning'
248+
status_bar_icon = 'codicon-warning'
249+
} else if (message_obj.type == 'loading') {
250+
status_bar_theme = 'default'
251+
status_bar_icon = 'codicon-loading'
252+
status_bar_icon_spin = true
253253
}
254254

255255
const message_actions = []
@@ -281,9 +281,9 @@ export const FileItem: FC<Props> = (props) => {
281281
return (
282282
<StatusBar
283283
placement="bottom"
284-
theme={statusBarTheme}
285-
icon={statusBarIcon}
286-
icon_spin={statusBarIconSpin}
284+
theme={status_bar_theme}
285+
icon={status_bar_icon}
286+
icon_spin={status_bar_icon_spin}
287287
label={message_obj.text}
288288
actions={message_actions}
289289
/>

‎packages/ui/src/components/editor/prompt/StatusBar/StatusBar.tsx‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,48 @@ export type StatusBarAction = {
1313
}
1414

1515
export type Props = {
16+
label: React.ReactNode
1617
theme?: 'default' | 'warning' | 'success' | 'error' | 'blue' | 'purple'
1718
placement?: 'top' | 'bottom'
1819
icon?: string
1920
icon_spin?: boolean
20-
label: React.ReactNode
2121
description?: React.ReactNode
2222
actions?: StatusBarAction[]
2323
className?: string
2424
}
2525

26-
export const StatusBar: React.FC<Props> = ({
27-
theme = 'default',
28-
placement,
29-
icon,
30-
icon_spin,
31-
label,
32-
description,
33-
actions,
34-
className
35-
}) => {
26+
export const StatusBar: React.FC<Props> = (props) => {
27+
const theme = props.theme ?? 'default'
28+
3629
return (
3730
<div
3831
className={cn(
3932
styles.container,
4033
styles[`theme-${theme}`],
41-
placement ? styles[`placement-${placement}`] : styles.rounded,
42-
className
34+
props.placement
35+
? styles[`placement-${props.placement}`]
36+
: styles.rounded,
37+
props.className
4338
)}
4439
>
4540
<div className={styles.content}>
46-
{icon && (
41+
{props.icon && (
4742
<span className={styles.icon}>
4843
<span
49-
className={cn('codicon', icon, {
50-
'codicon-modifier-spin': icon_spin
44+
className={cn('codicon', props.icon, {
45+
'codicon-modifier-spin': props.icon_spin
5146
})}
5247
/>
5348
</span>
5449
)}
55-
<label className={styles.label}>{label}</label>
56-
{description && (
57-
<span className={styles.description}>{description}</span>
50+
<label className={styles.label}>{props.label}</label>
51+
{props.description && (
52+
<span className={styles.description}>{props.description}</span>
5853
)}
5954
</div>
60-
{actions && actions.length > 0 && (
55+
{props.actions && props.actions.length > 0 && (
6156
<div className={styles.actions}>
62-
{actions.map((action) => {
57+
{props.actions.map((action) => {
6358
const content = (
6459
<div
6560
key={action.id}

0 commit comments

Comments
 (0)