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(component): use ReactNode for table actions #478

Merged
merged 1 commit into from
Dec 9, 2020
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/big-design/src/components/StatefulTable/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ test('sorts using a custom sorting function', () => {
});

test('renders custom actions', () => {
const { getByTestId } = render(getSimpleTable({ actions: () => <div data-testid="customAction">Test Action</div> }));
const { getByTestId } = render(getSimpleTable({ actions: <div data-testid="customAction">Test Action</div> }));

const customAction = getByTestId('customAction');

Expand Down
6 changes: 2 additions & 4 deletions packages/big-design/src/components/Table/Actions/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TableItem, TablePaginationProps, TableSelectable } from '../types';
import { StyledFlex } from './styled';

export interface ActionsProps<T> {
customActions?: React.ComponentType<any>;
customActions?: React.ReactNode;
forwardedRef: RefObject<HTMLDivElement>;
itemName?: string;
items: T[];
Expand Down Expand Up @@ -51,9 +51,7 @@ const InternalActions = <T extends TableItem>({
};

const renderActions = () => {
const CustomActions = customActions;

return CustomActions ? <CustomActions /> : null;
return customActions ?? null;
};

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/big-design/src/components/Table/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ describe('sortable', () => {

test('renders custom actions', () => {
const { getByTestId } = render(
<Table columns={columns} items={items} actions={() => <div data-testid="customAction">Test Action</div>} />,
<Table columns={columns} items={items} actions={<div data-testid="customAction">Test Action</div>} />,
);

const customAction = getByTestId('customAction');
Expand Down
2 changes: 1 addition & 1 deletion packages/big-design/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface TableColumn<T> {
export type TablePaginationProps = Omit<PaginationProps, keyof MarginProps>;

export interface TableProps<T> extends React.TableHTMLAttributes<HTMLTableElement> {
actions?: React.ComponentType<T>;
actions?: React.ReactNode;
columns: Array<TableColumn<T>>;
emptyComponent?: React.ReactElement;
headerless?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/PropTables/StatefulTablePropTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const statefulTableProps: Prop[] = [
},
{
name: 'actions',
types: 'React.ComponentType<any>',
types: 'React.ReactNode',
description: 'Component to render custom actions.',
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/PropTables/TablePropTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const tableProps: Prop[] = [
},
{
name: 'actions',
types: 'React.ComponentType<any>',
types: 'React.ReactNode',
description: 'Component to render custom actions.',
},
{
Expand Down