Skip to content

Commit

Permalink
feat(Grid): adds separator prop
Browse files Browse the repository at this point in the history
Closes #264
  • Loading branch information
aditya-kumawat committed Aug 20, 2020
1 parent 518cacd commit 9598aac
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/components/organisms/grid/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ export const Cell = (props: CellProps) => {
} = props;

const {
separator,
nestedRows
} = _this.props;

const {
name,
separator,
hidden,
pinned,
cellType = 'DEFAULT'
Expand All @@ -297,7 +297,7 @@ export const Cell = (props: CellProps) => {
'Grid-cell': true,
'Grid-cell--head': head,
'Grid-cell--body': !head,
'Grid-cell--separator': !firstCell && separator,
'Grid-cell--separator': !firstCell && (schema.separator !== undefined ? schema.separator : separator),
'Grid-cell--nestedRow': !head && colIndex === 0 && nestedRows
});

Expand Down
6 changes: 6 additions & 0 deletions core/components/organisms/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export interface GridProps extends BaseProps {
* Shows tooltip on Head Cell hover
*/
headCellTooltip?: boolean;
/**
* Shows left separator to all columns
*
* **Can be override by Column Schema**
*/
separator?: boolean;
}

export class Grid extends React.Component<GridProps> {
Expand Down
1 change: 1 addition & 0 deletions core/components/organisms/list/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface SharedListProps extends BaseProps {
onSelect?: TableProps['onSelect'];
onPageChange?: TableProps['onPageChange'];
headCellTooltip?: TableProps['headCellTooltip'];
separator?: TableProps['separator'];
}

type SyncListProps = SyncProps & SharedListProps;
Expand Down
6 changes: 6 additions & 0 deletions core/components/organisms/list/__stories__/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export const all = () => {
false
);

const separator = boolean(
'separator',
false
);

let dataAttr = {};
if (async) {
dataAttr = {
Expand Down Expand Up @@ -123,6 +128,7 @@ export const all = () => {
type={type}
size={size}
headCellTooltip={headCellTooltip}
separator={separator}
withPagination={withPagination}
paginationType={paginationType}
pageSize={pageSize}
Expand Down
10 changes: 9 additions & 1 deletion core/components/organisms/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ interface SharedTableProps extends BaseProps {
/**
* Shows tooltip on Head Cell hover
*/
headCellTooltip?: boolean;
headCellTooltip?: GridProps['headCellTooltip'];
/**
* Shows left separator to all columns
*
* **Can be override by Column Schema**
*/
separator?: GridProps['headCellTooltip'];
}

const defaultProps = {
Expand Down Expand Up @@ -565,6 +571,7 @@ export class Table extends React.Component<TableProps, TableState> {
type,
size,
headCellTooltip,
separator,
draggable,
nestedRows,
nestedRowRenderer,
Expand Down Expand Up @@ -633,6 +640,7 @@ export class Table extends React.Component<TableProps, TableState> {
type={type}
size={size}
headCellTooltip={headCellTooltip}
separator={separator}
draggable={draggable}
nestedRows={nestedRows}
nestedRowRenderer={nestedRowRenderer}
Expand Down
6 changes: 6 additions & 0 deletions core/components/organisms/table/__stories__/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export const all = () => {
false
);

const separator = boolean(
'separator',
false
);

let dataAttr = {};
if (async) {
dataAttr = {
Expand Down Expand Up @@ -147,6 +152,7 @@ export const all = () => {
type={type}
size={size}
headCellTooltip={headCellTooltip}
separator={separator}
draggable={draggable}
nestedRows={nestedRows}
nestedRowRenderer={nestedRowRenderer}
Expand Down

0 comments on commit 9598aac

Please sign in to comment.