Skip to content

Commit b20a6ab

Browse files
committed
review updates
1 parent e8eab53 commit b20a6ab

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

packages/@react-spectrum/ai/src/AttachmentList.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,32 +390,38 @@ const tagStyles = style({
390390
borderRadius: 'default'
391391
});
392392

393+
// this is checking that there isn't content in the attachment
394+
// similar to onlyPreview, but specifically checking siblings before the alert icon (aka looking for Content)
395+
const onlyPreviewFromError = ':not([data-slot=content] ~ *)';
393396
const attachmentErrorStyles = style({
394397
display: 'flex',
395398
flexShrink: 0,
396399
alignItems: 'center',
397400
paddingStart: {
398401
default: 8,
399-
':not([data-slot=content] ~ *)': 0
402+
[onlyPreviewFromError]: 0
400403
},
401404
position: {
402-
':not([data-slot=content] ~ *)': 'absolute'
405+
[onlyPreviewFromError]: 'absolute'
403406
},
404407
top: {
405-
':not([data-slot=content] ~ *)': '50%'
408+
[onlyPreviewFromError]: '50%'
406409
},
407410
insetStart: {
408-
':not([data-slot=content] ~ *)': '50%'
411+
[onlyPreviewFromError]: '50%'
409412
},
410413
transform: {
411-
':not([data-slot=content] ~ *)': 'translate(-50%, -50%)'
414+
[onlyPreviewFromError]: 'translate(-50%, -50%)'
412415
},
413416
'--iconPrimary': {
414417
type: 'color',
415418
value: 'negative'
416419
}
417420
});
418421

422+
// this is also checking that there isn't content in the attachment
423+
// similar to onlyPreview, but specifically checking siblings after the thumbnail (aka looking for Content)
424+
const onlyPreviewFromThumbnail = ':not(:has(~ [data-slot=content]))';
419425
function AttachmentContextProvider({
420426
children,
421427
isUploading,
@@ -433,7 +439,7 @@ function AttachmentContextProvider({
433439
isUploading: 0.15,
434440
isInvalid: {
435441
default: 1,
436-
':not(:has(~ [data-slot=content]))': 0.15
442+
[onlyPreviewFromThumbnail]: 0.15
437443
}
438444
},
439445
transition: 'default'
@@ -586,8 +592,10 @@ export const Attachment = forwardRef(function Attachment(
586592
top: '50%',
587593
insetStart: {
588594
default: '50%',
595+
// this checks that there is text content in the attachment + a Image as a thumbnail
589596
':has(~ [data-slot=content]):not(:has(~ [data-rsp-slot=thumbnail]))':
590597
'[calc(var(--card-padding-x) + var(--basic-thumb-size) / 2)]',
598+
// this checks that there is text content in the attachment + a Illustration as a thumbnail
591599
':has(~ [data-slot=content]):has(~ [data-rsp-slot=thumbnail])':
592600
'[calc(var(--card-padding-x) + var(--illust-margin-x) + var(--illust-thumb-size) / 2)]'
593601
},

0 commit comments

Comments
 (0)