Add cellStyleRevision prop for animated cell styling - #9
Closed
tothienbao6a0 wants to merge 2 commits into
Closed
Conversation
Adds an optional `getCellStyle` viewer prop that returns CSS overrides merged on top of each cell's resolved style. This is a generic escape hatch for per-cell styling (highlights, outlines, status tints) without forking the workbook data. The hook is applied at the single getCellData chokepoint so both the DOM and canvas renderers honor it, and is wired into the cell render cache invalidation so changing the callback re-resolves and repaints cells. The callback receives an XlsxCellStyleContext with the cell address, sheet, resolved style, value, and flags (validation, hyperlink, conditional format, chart highlight, merge, table header). Also adds a "Highlight" toggle to the playground demonstrating the prop and documents it in both READMEs. Co-authored-by: Cursor <cursoragent@cursor.com>
Adds an optional `cellStyleRevision` viewer prop. Bumping the counter forces the viewer to re-run `getCellStyle` and repaint cells, so consumers can animate or refresh custom cell styling while keeping a stable `getCellStyle` callback (store transient state in a ref, update it from a rAF loop or timer, and bump the revision to flush). Wired into the same getCellData chokepoint and cache invalidation as `getCellStyle` so both the DOM and canvas renderers repaint. Adds an "Animate" toggle to the playground and documents the pattern in the READMEs. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@tothienbao6a0 is attempting to deploy a commit to the Extend Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Jun 18, 2026
Contributor
Author
|
Withdrawing this from upstream for now — keeping it as a personal/experimental branch. The generally-useful capability is #8 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
cellStyleRevisionprop toXlsxViewer. Bumping the counter forces the viewer to re-rungetCellStyleand repaint cells, so consumers can animate or refresh custom cell styling while keeping a stablegetCellStylecallback.The pattern: store transient styling state in a ref, update it (e.g. from a
requestAnimationFrameloop or timer), and bumpcellStyleRevisionto flush the new styles.Why
getCellStyle(#8) re-resolves whenever the callback identity changes. For animation you'd otherwise have to recreate the callback every frame, which is non-obvious and creates churn.cellStyleRevisionis an explicit, cheap animation primitive: keep the callback memoized and bump a number.Note
Stacked on #8 (
getCellStyle). Please review/merge that first — this PR's diff includes that commit until #8 lands, after which it will show only thecellStyleRevisioncommit.cellStyleRevisionhas no effect withoutgetCellStyle.Implementation
getCellDatachokepoint and cache invalidation asgetCellStyle, so a revision bump re-resolves styles and repaints both the DOM and canvas renderers.cellStyleRevisionis intentionally agetCellDatadependency (commented in code): a new value givesgetCellDataa new identity, which clears the cell render cache and triggers a canvas repaint and DOM row re-render.Changes
cellStyleRevisionprop onXlsxViewerPropsXlsxViewerInner→XlsxGrid→ cache invalidation +getCellDatacellStyleRevisionTest plan
pnpm typecheck(package + playground)pnpm build(package)Made with Cursor