-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
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.
@@ -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); |
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.
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 |
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.
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} |
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.
use undefined
instead of null
in cases like this please
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.
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++) { |
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.
Looks like an unnecessary space after -1
This change will require some clever changes to SelectionTests
The blasphemy!
To fix the corner radius clipping caused by
I suppose it can also apply to other types of cells that need centering |
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.
pointer-events: none; | ||
} | ||
|
||
@mixin vertical-align() { |
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.
thing is, vertical-align
is an actual CSS property which this mixin has nothing to do with.
vertical-center
?
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're right that's confusing. renaming!
.pt-skeleton { | ||
opacity: 0; | ||
height: $pt-grid-size / 2; | ||
height: $skeleton-height * 1px; |
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.
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 { |
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.
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...
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.
looking really good! a few questions below
.pt-skeleton { | ||
opacity: 0; | ||
height: $pt-grid-size / 2; | ||
height: $pt-grid-size * 0.5; |
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 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); |
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.
whoa why the freaky padding?
i'd expect vertical-center
to center correctly, to not require 1px adjustments.
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.
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)
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.
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.
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.
also, what's wrong with 8px instead of 7? even numbers are easier.
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 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; |
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.
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; |
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.
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) { |
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.
Isn't &:not([class*="pt-intent-"], .pt-loading)
valid?
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.
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
e7478c1
to
501c580
Compare
9e59aa4
to
c44faf8
Compare
@@ -62,3 +62,9 @@ $cell-transition-duration: $pt-transition-duration * 3; | |||
cursor: $select-cell-cursor; | |||
} | |||
} | |||
|
|||
@mixin cell-content-align-vertical() { |
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.
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?
@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); |
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.
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.
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.
alternately, just set the super simple padding: $pt-grid-size;
to ensure space on all sides, and let flex box handle the actual centering.
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.
done
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"vsicons.presets.angular": 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.
what happened to reverting this?
22c337e
to
13bedbb
Compare
reverted the .vscode/settings change! |
Checklist
pt-skeleton
class on their header cell children