Skip to content

Commit 2a44b08

Browse files
committed
Update DataTable.tsx
1 parent f6fafa4 commit 2a44b08

1 file changed

Lines changed: 11 additions & 30 deletions

File tree

frontend/src/components/DataTable.tsx

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,12 @@ export function DataTable({ socket }: { socket: ReturnType<typeof useVisiLensSoc
240240
const isAscending = sortState?.ascending ?? true;
241241
const isFiltered = filterState?.column === col.name;
242242
const isFiltering = activeFilterColumn === col.name;
243-
const isNumber = ['integer', 'float', 'currency'].includes(col.type);
244243

245244
return (
246245
<div
247246
key={col.name}
248247
className={clsx(
249248
"group flex items-center px-4 border-r border-border last:border-r-0 font-sans font-bold text-xs text-secondary uppercase tracking-wider select-none transition-colors",
250-
isNumber ? "justify-end text-right" : "justify-between text-left",
251249
isFiltering ? "bg-surface" : "hover:bg-row-hover/50"
252250
)}
253251
style={{ width: COLUMN_WIDTH, minWidth: COLUMN_WIDTH }}
@@ -268,52 +266,37 @@ export function DataTable({ socket }: { socket: ReturnType<typeof useVisiLensSoc
268266
}
269267
}}
270268
onBlur={() => {
271-
// Close on blur if empty, otherwise keep open?
272-
// For now, just close to be safe
273269
setActiveFilterColumn(null);
274270
}}
275271
className="h-6 w-full rounded border border-accent/50 bg-canvas px-2 text-xs text-primary focus:border-accent focus:outline-none"
276272
placeholder="Filter..."
277273
/>
278274
<button
279-
onMouseDown={(e) => e.preventDefault()} // Prevent blur
275+
onMouseDown={(e) => e.preventDefault()}
280276
onClick={() => setActiveFilterColumn(null)}
281277
className="text-secondary hover:text-primary"
282278
>
283279
<X className="h-3 w-3" />
284280
</button>
285281
</div>
286282
) : (
287-
<>
283+
<div className="flex w-full items-center justify-between gap-2">
288284
<div
289-
className={clsx(
290-
"flex flex-col gap-0.5 truncate cursor-pointer flex-1",
291-
isNumber && "items-end"
292-
)}
285+
className="flex min-w-0 cursor-pointer flex-col gap-0.5"
293286
onClick={() => {
294287
const ascending = isSorted ? !isAscending : true;
295288
sortColumn(col.name, ascending);
296289
}}
297290
>
298-
<span>{col.name}</span>
299-
<span className="text-[10px] text-secondary/50 font-normal lowercase">
291+
<span className="truncate text-left">{col.name}</span>
292+
<span className="text-left text-[10px] font-normal lowercase text-secondary/50">
300293
{col.type}
301294
</span>
302295
</div>
303296

304-
<div className={clsx("flex items-center gap-1", isNumber && "order-first mr-2")}>
305-
{isSorted && !isNumber && (
306-
<div className="shrink-0 ml-2">
307-
{isAscending ? (
308-
<ArrowUp className="h-3 w-3 text-accent" />
309-
) : (
310-
<ArrowDown className="h-3 w-3 text-accent" />
311-
)}
312-
</div>
313-
)}
314-
315-
{isSorted && isNumber && (
316-
<div className="shrink-0 mr-2">
297+
<div className="flex items-center gap-1">
298+
{isSorted && (
299+
<div className="shrink-0">
317300
{isAscending ? (
318301
<ArrowUp className="h-3 w-3 text-accent" />
319302
) : (
@@ -326,7 +309,7 @@ export function DataTable({ socket }: { socket: ReturnType<typeof useVisiLensSoc
326309
<button
327310
onClick={(e) => {
328311
e.stopPropagation();
329-
filterColumn(col.name, ''); // Clear filter
312+
filterColumn(col.name, '');
330313
}}
331314
className="flex items-center gap-1 rounded border border-accent/40 bg-accent/10 px-2 py-1 text-[10px] font-semibold text-accent hover:bg-accent/20"
332315
title={`Filtered by: ${filterState?.term}`}
@@ -348,7 +331,7 @@ export function DataTable({ socket }: { socket: ReturnType<typeof useVisiLensSoc
348331
</button>
349332
)}
350333
</div>
351-
</>
334+
</div>
352335
)}
353336
</div>
354337
);
@@ -415,13 +398,11 @@ export function DataTable({ socket }: { socket: ReturnType<typeof useVisiLensSoc
415398
}}
416399
>
417400
{columns.map((col) => {
418-
const isNumber = ['integer', 'float', 'currency'].includes(col.type);
419401
return (
420402
<div
421403
key={col.name}
422404
className={clsx(
423-
"flex items-center px-4 border-r border-border/30 last:border-r-0 text-[13px] text-primary/90 whitespace-nowrap overflow-hidden",
424-
isNumber ? "justify-end text-right" : "justify-start text-left"
405+
"flex items-center px-4 border-r border-border/30 last:border-r-0 text-[13px] text-primary/90 whitespace-nowrap overflow-hidden justify-start text-left"
425406
)}
426407
style={{ width: COLUMN_WIDTH, minWidth: COLUMN_WIDTH }}
427408
title={String(row[col.name] ?? '')}

0 commit comments

Comments
 (0)