Skip to content

Commit e4d355c

Browse files
committed
improvement(tables): finish reference preview layout
1 parent a9482da commit e4d355c

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/reference-row-preview.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ describe('ReferenceRowPreview', () => {
107107
expect(container.textContent).toContain('Acme')
108108
expect(container.textContent).toContain('Enterprise')
109109
expect(container.textContent).not.toContain('Open in sub view')
110+
const goToTableLink = Array.from(container.querySelectorAll('a')).find(
111+
(link) => link.textContent === 'Go to table'
112+
)
113+
expect(goToTableLink?.getAttribute('href')).toBe('/workspace/workspace-1/tables/table-accounts')
114+
expect(goToTableLink?.parentElement?.className).toContain('h-9')
110115
const previewCell = container.querySelector('tbody > tr > td')
111116
expect(previewCell?.className).toContain('overflow-clip')
112117
expect(previewCell?.className).toContain('border-r')
@@ -120,7 +125,7 @@ describe('ReferenceRowPreview', () => {
120125
expect(subtable?.className).toContain('border-t')
121126
expect(subtable?.className).toContain('border-b')
122127
expect(subtable?.querySelectorAll('col')).toHaveLength(3)
123-
expect(container.querySelector('td > div > div > div:last-child')?.className).toContain(
128+
expect(container.querySelector('.overscroll-x-contain')?.className).toContain(
124129
'overscroll-x-contain'
125130
)
126131
expect(container.innerHTML).not.toContain('rounded-md')

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/reference-row-preview.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
'use client'
22

33
import { memo, type ReactNode, useMemo } from 'react'
4+
import { buttonVariants } from '@sim/emcn'
45
import { Loader } from '@sim/emcn/icons'
56
import { noop } from '@sim/utils/helpers'
7+
import Link from 'next/link'
68
import { columnTypeById } from '@/lib/table/column-types'
79
import { CellContent } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells'
810
import { ColumnTypeIcon } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/headers/column-type-icon'
911
import { expandToDisplayColumns } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/utils'
1012
import { useTable, useTableRow } from '@/hooks/queries/tables'
1113

1214
/**
13-
* Must match the sticky anchor's `h-[184px]` class below because the row
15+
* Must match the sticky anchor's `h-[144px]` class below because the row
1416
* virtualizer reserves this exact height. The zero-width anchor stays sticky
1517
* across the full table width, while its `100cqw` child uses TableGrid's
1618
* inline-size query container to cover the visible viewport.
1719
*/
18-
export const REFERENCE_ROW_PREVIEW_HEIGHT = 184
20+
export const REFERENCE_ROW_PREVIEW_HEIGHT = 144
1921

2022
const ReferenceIcon = columnTypeById('reference').icon
2123

@@ -124,16 +126,25 @@ export const ReferenceRowPreview = memo(function ReferenceRowPreview({
124126
colSpan={colSpan}
125127
className='overflow-clip border-[var(--border)] border-r border-b bg-[var(--surface-2)] p-0'
126128
>
127-
<div className='sticky left-0 h-[184px] w-0'>
129+
<div className='sticky left-0 h-[144px] w-0'>
128130
<div className='flex h-full w-[100cqw] min-w-0 flex-col bg-[var(--surface-2)]'>
129131
<div className='flex h-9 shrink-0 items-center gap-1.5 px-3 text-[var(--text-primary)] text-small'>
130132
<ReferenceIcon className='size-[14px] text-[var(--text-icon)]' />
131133
<span className='font-medium'>{table?.name ?? 'Referenced table'}</span>
132134
</div>
133135

134-
<div className='min-h-0 flex-1 overflow-auto overscroll-x-contain bg-[var(--bg)]'>
136+
<div className='h-[72px] shrink-0 overflow-auto overscroll-x-contain bg-[var(--bg)]'>
135137
{content}
136138
</div>
139+
140+
<div className='flex h-9 shrink-0 items-center bg-[var(--bg)] px-3'>
141+
<Link
142+
href={`/workspace/${workspaceId}/tables/${referenceTableId}`}
143+
className={buttonVariants({ variant: 'default', size: 'sm' })}
144+
>
145+
Go to table
146+
</Link>
147+
</div>
137148
</div>
138149
</div>
139150
</td>

0 commit comments

Comments
 (0)