Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Apr 3, 2024
1 parent 6a5cc77 commit fc45cba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Blocks/DataTable/variations/DefaultTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { capitalize } from 'lodash';
import { Icon } from '@plone/volto/components';
import { Menu, Loader } from 'semantic-ui-react';

import { defaultColDef } from '@eeacms/volto-block-data-table/config';
import Table from '@eeacms/volto-block-data-table/Table';

import leftSVG from '@plone/volto/icons/left-key.svg';
Expand Down Expand Up @@ -33,6 +34,7 @@ const DefaultView = (props) => {
rows={rows}
fields={fields}
columnDefs={columnDefs}
defaultColDef={defaultColDef}
withHeaders={withHeaders}
TableProps={TableProps}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/CellRenderers/CellRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const CellRenderer = (props) => {
const TableCell = tableCell ? Table.Cell : Fragment;

return (
<TableCell>
<TableCell style={{ minWidth: colDef.minWidth }}>
<CellRenderer {...props} value={value} />
</TableCell>
);
Expand Down
16 changes: 12 additions & 4 deletions src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@ const ColumnHeader = components.columnHeader;
const CellRenderer = components.cellRenderer;

export default (props) => {
const { rows, columnDefs, withHeaders, TableProps } = props;
const { rows, columnDefs, defaultColDef, withHeaders, TableProps } = props;
const { celled, striped, borderless, compacted } = TableProps || {};

return (
<Table
className={cx('data-table', {
className={cx('data-table unstackable', {
borderless,
compacted,
})}
celled={celled}
striped={striped}
stackable={false}
>
{withHeaders && (
<Table.Header>
<Table.Row>
{columnDefs.map((colDef) => (
<ColumnHeader key={colDef.field} colDef={colDef} />
<ColumnHeader
key={colDef.field}
colDef={{ ...defaultColDef, ...colDef }}
/>
))}
</Table.Row>
</Table.Header>
Expand All @@ -35,7 +39,11 @@ export default (props) => {
{rows.map((row) => (
<Table.Row key={row.id}>
{columnDefs.map((colDef) => (
<CellRenderer key={colDef.field} colDef={colDef} row={row} />
<CellRenderer
key={colDef.field}
colDef={{ ...defaultColDef, ...colDef }}
row={row}
/>
))}
</Table.Row>
))}
Expand Down
4 changes: 4 additions & 0 deletions src/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ export const renderers = {
skeleton: 'skeletonCellRenderer',
},
};

export const defaultColDef = {
minWidth: 100,
};
2 changes: 2 additions & 0 deletions src/table.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
}

.data-table-block {
overflow-x: auto;

.ui.menu.pagination {
display: flex;
justify-content: center;
Expand Down

0 comments on commit fc45cba

Please sign in to comment.