Skip to content

Commit

Permalink
feat: react table component (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza14khan authored Dec 6, 2024
1 parent b00d654 commit 18191a7
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 33 deletions.
17 changes: 17 additions & 0 deletions packages/design/tailwind/css/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,20 @@ input[type='file' i] {
}

/* End of Breadcrumbs */

/* Table */

.gi-table {
@apply gi-w-full gi-border-spacing-0 gi-border-collapse gi-text-md;
}

.gi-table-th,
.gi-table-td {
@apply gi-text-left gi-align-top gi-pl-1 gi-pr-5 gi-py-2.5 gi-border-b-[gray] gi-border-b gi-border-solid gi-align-middle gi-max-w-[25ch] gi-overflow-hidden gi-text-ellipsis gi-whitespace-nowrap;
}

.gi-table-no-data {
@apply gi-text-center gi-border-0 gi-py-8 gi-px-4;
}

/* End of Table */
3 changes: 3 additions & 0 deletions packages/react/ds/src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type CheckboxType = {
className?: string;
checked?: boolean;
disabled?: boolean;
ariaLabel?: string;
};

const Checkbox = ({
Expand All @@ -31,6 +32,7 @@ const Checkbox = ({
className,
checked,
disabled,
ariaLabel,
}: CheckboxType) => {
return (
<div className={`gi-checkbox-container ${className && className}`}>
Expand All @@ -42,6 +44,7 @@ const Checkbox = ({
value={value}
className={`${getSizeClass(size)} ${getTickSize(size)} gi-checkbox-input`}
checked={checked}
aria-label={ariaLabel}
disabled={disabled}
type="checkbox"
/>
Expand Down
13 changes: 11 additions & 2 deletions packages/react/ds/src/table/caption.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import React from 'react';

export function Caption(props: React.PropsWithChildren) {
return <caption>{props.children}</caption>;
type CaptionProps = {
children: React.ReactNode;
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
};

export function Caption({ children, size = 'lg' }: CaptionProps) {
return (
<caption className={`gi-text-left gi-mb-4 gi-font-bold gi-text-${size}`}>
{children}
</caption>
);
}
15 changes: 13 additions & 2 deletions packages/react/ds/src/table/table-data.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import React from 'react';
import { cn } from '../cn.js';

export function TableData(props: React.PropsWithChildren) {
return <td>{props.children}</td>;
interface TableDataProps extends React.PropsWithChildren {
className?: string;
colSpan?: number;
}

export function TableData({ children, className, colSpan }: TableDataProps) {
const baseClasses = 'gi-table-td';
return (
<td className={cn(baseClasses, className)} colSpan={colSpan}>
{children}
</td>
);
}
2 changes: 1 addition & 1 deletion packages/react/ds/src/table/table-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

export function TableHeader(props: React.PropsWithChildren) {
return <th>{props.children}</th>;
return <th className="gi-table-th">{props.children}</th>;
}
8 changes: 6 additions & 2 deletions packages/react/ds/src/table/table-row.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react';

export function TableRow(props: React.PropsWithChildren) {
return <tr>{props.children}</tr>;
interface TableRowProps extends React.PropsWithChildren {
className?: string;
}

export function TableRow({ children, className }: TableRowProps) {
return <tr className={className}>{children}</tr>;
}
Loading

0 comments on commit 18191a7

Please sign in to comment.