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

refactor(table): Add modalContentRenderer prop #371

Merged
merged 1 commit into from
Jul 24, 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
3 changes: 3 additions & 0 deletions src/lib/components/table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ const story = {
hideColumns: {
subContent: 'This property allows to hide defined columns by index.',
},
modalContentRenderer: {
subContent: 'This property allows to render custom modal content.',
},
onSelectionChanged: {
subContent:
'This event is triggered when a selection is changed. It receives the index of the selection as an argument.',
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface TableProps {
hideColumns?: number[];
hideDetails?: boolean;
imageComponent?: (args: any) => JSX.Element;
modalContentRenderer?: (content: ReactNode) => ReactNode;
onModalOpen?: ModalFunction;
onSelectionChanged?: (index: number) => void;
stickyHeaderTopOffset?: number;
Expand All @@ -53,6 +54,7 @@ const Table = ({
hideColumns = [],
hideDetails,
imageComponent,
modalContentRenderer,
onModalOpen,
onSelectionChanged,
stickyHeaderTopOffset = 0,
Expand Down Expand Up @@ -185,7 +187,11 @@ const Table = ({
title={infoModalData?.title}
onClose={() => setInfoModalData(null)}
>
<div className="pt8 p24 wmn6">{infoModalData?.body}</div>
<div className="pt8 p24 wmn6">
{modalContentRenderer
? modalContentRenderer(infoModalData?.body)
: infoModalData?.body}
</div>
</BottomOrRegularModal>
</div>
);
Expand Down
Loading