Skip to content

Conversation

@mturley
Copy link
Collaborator

@mturley mturley commented Apr 25, 2019

What: Closes #1832

This PR adds:

  • A new property columnTransforms which can be included in a column definition (object in the cells array of a Table) with an array of reactabular transform functions which will apply to every cell in the column (header and body). This complements the existing properties transforms (only applies to header cells) and cellTransforms (only applies to body cells).
  • A new decorator transform called classNames which just applies all of its arguments as classNames to the affected cells.
  • A new export Visibility which includes all the modifiers for column visibility as properties.
  • an example of using these three together to implement hidden/visible column breakpoints in a table.

@priley86
Copy link
Member

looking good!

@mturley mturley force-pushed the 1832-table-column-visibility branch from 78fe6a1 to 2cd439f Compare April 25, 2019 20:27
@patternfly-build
Copy link
Collaborator

PatternFly-React preview: https://1858-pr-patternfly-react-patternfly.surge.sh

…onstants, and hidden/visible breakpoints example

Closes patternfly#1832
@mturley mturley force-pushed the 1832-table-column-visibility branch from 2cd439f to e2b80fa Compare April 26, 2019 17:00
@mturley mturley changed the title feat(Table): Add columnTransforms, visibility decorator, and hidden/visible breakpoint example feat(Table): Add columnTransforms, classNames decorator, Visibility constants, and hidden/visible breakpoints example Apr 26, 2019
@mturley mturley marked this pull request as ready for review April 26, 2019 17:05
@codecov-io
Copy link

codecov-io commented Apr 26, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@08a9ab5). Click here to learn what that means.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1858   +/-   ##
=========================================
  Coverage          ?   82.59%           
=========================================
  Files             ?      622           
  Lines             ?     6849           
  Branches          ?       93           
=========================================
  Hits              ?     5657           
  Misses            ?     1152           
  Partials          ?       40
Flag Coverage Δ
#patternfly3 84.87% <ø> (?)
#patternfly4 79.29% <85.71%> (?)
#patternflymisc 95.68% <ø> (?)
Impacted Files Coverage Δ
...ernfly-4/react-table/src/components/Table/Table.js 88.46% <ø> (ø)
...t-table/src/components/Table/utils/transformers.js 100% <ø> (ø)
...ct-table/src/components/Table/utils/headerUtils.js 100% <100%> (ø)
...rc/components/Table/utils/decorators/classNames.js 75% <75%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08a9ab5...e2b80fa. Read the comment docs.

Copy link
Contributor

@redallen redallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm it works!

import styles from '@patternfly/patternfly/components/Table/table.css';

const pickProperties = (object, properties) =>
properties.reduce((picked, property) => ({ ...picked, [property]: object[property] }), {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a better way to do (and standardize) this across more components than just table, but this works for now.

Copy link
Collaborator Author

@mturley mturley Apr 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I don't think there is a clean way to get a subset of an object's properties. I figured this was nicer than the repetition in my original version:

const {
  hidden,
  hiddenOnSm,
  hiddenOnMd,
  hiddenOnLg,
  hiddenOnXl,
  visibleOnSm,
  visibleOnMd,
  visibleOnLg,
  visibleOnXl
} = styles.modifiers;

export const Visibility = {
  hidden,
  hiddenOnSm,
  hiddenOnMd,
  hiddenOnLg,
  hiddenOnXl,
  visibleOnSm,
  visibleOnMd,
  visibleOnLg,
  visibleOnXl
};

columns: [
{
title: 'Repositories',
columnTransforms: [classNames(Visibility.hidden, Visibility.visibleOnMd, Visibility.hiddenOnLg)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, me too :)

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hidden/visible functionality looks great!!

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlabaj tlabaj merged commit 8f739b6 into patternfly:master Apr 26, 2019
@mturley mturley deleted the 1832-table-column-visibility branch April 27, 2019 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for dropping columns in the Table

8 participants