Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always show the actions column #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/DataTable/DataTableColumnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export function DataTableColumnHeader({ column, title, className }) {
return <div className={cn(className)}>{title}</div>;
}

if (column.id === "actions") {
return <div className={cn(className)}>{title}</div>;
}

return (
<div className={cn("flex items-center space-x-2", className)}>
<DropdownMenu>
Expand Down
9 changes: 8 additions & 1 deletion src/components/DataTable/SWRDataTable/DataTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useNavigate } from "react-router-dom";
import { TableBody, TableCell, TableRow } from "#/components/ui";

import { useTableContext } from "../TableContext";
import { cn } from "#/lib/utils";

export function DataTableBody({ hasDetails }) {
// @ts-expect-error TS(2339) FIXME: Property 'table' does not exist on type '{}'.
Expand All @@ -27,7 +28,13 @@ export function DataTableBody({ hasDetails }) {
}}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
<TableCell
key={cell.id}
className={cn({
"bg-background sticky right-0 group-hover:bg-muted/40 transition-colors":
Copy link
Contributor

@ribeirojose ribeirojose Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 would only perhaps use a heavier bg to make sure it stands out from the background. Currently it seems a bit faded

cell.column.id === "actions",
})}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
Expand Down
8 changes: 7 additions & 1 deletion src/components/DataTable/SWRDataTable/DataTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { flexRender } from "@tanstack/react-table";
import { TableHead, TableHeader, TableRow } from "#/components/ui";

import { useTableContext } from "../TableContext";
import { cn } from "#/lib/utils";

export function DataTableHeader() {
// @ts-expect-error TS(2339) FIXME: Property 'table' does not exist on type '{}'.
Expand All @@ -15,7 +16,12 @@ export function DataTableHeader() {
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableHead key={header.id}>
<TableHead
key={header.id}
className={cn({
"sticky right-0": header.id === "actions",
})}
>
{header.isPlaceholder
? null
: flexRender(
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TableRow = React.forwardRef<
<tr
ref={ref}
className={cn(
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b dark:border-b-2 transition-colors",
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b dark:border-b-2 transition-colors group",
className
)}
{...props}
Expand Down