Fix: Optimize table style #3221 (#9703)

### What problem does this PR solve?

Fix: Optimize table style
-Modify the style of the table scrollbar and remove unnecessary
scrollbars
-Adjust the header style of the table, add background color and
hierarchy
-Optimize the style of datasets and file tables
-Add a new background color variable

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2025-08-26 10:46:54 +08:00
committed by GitHub
parent 63b5c2292d
commit ae505e6165
8 changed files with 113 additions and 65 deletions

View File

@ -8,7 +8,7 @@ const Table = React.forwardRef<
>(({ className, rootClassName, ...props }, ref) => ( >(({ className, rootClassName, ...props }, ref) => (
<div <div
className={cn( className={cn(
'relative w-full overflow-auto rounded-2xl bg-bg-card', 'relative w-full overflow-auto rounded-2xl bg-bg-card scrollbar-none',
rootClassName, rootClassName,
)} )}
> >
@ -27,7 +27,7 @@ const TableHeader = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<thead <thead
ref={ref} ref={ref}
className={cn('[&_tr]:border-b top-0 sticky', className)} className={cn('[&_tr]:border-b top-0 sticky bg-bg-title z-10', className)}
{...props} {...props}
/> />
)); ));
@ -67,7 +67,7 @@ const TableRow = React.forwardRef<
<tr <tr
ref={ref} ref={ref}
className={cn( className={cn(
'border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted', 'border-b border-border-button transition-colors hover:bg-bg-card data-[state=selected]:bg-bg-card',
className, className,
)} )}
{...props} {...props}
@ -82,7 +82,7 @@ const TableHead = React.forwardRef<
<th <th
ref={ref} ref={ref}
className={cn( className={cn(
'h-12 px-4 text-left align-middle font-normal text-text-secondary [&:has([role=checkbox])]:pr-0', 'h-12 px-4 text-left align-middle font-normal text-text-secondary [&:has([role=checkbox])]:pr-0 ',
className, className,
)} )}
{...props} {...props}

View File

