Skip to content

Commit e87b2bb

Browse files
committed
fix: improve user table hover & selected styles (#195)
1 parent ce5b945 commit e87b2bb

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/features/users/components/data-table-column-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function DataTableColumnHeader<TData, TValue>({
3737
<Button
3838
variant='ghost'
3939
size='sm'
40-
className='data-[state=open]:bg-accent -ms-3 h-8'
40+
className='data-[state=open]:bg-accent h-8'
4141
>
4242
<span>{title}</span>
4343
{column.getIsSorted() === 'desc' ? (

src/features/users/components/users-columns.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ export const columns: ColumnDef<User>[] = [
2323
/>
2424
),
2525
meta: {
26-
className: cn(
27-
'sticky md:table-cell start-0 z-10 rounded-tl',
28-
'bg-background group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted'
29-
),
26+
className: cn('sticky md:table-cell start-0 z-10 rounded-tl-[inherit]'),
3027
},
3128
cell: ({ row }) => (
3229
<Checkbox
@@ -45,13 +42,12 @@ export const columns: ColumnDef<User>[] = [
4542
<DataTableColumnHeader column={column} title='Username' />
4643
),
4744
cell: ({ row }) => (
48-
<LongText className='max-w-36'>{row.getValue('username')}</LongText>
45+
<LongText className='max-w-36 ps-3'>{row.getValue('username')}</LongText>
4946
),
5047
meta: {
5148
className: cn(
52-
'drop-shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:drop-shadow-[0_1px_2px_rgb(255_255_255_/_0.1)] lg:drop-shadow-none',
53-
'bg-background group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted',
54-
'sticky start-6 md:table-cell'
49+
'drop-shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:drop-shadow-[0_1px_2px_rgb(255_255_255_/_0.1)]',
50+
'sticky start-6 @4xl/content:table-cell @4xl/content:drop-shadow-none'
5551
),
5652
},
5753
enableHiding: false,

src/features/users/components/users-table.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
getSortedRowModel,
1515
useReactTable,
1616
} from '@tanstack/react-table'
17+
import { cn } from '@/lib/utils'
1718
import {
1819
Table,
1920
TableBody,
@@ -79,7 +80,10 @@ export function UsersTable({ columns, data }: DataTableProps) {
7980
<TableHead
8081
key={header.id}
8182
colSpan={header.colSpan}
82-
className={header.column.columnDef.meta?.className ?? ''}
83+
className={cn(
84+
'bg-background group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted',
85+
header.column.columnDef.meta?.className ?? ''
86+
)}
8387
>
8488
{header.isPlaceholder
8589
? null
@@ -104,7 +108,10 @@ export function UsersTable({ columns, data }: DataTableProps) {
104108
{row.getVisibleCells().map((cell) => (
105109
<TableCell
106110
key={cell.id}
107-
className={cell.column.columnDef.meta?.className ?? ''}
111+
className={cn(
112+
'bg-background group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted',
113+
cell.column.columnDef.meta?.className ?? ''
114+
)}
108115
>
109116
{flexRender(
110117
cell.column.columnDef.cell,

0 commit comments

Comments
 (0)