Skip to content

Commit

Permalink
[@kadena/react-ui] Classnames to table components
Browse files Browse the repository at this point in the history
  • Loading branch information
MRVDH committed Jan 24, 2024
1 parent 6a5275c commit 5267f19
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
5 changes: 3 additions & 2 deletions packages/libs/react-ui/src/components/Table/TBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import type { CompoundType } from './types';

export interface ITBodyProps {
children?: CompoundType<typeof Tr>;
className?: string;
}

export const TBody: FC<ITBodyProps> = ({ children }) => {
export const TBody: FC<ITBodyProps> = ({ children, className }) => {
return (
<tbody>
<tbody className={className}>
{React.Children.map(children, (child) => {
if (
!React.isValidElement(child) ||
Expand Down
5 changes: 3 additions & 2 deletions packages/libs/react-ui/src/components/Table/THead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import type { CompoundType } from './types';

export interface ITHeadProps {
children?: CompoundType<typeof Tr>;
className?: string;
}

export const THead: FC<ITHeadProps> = ({ children }) => {
export const THead: FC<ITHeadProps> = ({ children, className }) => {
return (
<thead>
<thead className={className}>
{React.Children.map(children, (child) => {
if (
!React.isValidElement(child) ||
Expand Down
9 changes: 8 additions & 1 deletion packages/libs/react-ui/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ import type { CompoundType } from './types';
export interface ITableProps extends Pick<Sprinkles, 'wordBreak'> {
children?: CompoundType<typeof TBody> | CompoundType<typeof THead>;
striped?: boolean;
className?: string;
}

export const Table: FC<ITableProps> = ({ children, striped, wordBreak }) => {
export const Table: FC<ITableProps> = ({
children,
striped,
wordBreak,
className,
}) => {
return (
<table
className={classNames(
tableClass,
{ stripedClass: striped },
sprinkles({ wordBreak }),
className,
)}
>
{React.Children.map(children, (child) => {
Expand Down
6 changes: 4 additions & 2 deletions packages/libs/react-ui/src/components/Table/Td.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import classNames from 'classnames';
import type { FC } from 'react';
import React from 'react';
import { tdClass } from './Table.css';

export interface ITdProps {
children?: React.ReactNode;
className?: string;
}

export const Td: FC<ITdProps> = ({ children }) => {
return <td className={tdClass}>{children}</td>;
export const Td: FC<ITdProps> = ({ children, className }) => {
return <td className={classNames(tdClass, className)}>{children}</td>;
};
15 changes: 13 additions & 2 deletions packages/libs/react-ui/src/components/Table/Th.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ import { thClass } from './Table.css';
export interface IThProps
extends Pick<Sprinkles, 'width' | 'minWidth' | 'maxWidth'> {
children?: React.ReactNode;
className?: string;
}

export const Th: FC<IThProps> = ({ children, width, minWidth, maxWidth }) => {
export const Th: FC<IThProps> = ({
children,
width,
minWidth,
maxWidth,
className,
}) => {
return (
<th
className={classNames(thClass, sprinkles({ width, minWidth, maxWidth }))}
className={classNames(
thClass,
sprinkles({ width, minWidth, maxWidth }),
className,
)}
>
{children}
</th>
Expand Down
6 changes: 4 additions & 2 deletions packages/libs/react-ui/src/components/Table/Tr.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from 'classnames';
import type { FC } from 'react';
import React from 'react';
import { Link, SystemIcon } from '..';
Expand All @@ -11,11 +12,12 @@ export interface ITrProps {
children?: CompoundType<typeof Td> | CompoundType<typeof Th>;
url?: string;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
className?: string;
}

export const Tr: FC<ITrProps> = ({ children, url, onClick }) => {
export const Tr: FC<ITrProps> = ({ children, url, onClick, className }) => {
return (
<tr className={trClass}>
<tr className={classNames(trClass, className)}>
{React.Children.map(children, (child) => {
if (
!React.isValidElement(child) ||
Expand Down

0 comments on commit 5267f19

Please sign in to comment.