Repository navigation
fix(deck): compile all color scale properties on a layer - #781
Conversation
Signed-off-by: Ihor Dykhta <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds support for multiple color-scale accessors per layer. It updates color-scale detection, JSON config compilation, and legend extraction to process all matching accessors, and adds tests for multi-accessor layers and legend behavior. ChangesMultiple color scale support
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Ihor Dykhta <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c5509035f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/deck/src/json/colorScaleFunction.ts (1)
34-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing tsdoc on new exported API surface.
ColorScalePropName,getColorScale, andgetAllColorScalesare new/modified exported symbols with no tsdoc.As per coding guidelines, "Add tsdoc to exported types and functions in
@sqlrooms/*packages."📝 Example tsdoc additions
+/** Names of layer accessor props that can carry a color scale. */ export type ColorScalePropName = | 'getFillColor' | 'getLineColor' | 'getColor' | 'getSourceColor' | 'getTargetColor'; +/** + * Returns the first color scale entry found on the layer props, if any. + * `@deprecated` Prefer {`@link` getAllColorScales} when a layer may define multiple color scale accessors. + */ export function getColorScale(props: Record<string, unknown>): ... +/** Returns every color scale entry found across all known accessor props on the layer. */ export function getAllColorScales(props: Record<string, unknown>): Array<{🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/deck/src/json/colorScaleFunction.ts` around lines 34 - 59, Add tsdoc for the new exported API in colorScaleFunction.ts: document ColorScalePropName, getColorScale, and getAllColorScales. Use concise tsdoc comments on each exported type/function describing what color scale properties they cover and what each function returns, keeping the docs aligned with the existing getAllColorScales/getColorScale behavior.Source: Coding guidelines
packages/deck/src/json/extractColorScaleLegends.ts (1)
53-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo test coverage for multi-scale legend extraction.
extractColorScaleLegendsnow loops and builds a legend per color scale, but onlycreateDeckJsonConfiguration.test.tsgained multi-accessor tests; no test exercises this file's new looping/per-legend error-handling behavior (e.g. a layer withgetFillColor+getLineColor, orgetSourceColor+getTargetColor, producing two distinct legends).As per coding guidelines, "Add or update tests when changing behavior or public API, when practical."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/deck/src/json/extractColorScaleLegends.ts` around lines 53 - 119, Add tests for extractColorScaleLegends to cover the new per-color-scale loop and fallback behavior. In the tests for extractColorScaleLegends, use a layer with multiple resolved color scales (for example getFillColor plus getLineColor, or getSourceColor plus getTargetColor) and assert that it returns a separate legend for each scale. Also verify the error-handling path by making one color scale fail in buildColorScaleLegend while another succeeds, and confirm the successful legend is still returned.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/deck/src/json/colorScaleFunction.ts`:
- Around line 34-59: Add tsdoc for the new exported API in
colorScaleFunction.ts: document ColorScalePropName, getColorScale, and
getAllColorScales. Use concise tsdoc comments on each exported type/function
describing what color scale properties they cover and what each function
returns, keeping the docs aligned with the existing
getAllColorScales/getColorScale behavior.
In `@packages/deck/src/json/extractColorScaleLegends.ts`:
- Around line 53-119: Add tests for extractColorScaleLegends to cover the new
per-color-scale loop and fallback behavior. In the tests for
extractColorScaleLegends, use a layer with multiple resolved color scales (for
example getFillColor plus getLineColor, or getSourceColor plus getTargetColor)
and assert that it returns a separate legend for each scale. Also verify the
error-handling path by making one color scale fail in buildColorScaleLegend
while another succeeds, and confirm the successful legend is still returned.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5be8aff6-b4c9-47be-9108-68cba21d5af8
📒 Files selected for processing (4)
packages/deck/__tests__/createDeckJsonConfiguration.test.tspackages/deck/src/json/colorScaleFunction.tspackages/deck/src/json/createDeckJsonConfiguration.tspackages/deck/src/json/extractColorScaleLegends.ts
Signed-off-by: Ihor Dykhta <[email protected]>
Previously
applyColorScaleonly resolved the first color scale property found on a layer. If a layer defined bothgetFillColorandgetLineColor(orgetSourceColor/getTargetColoron arc layers) as color scales, only the first was compiled — the second remained unresolved.getAllColorScales()and loop inapplyColorScaleto compile every color scale propertyextractColorScaleLegendsto render legends for all color scale propertiesSummary by CodeRabbit