-
Notifications
You must be signed in to change notification settings - Fork 165
Conversation
import Markdown from 'terra-markdown'; | ||
import ReadMe from 'terra-table/docs/README.md'; | ||
// Component Source | ||
// eslint-disable-next-line import/no-webpack-loader-syntax, import/first, import/no-unresolved, import/extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of disabling just the next-line, eslint allows you to disable blocks of code.
/* eslint-disable import/no-webpack-loader-syntax, import/first, import/no-unresolved, import/extensions */
import TableSrc from '!raw-loader!terra-table/src/Table';
import SingleSelectableRowsSrc from '!raw-loader!terra-table/src/SingleSelectableRows';
import TableHeaderSrc from '!raw-loader!terra-table/src/TableHeader';
....
/* eslint-enable import/no-webpack-loader-syntax, import/first, import/no-unresolved, import/extensions */
packages/terra-table/README.md
Outdated
[![NPM version](http://img.shields.io/npm/v/terra-table.svg)](https://www.npmjs.org/package/terra-table) | ||
[![Build Status](https://travis-ci.org/cerner/terra-core.svg?branch=master)](https://travis-ci.org/cerner/terra-core) | ||
|
||
{insert description} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please update
@@ -0,0 +1,145 @@ | |||
@import './variables'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consolidate this will Table.scss.
packages/terra-table/lib/Table.scss
Outdated
} | ||
|
||
.terra-Table-sort-indicator { | ||
float: right; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/terra-table/src/Table.scss
Outdated
@import './mixins'; | ||
@import './terra-table'; | ||
|
||
[data-column-min-width='tiny'] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these css classes instead of using attribute selectors?
<div> | ||
{display} | ||
<span className={ascSortInd}>{iconUp}</span> | ||
<span className={descSortInd}>{iconDown}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of updating css visibility, can we render only the sort/icon we need?
|
||
const defaultProps = { | ||
isSelected: false, | ||
isSelectable: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep it undefined because, if Table is non-selectable, then there is no need to define this attribute for every row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just remove it from the defaultProps altogether. It'll be undefined if not passed in. I don't think you need to default isSelected either, but you should probably add a default for height
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the default for isSelectable. Cannot add default for height as it will set the maximum height on the row and by default we are not setting restrictions on height
Selectable table rows are not keyboard accessible. |
@@ -0,0 +1,3 @@ | |||
# Themeable Variables | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are no themeable sass variables, this file can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added variables in doc c9b2d68#diff-a2f8fe2900b7404b7406ee8301ba4387R4
/** | ||
* Content to be displayed for the row cell | ||
*/ | ||
display: PropTypes.any.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Change this to content
. It is easier to reason about what this is an matches with other react components we have.
$terra-table-thead-border-width: 1px !default; | ||
$terra-table-tr-border-color: $terra-grey-30 !default; | ||
$terra-table-tr-border-width: 1px !default; | ||
$terra-table-cell-max-height-tiny: 26px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The max-height
and min-width
values should be set in rem units.
Updated the code with changes as per above comments |
|
||
return ( | ||
<td {...customProps} className={contentClassName}> | ||
<div>{content}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to wrap the content in an extra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, the minimum height set on the table cell is the minimum height required by the content in the cell. Therefore in order to restrict the maximum height of the cell I have to add extra div tag.
<Table.HeaderContent content={'Column Heading 3'} key={3} minWidth={'large'} /> | ||
</Table.Header> | ||
<Table.Rows> | ||
<Table.Row key={0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that it's not good practice to set the key equal to the index of the array, and this section of code feels like it's doing just that, even though there isn't a map or forEach function being called. Could we generate unique ids for these keys instead of using the numbers 1, 2, and 3? I used shortid to generate it in one of my code changes for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should leave it up to the user to set keys. Setting a random key is actually worse than just using the index since keys help React identify which items have changed, are added, or are removed.
Check this thread for some more information.
facebook/react#1342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree on that. For this example, it feels too closely like it's setting the key equal to the value of it's array index, which also is not a good practice for assigning keys to react components. I feel like a developer would look at this example, and think that it could use the map function for example, and assign the key equal to the numerical index of that given element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't pay enough attention to see that this is an example. +1 to using non-index keys in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed in commit bb5f8be
import React from 'react'; | ||
import Table from 'terra-table'; | ||
|
||
const shortid = require('shortid'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should consumers be providing these keys rather than us generating them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I know there was some discussion about this before. I just want to understand why we do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are generating the keys in example files only, we are not generating the keys in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still hesitate doing random key generation, even in examples, because we know this is a pattern we don't want to perpetuate. Can we make the examples slightly more meaningful, allowing us to make use of keys that'd make sense? Something like:
<Table isStriped={false}>
<Table.Header>
<Table.HeaderContent content={'Name'} key="NAME" minWidth={'small'} />
<Table.HeaderContent content={'Address'} key="ADDRESS" minWidth={'medium'} />
<Table.HeaderContent content={'Phone'} key="PHONE_NUMBER" minWidth={'large'} />
</Table.Header>
<Table.Rows>
<Table.Row key="PERSON_0">
<Table.RowContent content="John Smith" key="NAME" />
<Table.RowContent content="123 Adams Drive" key="ADDRESS" />
<Table.RowContent content="111-222-3333" key="PHONE_NUMBER" />
</Table.Row>
<Table.Row key="PERSON_1">
<Table.RowContent content="Jane Smith" key="NAME" />
<Table.RowContent content="321 Drive Street" key="ADDRESS" />
<Table.RowContent content="111-222-3333" key="PHONE_NUMBER" />
</Table.Row>
<Table.Row key="PERSON_2">
<Table.RowContent content="Dave Smith" key="NAME" />
<Table.RowContent content="213 Raymond Road" key="ADDRESS" />
<Table.RowContent content="111-222-3333" key="PHONE_NUMBER" />
</Table.Row>
</Table.Rows>
</Table>
We want to get the point across that the key structure should match the schema of whatever data structure is being presented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Tyler's comment. That can allow us to get rid of the additional dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to the war room tomorrow. In my component, I'm finding a need to generate random keys, and so far, this is the best solution I found.
packages/terra-site/package.json
Outdated
@@ -26,6 +26,8 @@ | |||
"react-dom": "^15.4.2", | |||
"react-intl": "^2.2.3", | |||
"react-router": "^3.0.2", | |||
"shortid": "^2.2.8", | |||
"terra-application": "^0.x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are deprecating terra-application
. Please remove this line.
packages/terra-site/package.json
Outdated
@@ -26,6 +26,7 @@ | |||
"react-dom": "^15.4.2", | |||
"react-intl": "^2.2.3", | |||
"react-router": "^3.0.2", | |||
"shortid": "^2.2.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we done some analysis about adding this as a dependency?
packages/terra-table/docs/README.md
Outdated
|
||
<Table isStriped={false}> | ||
<Table.Header> | ||
<Table.HeaderContent display={'Column Heading 1'} key={1} minWidth={'small'} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples are using a content
prop instead of display
. Should this be updated to switch display
prop to content
Summary
Terra Table React Component
Thanks for contributing to Terra.
@cerner/terra
#57