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

feat(theme): added new styles for component Table #292

Merged
merged 1 commit into from
May 18, 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
2 changes: 1 addition & 1 deletion packages/components/react/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TableHeader from './table-header'
import TableFooter from './table-footer'
import TableCaption from './table-caption'

export type { Comp as TableComponent, Props as TableProps } from './table'
export type { Props as TableProps } from './table'
export type { Comp as TableBodyComponent, Props as TableBodyProps } from './table-body'
export type { Comp as TableCellComponent, Props as TableCellProps } from './table-cell'
export type { Comp as TableHeadComponent, Props as TableHeadProps } from './table-Head'
Expand Down
33 changes: 22 additions & 11 deletions packages/components/react/table/table.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import * as React from 'react'
import { cn, table } from '@openui-org/theme'
import type { VariantProps } from '@openui-org/theme'
import { Slot } from '@radix-ui/react-slot'

export interface Props extends React.HTMLAttributes<HTMLTableElement> {}
export interface Comp extends HTMLTableElement {}
export interface Props extends React.HTMLAttributes<HTMLTableElement>,
VariantProps<typeof table> {
asChild?: boolean
children?: React.ReactNode
}
interface Comp extends HTMLTableElement {}

const Table = React.forwardRef<Comp, Props>(({ className, ...props }, ref) => (
<div className="relative w-full overflow-auto">
<table
ref={ref}
className={cn(table(), className)}
{...props}
/>
</div>
))
const Table = React.forwardRef<Comp, Props>(({ className, children, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'table'
return (
<div className="relative w-full overflow-auto p-4">
<Comp
ref={ref}
className={cn(table(), className)}
{...props}
>
{children}
</Comp>
</div>
)
})

Table.displayName = 'Table'

Expand Down
16 changes: 8 additions & 8 deletions packages/theme/src/components/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { cva } from 'class-variance-authority'
* // Table elements
* </Table>
*/
export const table = cva('w-full caption-bottom text-sm')
export const table = cva('w-full caption-bottom text-small rounded-lg overflow-hidden')

/**
* Table wrapper **Class Variants** component
Expand All @@ -22,7 +22,7 @@ export const table = cva('w-full caption-bottom text-sm')
* // TableHeader elements
* </tableHeader>
*/
export const tableHeader = cva('[&_tr]:border-b')
export const tableHeader = cva('[&_th]:bg-foreground/20 disabled:[&_th]:bg-foreground/10 pointer-events-none')

/**
* Table wrapper **Class Variants** component
Expand All @@ -34,7 +34,7 @@ export const tableHeader = cva('[&_tr]:border-b')
* // TableBody elements
* </tableBody>
*/
export const tableBody = cva('[&_tr]:border-b')
export const tableBody = cva('hover:[&_tr]:bg-foreground/10')

/**
* Table wrapper **Class Variants** component
Expand All @@ -46,7 +46,7 @@ export const tableBody = cva('[&_tr]:border-b')
* // TableFooter elements
* </TableFooter>
*/
export const tableFooter = cva('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0')
export const tableFooter = cva('[&_tr]:bg-foreground/20 pointer-events-none w-full')

/**
* Table wrapper **Class Variants** component
Expand All @@ -58,7 +58,7 @@ export const tableFooter = cva('border-t bg-muted/50 font-medium [&>tr]:last:bor
* // TableRow elements
* </TableRow>
*/
export const tableRow = cva('border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted')
export const tableRow = cva('transition-colors hover:bg-foreground/50 data-[state=selected]:bg-foreground/50 rounded-lg')

/**
* Table wrapper **Class Variants** component
Expand All @@ -70,7 +70,7 @@ export const tableRow = cva('border-b transition-colors hover:bg-muted/50 data-[
* // TableHead elements
* </TableHead>
*/
export const tableHead = cva('h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0')
export const tableHead = cva('h-12 px-4 text-left align-middle font-medium text-background-foreground [&:has([role=checkbox])]:pr-0 ')

/**
* Table wrapper **Class Variants** component
Expand All @@ -82,7 +82,7 @@ export const tableHead = cva('h-12 px-4 text-left align-middle font-medium text-
* // TableCell elements
* </TableCell>
*/
export const tableCell = cva('h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0')
export const tableCell = cva('h-12 px-4 text-left align-middle font-medium text-background-foreground [&:has([role=checkbox])]:pr-0')

/**
* Table wrapper **Class Variants** component
Expand All @@ -94,4 +94,4 @@ export const tableCell = cva('h-12 px-4 text-left align-middle font-medium text-
* // TableCaption elements
* </TableCaption>
*/
export const tableCaption = cva('mt-4 text-sm text-muted-foreground')
export const tableCaption = cva('mt-4 text-sm text-background-foreground')
Loading