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

Set proper background color on sticky table header #1329

Merged
merged 3 commits into from
Nov 22, 2024
Merged
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
70 changes: 40 additions & 30 deletions lib/platform-bible-react/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.cjs.map

Large diffs are not rendered by default.

70 changes: 40 additions & 30 deletions lib/platform-bible-react/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TableHeader = React.forwardRef<
<thead
ref={ref}
className={cn(
{ 'tw-sticky tw-top-0 tw-bg-muted': stickyHeader },
{ 'tw-sticky tw-top-[-1px] tw-bg-background tw-drop-shadow-sm': stickyHeader },
'[&_tr]:tw-border-b',
className,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,95 @@ import {
TableRow,
} from '@/components/shadcn-ui/table';

export default function TableExamples() {
const invoices = [
{
invoice: 'INV001',
paymentStatus: 'Paid',
totalAmount: '$250.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV002',
paymentStatus: 'Pending',
totalAmount: '$150.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV003',
paymentStatus: 'Unpaid',
totalAmount: '$350.00',
paymentMethod: 'Bank Transfer',
},
];
const invoices = [
{
invoice: 'INV001',
paymentStatus: 'Paid',
totalAmount: '$250.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV002',
paymentStatus: 'Pending',
totalAmount: '$150.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV003',
paymentStatus: 'Unpaid',
totalAmount: '$350.00',
paymentMethod: 'Bank Transfer',
},
];

const lotsOfInvoices = Array(10).fill(invoices).flat();

export default function TableExamples() {
return (
<Table className="tw-border">
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="tw-text-end">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow
key={invoice.invoice}
data-state={invoice.paymentStatus === 'Paid' ? 'selected' : ''}
>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
<TableCell className="tw-text-end">{invoice.totalAmount}</TableCell>
<>
<Table className="tw-border">
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="tw-text-end">Amount</TableHead>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="tw-text-end">-SUM-</TableCell>
</TableRow>
</TableFooter>
</Table>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow
key={invoice.invoice}
data-state={invoice.paymentStatus === 'Paid' ? 'selected' : ''}
>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
<TableCell className="tw-text-end">{invoice.totalAmount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="tw-text-end">-SUM-</TableCell>
</TableRow>
</TableFooter>
</Table>

<div className="tw-relative tw-max-h-80 tw-overflow-auto">
<Table stickyHeader className="tw-border">
<TableHeader stickyHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="tw-text-end">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{lotsOfInvoices.map((invoice, index) => (
<TableRow
// eslint-disable-next-line react/no-array-index-key
key={invoice.invoice + index}
data-state={invoice.paymentStatus === 'Paid' ? 'selected' : ''}
>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
<TableCell className="tw-text-end">{invoice.totalAmount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="tw-text-end">-SUM-</TableCell>
</TableRow>
</TableFooter>
</Table>
</div>
</>
);
}
Loading