Skip to content

Kpi delta theme tokens#9029

Draft
ericokuma wants to merge 4 commits intomainfrom
cursor/PM-129-kpi-delta-theme-tokens-2f61
Draft

Kpi delta theme tokens#9029
ericokuma wants to merge 4 commits intomainfrom
cursor/PM-129-kpi-delta-theme-tokens-2f61

Conversation

@ericokuma
Copy link
Contributor

This PR introduces text-kpi-positive and text-kpi-negative theme tokens to allow customers to customize the colors of positive and negative delta/comparison values in dashboards. This addresses visual asymmetry where positive deltas were gray while negative were red, improving dashboard scanability and meeting customer requests for green positive values.

By default, the new tokens preserve current behavior (gray for positive, red for negative) for a safe, opt-in rollout. Customers can customize these colors (e.g., green for positive) via their theme.yaml file.

Changes include:

  • Defining --kpi-positive and --kpi-negative CSS variables in app.css with defaults.
  • Adding kpi.positive and kpi.negative to tailwind.config.ts.
  • Updating theme.ts and parse_theme.go to expose these tokens for theme configuration.
  • Replacing hardcoded text-red-500 and text-fg-secondary with the new KPI tokens in MeasureChange.svelte, PercentageChange.svelte, KPI.svelte, MeasureBigNumber.svelte, LeaderboardRow.svelte, and PivotDeltaCell.svelte.
  • Adding a parser test for the new theme variables.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Linear Issue: PM-129

Open in Web Open in Cursor 

…lta coloring

Introduce two semantic CSS theme tokens for KPI delta/comparison values:
- text-kpi-positive: defaults to text-fg-secondary (gray) — no visual change
- text-kpi-negative: defaults to text-red-500 (red) — no visual change

Customers can opt in to green-for-positive by overriding kpi-positive in
their theme YAML config (e.g., kpi-positive: '#16a34a').

Changes:
- app.css: define --kpi-positive and --kpi-negative CSS vars (light + dark)
- tailwind.config.ts: add kpi color object for Tailwind utilities
- theme.ts: add kpi-positive/kpi-negative to Colors type
- parse_theme.go: whitelist kpi-positive/kpi-negative in allowedCSSVariables
- parser_test.go: add test for KPI semantic variables

Updated components:
- MeasureChange.svelte: text-red-500 → text-kpi-negative, text-fg-secondary → text-kpi-positive
- PercentageChange.svelte: text-destructive → text-kpi-negative, add text-kpi-positive
- KPI.svelte: text-red-500 → text-kpi-negative, add text-kpi-positive
- MeasureBigNumber.svelte: text-red-500 → text-kpi-negative, add text-kpi-positive
- LeaderboardRow.svelte: text-red-500 → text-kpi-negative, add text-kpi-positive
- PivotDeltaCell.svelte: text-destructive → text-kpi-negative, text-fg-secondary → text-kpi-positive

Resolves PM-129

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Mar 11, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

…tive

All components now use three-way checks (positive / negative / neutral)
so zero-change values stay gray even when a customer overrides
kpi-positive to green. Matches the acceptance criterion that
zero/neutral values remain text-fg-secondary.

Components fixed:
- MeasureChange.svelte: add isValuePositive flag, zero → text-fg-secondary
- PercentageChange.svelte: add diffIsPositive flag, zero → text-fg-secondary
- KPI.svelte: percent > 0 (was >= 0), zero → text-fg-disabled fallback
- MeasureBigNumber.svelte: diff > 0 (was >= 0), add isComparisonNegative

PivotDeltaCell.svelte and LeaderboardRow.svelte already handled zero
correctly with three-way logic.

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@ericokuma ericokuma requested review from djbarnwal and royendo March 11, 2026 21:53
Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@royendo
Copy link
Contributor

royendo commented Mar 11, 2026

Correct me if im wrong, but i dont think kpi-positive is surfaced in theme.yaml.

getting
invalid light theme: invalid CSS variable: "kpi-positive"

when trying to define it.

dont forget to have it auto populate a theme.yaml when creating it and surfacing it here so users can change the color.

Add KPI delta color tokens to all places where users discover theme
variables:

- new-files.ts: scaffold template shows kpi-positive/kpi-negative as
  commented-out options in both light and dark sections
- AI instructions (theme.md): add KPI delta color examples
- Reference docs (themes.md): add example theme with KPI delta colors

This ensures users creating a new theme immediately see the option to
customize positive/negative delta colors.

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@royendo
Copy link
Contributor

royendo commented Mar 12, 2026

  1. When creating a theme.yaml from the Add More Themes, the two new keys are not added to light or dark mode

but manually adding works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants