Skip to content

Commit

Permalink
Merge f1c5c88 into 1f85756
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala authored Feb 4, 2019
2 parents 1f85756 + f1c5c88 commit d8c0b2a
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import React, { Component } from 'react';
import React, { Component, Children, Fragment } from 'react';
import styles from '@patternfly/patternfly-next/components/Table/table.css';
import { css } from '@patternfly/react-styles';
import { mapOpenedRows } from './utils/headerUtils';

const BodyWrapper = (rows) => {
const BodyWrapper = (rows, onCollapse) => {
class TableBody extends Component {
render() {
if (onCollapse) {
return (
<Fragment>
{mapOpenedRows(rows, Children.toArray(this.props.children)).map((oneRow, key) => (
<tbody {...this.props} className={css(oneRow.isOpen && styles.modifiers.expanded)} key={`tbody-${key}`}>
{oneRow.rows}
</tbody>
))}
</Fragment>
)
}
return (
<tbody {...this.props} className={css(
rows.some(row => row.isOpen && !row.hasOwnProperty('parent')) && styles.modifiers.expanded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { AngleDownIcon } from '@patternfly/react-icons';
import { AngleDownIcon, AngleRightIcon } from '@patternfly/react-icons';
import { css } from '@patternfly/react-styles';
import { Button } from '@patternfly/react-core';
import styles from '@patternfly/patternfly-next/components/Table/table.css';
Expand All @@ -19,7 +19,15 @@ const defaultProps = {
const CollapseColumn = ({ children, onToggle, isOpen, className, ...props }) => (
<React.Fragment>
{isOpen !== undefined &&
<Button className={css(className, isOpen && styles.modifiers.expanded)} {...props} variant="plain" aria-label="Details" onClick={onToggle} aria-expanded={isOpen}><AngleDownIcon /></Button>
<Button className={css(className, isOpen && styles.modifiers.expanded)}
{...props}
variant="plain"
aria-label="Details"
onClick={onToggle}
aria-expanded={isOpen}
>
{ isOpen ? <AngleDownIcon /> : <AngleRightIcon /> }
</Button>
}
{children}
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { AngleUpIcon, AngleDownIcon, SortIcon } from '@patternfly/react-icons';
import { LongArrowAltUpIcon, LongArrowAltDownIcon, ArrowsAltVIcon } from '@patternfly/react-icons';
import { css } from '@patternfly/react-styles';
import { tableSortIndicator } from '@patternfly/patternfly-next/components/Table/table.css';

Expand All @@ -25,7 +25,7 @@ export const SortByDirection = {
};

const SortColumn = ({ isSortedBy, children, className, onSort, sortDirection, ...props }) => {
const SortedByIcon = isSortedBy ? (sortDirection === 'asc' ? AngleUpIcon : AngleDownIcon) : SortIcon;
const SortedByIcon = isSortedBy ? (sortDirection === 'asc' ? LongArrowAltUpIcon : LongArrowAltDownIcon) : ArrowsAltVIcon;
return (
<button {...props} className={css(className)} onClick={event => onSort && onSort(event)}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Table extends React.Component {
{...props}
renderers={{
body: {
wrapper: BodyWrapper(rows),
wrapper: BodyWrapper(rows, onCollapse),
row: RowWrapper,
cell: BodyCell
},
Expand Down
Loading

0 comments on commit d8c0b2a

Please sign in to comment.