Skip to content

Commit 8820096

Browse files
committed
Center grid loading dots
1 parent 4f09454 commit 8820096

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

src/components/database/components/grid/grid-table/GridVirtualizer.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useCallback, useEffect, useRef, useState } from 'react';
22

33
import { PADDING_END, useDatabaseContext } from '@/application/database-yjs';
4-
import LoadingDots from '@/components/_shared/LoadingDots';
54
import { GridDragContext } from '@/components/database/components/grid/drag-and-drop/GridDragContext';
65
import { RenderColumn } from '@/components/database/components/grid/grid-column/useRenderFields';
76
import { RenderRowType } from '@/components/database/components/grid/grid-row';
@@ -17,6 +16,24 @@ import { useGridContext } from '@/components/database/grid/useGridContext';
1716

1817
import { useColumnResize } from '../grid-column/useColumnResize';
1918

19+
const GRID_LOADING_DOT_COLORS = ['#00b5ff', '#e3006d', '#f7931e'] as const;
20+
21+
const gridLoadingDots = (
22+
<div className={'flex h-full items-center gap-1.5'}>
23+
{GRID_LOADING_DOT_COLORS.map((color, index) => (
24+
<span
25+
key={color}
26+
className={'h-1.5 w-1.5 animate-bounce rounded-full'}
27+
style={{
28+
animationDelay: `${index * 120}ms`,
29+
animationDuration: '900ms',
30+
backgroundColor: color,
31+
}}
32+
/>
33+
))}
34+
</div>
35+
);
36+
2037
function GridVirtualizer({ columns }: { columns: RenderColumn[] }) {
2138
const { rows: data, resizeRows, onResizeRowEnd } = useGridContext();
2239
const { handleResizeStart, isResizing } = useColumnResize(columns);
@@ -189,21 +206,19 @@ function GridVirtualizer({ columns }: { columns: RenderColumn[] }) {
189206
left: 0,
190207
transform: `translateY(${row.start - virtualizer.options.scrollMargin}px)`,
191208
display: 'flex',
209+
right: isPlaceholderRow ? 0 : undefined,
192210
pointerEvents: isPlaceholderRow ? 'none' : undefined,
193211
zIndex: rowData.type === RenderRowType.NewRow ? 1 : undefined,
194212
}}
195213
>
196214
{isPlaceholderRow ? (
197215
<div
198-
className={'flex min-h-[240px] items-center justify-center'}
216+
data-testid={'grid-loading-indicator'}
217+
className={'flex h-9 w-full items-center justify-center'}
218+
aria-label={'Loading rows'}
199219
role={'status'}
200-
style={{
201-
paddingLeft: columnItems[0]?.start,
202-
paddingRight: isDocumentBlock ? 0 : PADDING_INLINE,
203-
width: totalSize - (paddingEnd ?? 0),
204-
}}
205220
>
206-
<LoadingDots className={'flex items-center justify-center opacity-80'} />
221+
{gridLoadingDots}
207222
</div>
208223
) : rowData.type === RenderRowType.NewRow ? (
209224
<div

0 commit comments

Comments
 (0)