TPS-1470: Decouple KPI trend arrow direction from positive/negative colors - #424
Conversation
…olors KpiChart/KpiChartChange gain a new optional `reverseTrendDirection` prop, and KpiTrend gains a new optional `invertColor` prop. Both default to mirroring the existing `invertChangeColors`/`reverseTrend` value, so current consumers keep looking exactly the same until they opt in to setting color and arrow direction independently. Companion change to embeddable-hq/remarkable-pro#279, which adds a "Reverse trend direction" input to KpiChartNumberComparisonPro and LineChartComparisonWithKpiTabsPro and is ready to wire into this new prop once this ships.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (9)
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. WalkthroughThe KPI trend components now control arrow direction and badge color independently. New optional props preserve existing behavior by default. Tests and Storybook coverage validate the separate controls. ChangesKPI trend controls
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The new optional controls retain prior defaults while allowing direction and color to be configured independently. No merge-blocking issue is identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…ency KpiTrend already had `reverseTrend` for direction; the new color prop should use the same verb rather than mixing "invert"/"reverse" on the same component. `invertChangeColors` on KpiChart/KpiChartChange is unchanged (already-published API).
…stency with invertChangeColors
Addresses SonarCloud warnings on KpiChartChange.tsx (use the opposite operator instead of !(a !== b)). Logically equivalent, no behavior change.
|



Why is this pull-request needed?
Consumers of
KpiChart/KpiTrendcan only toggle a singleinvertChangeColors/reverseTrendboolean, which drives both the trend badge's color (positive/negative) and its arrow icon direction together. A customer usingKpiChartNumberComparisonPro(inembeddable-hq/remarkable-pro) wanted to reverse the colors without also flipping the arrow, which isn't possible today.Main changes
KpiTrendgains a new optionalreverseColorprop that controls the badge color independently ofreverseTrend(which now controls only the arrow icon direction).reverseColordefaults toreverseTrend, so any existing usage that only passesreverseTrendrenders identically to before. (Named to match the existingreverseTrendprop on the same component, rather than introducing a different verb.)KpiChartChange(andKpiChart, which wraps it) gain a new optionalinvertTrendDirectionprop. It defaults to mirroringinvertChangeColorswhen not provided, so nothing changes for existing consumers until they explicitly set it. (invertChangeColorsitself is unchanged — it's already-published API.)IncreasingWithReversedColorOnly) andargTypescontrol demonstrating the decoupledreverseColor.minor, since this is a purely additive, backwards-compatible API change).Companion change: embeddable-hq/remarkable-pro#279 adds a "Reverse trend direction" input to
KpiChartNumberComparisonProandLineChartComparisonWithKpiTabsPro, with backwards-compatible config migration, ready to wire intoinvertTrendDirectiononce this is released.Test evidence
Ran the full repo suite locally: lint (
eslint:fix),prettier:write, type-check (tsc --noEmit),npm run build(tsup, including.d.tsgeneration), andnpm test— all tests pass (840 baseline + new coverage forKpiTrend,KpiChartChange, andKpiChart), across 67 files.madge --circularreports no circular dependencies.https://www.loom.com/share/e6283cbbdca24d7db6633c688b952224