@ -837,7 +837,7 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
fileManager: { fileManager: {
name: 'Name', name: 'Name',
uploadDate: 'Upload Date', uploadDate: 'Upload Date',
knowledgeBase: 'Knowledge Base', knowledgeBase: 'Dataset',
size: 'Size', size: 'Size',
action: 'Action', action: 'Action',
addToKnowledge: 'Link to Knowledge Base', addToKnowledge: 'Link to Knowledge Base',

View File

@ -50,9 +50,10 @@ export function DatasetActionCell({
}, [record, showRenameModal]); }, [record, showRenameModal]);
return ( return (
<section className="flex gap-4 items-center text-text-sub-title-invert"> <section className="flex gap-4 items-center text-text-sub-title-invert opacity-0 group-hover:opacity-100 transition-opacity">
<Button <Button
variant={'ghost'} variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'} size={'sm'}
disabled={isRunning} disabled={isRunning}
onClick={handleRename} onClick={handleRename}
@ -61,7 +62,12 @@ export function DatasetActionCell({
</Button> </Button>
<HoverCard> <HoverCard>
<HoverCardTrigger> <HoverCardTrigger>
<Button variant="ghost" disabled={isRunning} size={'sm'}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
disabled={isRunning}
size={'sm'}
>
<Eye /> <Eye />
</Button> </Button>
</HoverCardTrigger> </HoverCardTrigger>
@ -88,7 +94,8 @@ export function DatasetActionCell({
{isVirtualDocument || ( {isVirtualDocument || (
<Button <Button
variant={'ghost'} variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
onClick={onDownloadDocument} onClick={onDownloadDocument}
disabled={isRunning} disabled={isRunning}
size={'sm'} size={'sm'}
@ -97,7 +104,12 @@ export function DatasetActionCell({
</Button> </Button>
)} )}
<ConfirmDeleteDialog onOk={handleRemove}> <ConfirmDeleteDialog onOk={handleRemove}>
<Button variant={'ghost'} size={'sm'} disabled={isRunning}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
disabled={isRunning}
>
<Trash2 /> <Trash2 />
</Button> </Button>
</ConfirmDeleteDialog> </ConfirmDeleteDialog>

View File

@ -119,7 +119,7 @@ export function DatasetTable({
return ( return (
<div className="w-full"> <div className="w-full">
<Table rootClassName="max-h-[82vh]"> <Table rootClassName="max-h-[calc(100vh-222px)]">
<TableHeader> <TableHeader>
{table.getHeaderGroups().map((headerGroup) => ( {table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}> <TableRow key={headerGroup.id}>
@ -144,6 +144,7 @@ export function DatasetTable({
<TableRow <TableRow
key={row.id} key={row.id}
data-state={row.getIsSelected() && 'selected'} data-state={row.getIsSelected() && 'selected'}
className="group"
> >
{row.getVisibleCells().map((cell) => ( {row.getVisibleCells().map((cell) => (
<TableCell <TableCell

View File

@ -61,24 +61,40 @@ export function ActionCell({
}, [record, showMoveFileModal]); }, [record, showMoveFileModal]);
return ( return (
<section className="flex gap-4 items-center text-text-sub-title-invert"> <section className="flex gap-4 items-center text-text-sub-title-invert opacity-0 group-hover:opacity-100 transition-opacity">
<Button <Button
variant="ghost" variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'} size={'sm'}
onClick={handleShowConnectToKnowledgeModal} onClick={handleShowConnectToKnowledgeModal}
> >
<Link2 /> <Link2 />
</Button> </Button>
<Button variant="ghost" size={'sm'} onClick={handleShowMoveFileModal}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowMoveFileModal}
>
<FolderInput /> <FolderInput />
</Button> </Button>
<Button variant="ghost" size={'sm'} onClick={handleShowFileRenameModal}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowFileRenameModal}
>
<FolderPen /> <FolderPen />
</Button> </Button>
{isFolder || ( {isFolder || (
<Button variant={'ghost'} size={'sm'} onClick={onDownloadDocument}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={onDownloadDocument}
>
<ArrowDownToLine /> <ArrowDownToLine />
</Button> </Button>
)} )}
@ -89,7 +105,11 @@ export function ActionCell({
documentName={record.name} documentName={record.name}
className="text-text-sub-title-invert" className="text-text-sub-title-invert"
> >
<Button variant={'ghost'} size={'sm'}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
>
<Eye /> <Eye />
</Button> </Button>
</NewDocumentLink> </NewDocumentLink>
@ -97,7 +117,8 @@ export function ActionCell({
{/* <DropdownMenu> {/* <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="ghost" size={'sm'}> <Button variant="transparent"
className="border-none" size={'sm'}>
<EllipsisVertical /> <EllipsisVertical />
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
@ -118,7 +139,11 @@ export function ActionCell({
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> */} </DropdownMenu> */}
<ConfirmDeleteDialog> <ConfirmDeleteDialog>
<Button variant="ghost" size={'sm'}> <Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
>
<Trash2 /> <Trash2 />
</Button> </Button>
</ConfirmDeleteDialog> </ConfirmDeleteDialog>

View File

@ -213,6 +213,7 @@ export function FilesTable({
id: 'actions', id: 'actions',
header: t('action'), header: t('action'),
enableHiding: false, enableHiding: false,
enablePinning: true,
cell: ({ row }) => { cell: ({ row }) => {
return ( return (
<ActionCell <ActionCell
@ -259,51 +260,56 @@ export function FilesTable({
}); });
return ( return (
<div className="w-full"> <>
<Table> <div className="w-full">
<TableHeader> <Table rootClassName="max-h-[calc(100vh-242px)] overflow-auto">
{table.getHeaderGroups().map((headerGroup) => ( <TableHeader>
<TableRow key={headerGroup.id}> {table.getHeaderGroups().map((headerGroup) => (
{headerGroup.headers.map((header) => { <TableRow key={headerGroup.id}>
return ( {headerGroup.headers.map((header) => {
<TableHead key={header.id}> return (
{header.isPlaceholder <TableHead key={header.id}>
? null {header.isPlaceholder
: flexRender( ? null
header.column.columnDef.header, : flexRender(
header.getContext(), header.column.columnDef.header,
)} header.getContext(),
</TableHead> )}
); </TableHead>
})} );
</TableRow> })}
))}
</TableHeader>
<TableBody>
{loading ? (
<TableSkeleton columnsLength={columns.length}></TableSkeleton>
) : table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && 'selected'}
>
{row.getVisibleCells().map((cell) => (
<TableCell
key={cell.id}
className={cell.column.columnDef.meta?.cellClassName}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow> </TableRow>
)) ))}
) : ( </TableHeader>
<TableEmpty columnsLength={columns.length}></TableEmpty> <TableBody className="max-h-96 overflow-y-auto">
)} {loading ? (
</TableBody> <TableSkeleton columnsLength={columns.length}></TableSkeleton>
</Table> ) : table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && 'selected'}
className="group"
>
{row.getVisibleCells().map((cell) => (
<TableCell
key={cell.id}
className={cell.column.columnDef.meta?.cellClassName}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext(),
)}
</TableCell>
))}
</TableRow>
))
) : (
<TableEmpty columnsLength={columns.length}></TableEmpty>
)}
</TableBody>
</Table>
</div>
<div className="flex items-center justify-end py-4"> <div className="flex items-center justify-end py-4">
<div className="space-x-2"> <div className="space-x-2">
<RAGFlowPagination <RAGFlowPagination
@ -331,6 +337,6 @@ export function FilesTable({
loading={fileRenameLoading} loading={fileRenameLoading}
></RenameDialog> ></RenameDialog>
)} )}
</div> </>
); );
} }

View File

@ -55,7 +55,7 @@ module.exports = {
'input-border': 'var(--input-border)', 'input-border': 'var(--input-border)',
/* design colors */ /* design colors */
'bg-title': 'var(--bg-title)',
'bg-base': 'var(--bg-base)', 'bg-base': 'var(--bg-base)',
'bg-card': 'var(--bg-card)', 'bg-card': 'var(--bg-card)',
'bg-component': 'var(--bg-component)', 'bg-component': 'var(--bg-component)',

View File

@ -91,6 +91,8 @@
--input-border: rgba(22, 22, 24, 0.2); --input-border: rgba(22, 22, 24, 0.2);
--metallic: #46464a; --metallic: #46464a;
--bg-title: #f6f6f7;
/* design colors */ /* design colors */
--bg-base: #ffffff; --bg-base: #ffffff;
@ -235,6 +237,8 @@
--input-border: rgba(255, 255, 255, 0.2); --input-border: rgba(255, 255, 255, 0.2);
--metallic: #fafafa; --metallic: #fafafa;
--bg-title: #38383a;
/* design colors */ /* design colors */
--bg-base: #161618; --bg-base: #161618;