Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading prop on header cells #452

Merged
merged 38 commits into from
Jan 26, 2017
Merged

Conversation

michael-yx-wu
Copy link
Contributor

@michael-yx-wu michael-yx-wu commented Jan 11, 2017

Checklist

  • Works with EditableName
  • Works with children content (spacing only)
    • Users will be responsible with using the pt-skeleton class on their header cell children
  • Update documentation
  • Includes tests

@blueprint-bot
Copy link

Update docs and example

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Fix css syntax bug

Preview: docs | table
Coverage: core | datetime

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

kinda want header skeletons to be a little taller, like the header text itself relative to cell text?

image

@@ -29,7 +29,7 @@ export class LoadableContent extends React.Component<ILoadableContentProps, {}>

public constructor(props: ILoadableContentProps) {
super(props);
this.calculateStyle(props.loading);
this.calculateStyle(props.variableLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

preferable to have this function return the styles instead of setting them internally (#sideeffect).

this.style = this.calculateStyle()

@@ -59,6 +62,15 @@ export interface IColumnHeaderCellProps extends IColumnNameProps, IProps {
isColumnSelected?: boolean;

/**
* If true, the column name (string or `ReactElement`) will be replaced with a fixed-height
Copy link
Contributor

Choose a reason for hiding this comment

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

paren clause is not helpful, please remove. say "column name" to reference the prop, from which the user can infer the typings.

return (
<div className={classes} style={style}>
{this.renderName()}
{this.maybeRenderContent()}
{resizeHandle}
{loading ? null : resizeHandle}
Copy link
Contributor

Choose a reason for hiding this comment

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

use undefined instead of null in cases like this please

Copy link
Contributor

Choose a reason for hiding this comment

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

comments in this file also apply to file below

Use PureRender on Resizable and avoid passing a new function as props on
each render in Table.
for (let property of Object.getOwnPropertyNames(bigSpaceRocks[0])) {
randomNumbers.push(Math.random());
}
for (let i = -1 ; i < numRows * numColumns; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an unnecessary space after -1

@blueprint-bot
Copy link

Shorten row header skeletons

Preview: docs | table
Coverage: core | datetime

@llorca
Copy link
Contributor

llorca commented Jan 12, 2017

To fix the corner radius clipping caused by justify-contents on .bp-table-cell.pt-loading, we can try using an alternate way of centering the skeleton in the cell. Try removing justify-contents from .bp-table-cell.pt-loading, then add the following to .bp-table-cell .pt-skeleton:

position: absolute;
top: 50%;
transform: translateX(-50%);

I suppose it can also apply to other types of cells that need centering

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

webpack errors on circle (these don't fail the build but should be fixed):

image

pointer-events: none;
}

@mixin vertical-align() {
Copy link
Contributor

Choose a reason for hiding this comment

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

thing is, vertical-align is an actual CSS property which this mixin has nothing to do with.

vertical-center?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right that's confusing. renaming!

.pt-skeleton {
opacity: 0;
height: $pt-grid-size / 2;
height: $skeleton-height * 1px;
Copy link
Contributor

Choose a reason for hiding this comment

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

whoa please just expect a unit from the variable. if the variable is called height then it should be usable as a height (ie, has a unit).

}
}

@mixin cell-loading {
Copy link
Contributor

Choose a reason for hiding this comment

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

this mixin is used exactly once (in _cell.scss) but looks very similar to other instances of loading cells. suggests a potential refactor, though i'm not sure what...

@blueprint-bot
Copy link

Remove unused variables

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Add column header loading test

Preview: docs | table
Coverage: core | datetime

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

looking really good! a few questions below

.pt-skeleton {
opacity: 0;
height: $pt-grid-size / 2;
height: $pt-grid-size * 0.5;
Copy link
Contributor

Choose a reason for hiding this comment

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

i much prefer / 2 to * 0.5. why this change?


.bp-table-column-name-text {
@include vertical-center();
padding: ($pt-grid-size * 1.1) $pt-grid-size ($pt-grid-size * 1.2);
Copy link
Contributor

Choose a reason for hiding this comment

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

whoa why the freaky padding?

i'd expect vertical-center to center correctly, to not require 1px adjustments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does center the children content of .bp-table-column-name-text. the default header is 30px high. the problem with a 7px height skeleton is that we need unequal top / bottom padding to make it 30px (i.e. 11px top, 22px bottom)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok gotcha. in that case, would be even better to compute these values from the variable i proposed below. use floor() and ceil() functions to ensure whole pixel values.

Copy link
Contributor

@giladgray giladgray Jan 25, 2017

Choose a reason for hiding this comment

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

also, what's wrong with 8px instead of 7? even numbers are easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the designers were against 8px, too thick. there was a bushy eyebrow meme going on for a while, because that's what it looks like 😛.

padding: ($pt-grid-size * 1.1) $pt-grid-size ($pt-grid-size * 1.2);

.pt-skeleton {
height: $pt-grid-size * 0.7;
Copy link
Contributor

Choose a reason for hiding this comment

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

this would make a good variable. $header-skeleton-height

* will also want to conditionally apply the `.pt-skeleton` class where appropriate.
* @default false
*/
loading?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

huh awkward that it's inconsistent with the rest of the component 😢

@@ -29,7 +29,7 @@ $cell-transition-duration: $pt-transition-duration * 3;
transition: color $cell-transition-duration;

.pt-dark & {
&:not([class*="pt-intent-"]) {
&:not([class*="pt-intent-"]):not(.pt-loading) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't &:not([class*="pt-intent-"], .pt-loading) valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that syntax is proposed in selectors level 4: https://drafts.csswg.org/selectors-4/#negation

in selectors level 3, :not only takes a simple argument. so while this compiles and seems to work in chrome and FF, i'm on the latest stable version for both. i'm going to go with the more verbose syntax for now since it's guaranteed it'll work on older browsers

@blueprint-bot
Copy link

Clean up CSS

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Use floor / ceil instead of custom padding

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Rename vertical center mixin

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Move vertical center mixin to cell/common

Preview: docs | table
Coverage: core | datetime

@@ -62,3 +62,9 @@ $cell-transition-duration: $pt-transition-duration * 3;
cursor: $select-cell-cursor;
}
}

@mixin cell-content-align-vertical() {
Copy link
Contributor

Choose a reason for hiding this comment

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

That clears up naming confusion, and describes what it does: vertically center anything inside a cell. Not specific to loading or header cells. How's that @giladgray?

@blueprint-bot
Copy link

Move vertical center mixin to cell/common

Preview: docs | table
Coverage: core | datetime

@blueprint-bot
Copy link

Rename mixin

Preview: docs | table
Coverage: core | datetime

@include cell-content-align-vertical();
padding: floor(($column-header-min-height - $column-name-text-skeleton-height) / 2)
$pt-grid-size
ceil(($column-header-min-height - $column-name-text-skeleton-height) / 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

this entire property is actually worthless because of the mixin. try removing it and notice how the skeleton becomes perfectly centered (and how it was clearly a pixel off with this padding).

i'd still suggest 8px height cuz even numbers are always better for centering.

Copy link
Contributor

Choose a reason for hiding this comment

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

alternately, just set the super simple padding: $pt-grid-size; to ensure space on all sides, and let flex box handle the actual centering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@blueprint-bot
Copy link

Change header height to 8px

Preview: docs | table
Coverage: core | datetime

"typescript.tsdk": "./node_modules/typescript/lib",
"vsicons.presets.angular": false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened to reverting this?

@blueprint-bot
Copy link

Change header height to 8px

Preview: docs | table
Coverage: core | datetime

@michael-yx-wu
Copy link
Contributor Author

reverted the .vscode/settings change!

@gscshoyru gscshoyru merged commit 9077435 into master Jan 26, 2017
@michael-yx-wu michael-yx-wu deleted the mw/table-header-loading branch January 26, 2017 18:54
@giladgray giladgray mentioned this pull request Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants