mirror of
https://github.com/ershisan99/podcaster.git
synced 2025-12-16 20:59:26 +00:00
feat: add table component
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.29.2",
|
||||
"@tanstack/react-query-persist-client": "^5.29.2",
|
||||
"clsx": "^2.1.0",
|
||||
"idb-keyval": "^6.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
||||
2556
pnpm-lock.yaml
generated
2556
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
54
src/components/ui/table/table.tsx
Normal file
54
src/components/ui/table/table.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
|
||||
import { clsx } from "clsx";
|
||||
|
||||
export const Table = forwardRef<
|
||||
HTMLTableElement,
|
||||
ComponentPropsWithoutRef<"table">
|
||||
>(({ className, ...rest }, ref) => {
|
||||
const classes = clsx(className, "w-full border-collapse");
|
||||
|
||||
return <table className={classes} {...rest} ref={ref} />;
|
||||
});
|
||||
export const TableHead = forwardRef<
|
||||
ElementRef<"thead">,
|
||||
ComponentPropsWithoutRef<"thead">
|
||||
>(({ ...rest }, ref) => {
|
||||
return <thead {...rest} ref={ref} />;
|
||||
});
|
||||
|
||||
export const TableBody = forwardRef<
|
||||
ElementRef<"tbody">,
|
||||
ComponentPropsWithoutRef<"tbody">
|
||||
>(({ ...rest }, ref) => {
|
||||
return <tbody {...rest} ref={ref} />;
|
||||
});
|
||||
|
||||
export const TableRow = forwardRef<
|
||||
ElementRef<"tr">,
|
||||
ComponentPropsWithoutRef<"tr">
|
||||
>(({ className, ...rest }, ref) => {
|
||||
const classes = clsx(className, "odd:bg-gray-100");
|
||||
return <tr className={classes} {...rest} ref={ref} />;
|
||||
});
|
||||
|
||||
export const TableHeadCell = forwardRef<
|
||||
ElementRef<"th">,
|
||||
ComponentPropsWithoutRef<"th">
|
||||
>(({ children, className, ...rest }, ref) => {
|
||||
const classes = clsx(className, "py-3 px-4");
|
||||
|
||||
return (
|
||||
<th className={classes} {...rest} ref={ref}>
|
||||
<span>{children}</span>
|
||||
</th>
|
||||
);
|
||||
});
|
||||
|
||||
export const TableCell = forwardRef<
|
||||
ElementRef<"td">,
|
||||
ComponentPropsWithoutRef<"td">
|
||||
>(({ className, ...rest }, ref) => {
|
||||
const classes = clsx(className, "py-3 px-4 border-t border-slate-200");
|
||||
|
||||
return <td className={classes} {...rest} ref={ref} />;
|
||||
});
|
||||
Reference in New Issue
Block a user