Skip to content

Commit a016489

Browse files
committed
fix(chat): make composer chips read against the composer shell
The composer is --white in light and --surface-4 in dark. The chip reused chipFilledFillTokens (--surface-5 / dark:--surface-4), which assumes a page background, so in dark mode the chip fill matched its own container exactly and only the border showed. Same for the remove badge, which sits on the shell and was 5/255 from it. - Chip fills --surface-5 in both themes and hover steps away from the shell in each theme's 'raised' direction. - Remove badge uses --surface-6, readable on white and on --surface-4. - Cap the document card at min(220px,100%) so a long filename truncates on a narrow viewport instead of overflowing the composer.
1 parent e8852fe commit a016489

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list/attached-files-list.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ import { getFileExtension } from '@/lib/uploads/utils/file-utils'
88
import type { AttachedFile } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments'
99

1010
/**
11-
* Chrome shared by both chip shapes, borrowed from the chip family's filled field so a
12-
* hand-rolled card still reads as part of the system. Both shapes stand 48px tall, so a
13-
* row mixing thumbnails and documents sits on one baseline.
11+
* Chrome shared by both chip shapes. Both stand 48px tall so a row mixing thumbnails
12+
* and documents sits on one baseline.
13+
*
14+
* Deliberately NOT `chipFilledFillTokens` (`--surface-5` / `dark:--surface-4`): that
15+
* pair assumes a page background, but this chip sits inside the composer, which is
16+
* already `--surface-4` in dark mode — reusing it would make the chip invisible against
17+
* its own container. `--surface-5` steps away from the composer in both themes, and
18+
* hover steps further away in the direction each theme reads as "raised".
1419
*/
1520
const CHIP_SURFACE =
16-
'relative h-[48px] cursor-pointer rounded-[10px] border border-[var(--border)] bg-[var(--surface-5)] transition-colors dark:bg-[var(--surface-4)] hover-hover:bg-[var(--surface-active)]'
21+
'relative h-[48px] cursor-pointer rounded-[10px] border border-[var(--border)] bg-[var(--surface-5)] transition-colors hover-hover:bg-[var(--surface-active)] dark:hover-hover:bg-[var(--surface-6)]'
1722

1823
interface AttachedFilesListProps {
1924
attachedFiles: AttachedFile[]
@@ -49,15 +54,17 @@ const AttachedFileChip = React.memo(function AttachedFileChip({
4954

5055
return (
5156
<Tooltip.Root>
52-
<div className='group relative flex-shrink-0'>
57+
<div className={cn('group relative', isMedia ? 'flex-shrink-0' : 'min-w-0')}>
5358
<Tooltip.Trigger asChild>
5459
<button
5560
type='button'
5661
className={cn(
5762
CHIP_SURFACE,
5863
isMedia
5964
? 'w-[48px] overflow-hidden'
60-
: 'flex max-w-[220px] items-center gap-2 py-2 pr-3 pl-2'
65+
: // Capped at 220px but never wider than the composer, so a long filename
66+
// truncates on a narrow viewport instead of overflowing the shell.
67+
'flex max-w-[min(220px,100%)] items-center gap-2 py-2 pr-3 pl-2'
6168
)}
6269
onClick={() => onFileClick(file)}
6370
>
@@ -120,7 +127,10 @@ const AttachedFileChip = React.memo(function AttachedFileChip({
120127
onRemoveFile(file.id)
121128
}}
122129
aria-label={`Remove ${file.name}`}
123-
className='-top-[5px] -right-[5px] absolute flex size-[16px] items-center justify-center rounded-full border border-[var(--border)] bg-[var(--surface-6)] text-[var(--text-icon)] opacity-0 transition-opacity group-hover:opacity-100 dark:bg-[var(--surface-3)]'
130+
// Overhangs the chip by 5px, which the composer's `py-2` absorbs. `--surface-6`
131+
// (not the chip's own fill) because this badge sits on the composer shell —
132+
// white in light mode, `--surface-4` in dark — and must read against both.
133+
className='-top-[5px] -right-[5px] absolute flex size-[16px] items-center justify-center rounded-full border border-[var(--border)] bg-[var(--surface-6)] text-[var(--text-icon)] opacity-0 transition-opacity group-hover:opacity-100'
124134
>
125135
<X className='size-[9px]' />
126136
</button>

0 commit comments

Comments
 (0)