-
Notifications
You must be signed in to change notification settings - Fork 274
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
Make loading cell able to render a loading skeleton #832
Conversation
import { GridCellKind, type LoadingCell } from "../internal/data-grid/data-grid-types.js"; | ||
import type { InternalCellRenderer } from "./cell-types.js"; | ||
|
||
function getRandomNumber(x: number, y: number): number { |
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.
Would add a function comment saying it maps two number pseudo-randomly to the range [-1, 1] since that's not immediately clear.
@@ -313,6 +313,8 @@ export interface BaseGridCell { | |||
/** @category Cells */ | |||
export interface LoadingCell extends BaseGridCell { | |||
readonly kind: GridCellKind.Loading; | |||
readonly skeletonWidth?: number; | |||
readonly skeletonVariability?: number; |
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.
Think instead of skeletonVariability
, skeletonWidth
should either be a static number
or a dynamic (col: number, row: number) => number
, so it can left up to developer to be pseudo-random or deterministic.
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 callback seems not needed as you get that information inside getCellContent
. The variability is just there to make it easier to achieve semi-organic skeletons without writing your own randomizer. I just didn't want it to be the obvious fallback that people use Math.random() which is rather slow.
} | ||
|
||
const hpad = theme.cellHorizontalPadding; | ||
const rectHeight = 18; |
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.
Is the 18
here based on the current defaults for line height & font size? In that case, could it be calculated from whatever is defined in the theme?
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.
There wasn't a good option I could think of really. Using the cell height - 2*cellVerticalPadding is probably the most consistent method, but it is likely to look bad for some people. The only other things I could think to do were to make it configurable as a theme param, make it configurable as a cell param, or to make it parse the font param (which is a really bad idea).
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've attempting to strike a better balance in the recent commit
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.
LGTM 👍
No description provided.