Skip to content

Conversation

adamwoodnz
Copy link
Contributor

@adamwoodnz adamwoodnz commented Sep 4, 2025

Fixes CHARTS-110: Leaderboard Chart: Make theming consistent with other charts

Proposed changes:

  • Updates the LeaderboardChart component to support Global Context theming, making it consistent with other chart types
  • Custom colors are still supported
  • Updates the shipped themes to better align with Woo Analytics and expectations for the default theme

Screenshots

Leaderboard Chart Context
Screenshot 2025-09-04 at 4 59 30 PM Screenshot 2025-09-04 at 4 59 51 PM

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

@adamwoodnz adamwoodnz changed the title Charts 110 leaderboard chart make theming consistent with other charts Leaderboard chart: make theming consistent with other charts Sep 4, 2025
@adamwoodnz adamwoodnz self-assigned this Sep 4, 2025
Copy link
Contributor

github-actions bot commented Sep 4, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the charts-110-leaderboard-chart-make-theming-consistent-with-other-charts branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack charts-110-leaderboard-chart-make-theming-consistent-with-other-charts

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Sep 4, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 4, 2025
background-color: var(--bar-color, #3858e9);

border-radius: var(--bar-border, 9999px);
border-radius: var(--a8c--charts--leaderboard--bar--border-radius, 9999px);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace this custom var to avoid conflicts due to generic naming. Pattern follows that used in WordPress components.

Copy link

jp-launch-control bot commented Sep 4, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/js-packages/charts/src/components/leaderboard-chart/leaderboard-chart.tsx 24/25 (96.00%) -4.00% 1 ❤️‍🩹
projects/js-packages/charts/src/providers/chart-context/global-charts-provider.tsx 33/33 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@adamwoodnz adamwoodnz force-pushed the charts-110-leaderboard-chart-make-theming-consistent-with-other-charts branch from 0717309 to f96d339 Compare September 4, 2025 04:47
Comment on lines -40 to -46
.primaryBar {
--bar-color: var(--primary-color, #3858e9);
}

.secondaryBar {
--bar-color: var(--secondary-color, #66bdff);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fallback colors are not consistent with the default theme (which is based on Jetpack colors), and the CSS approach isn't used elsewhere. I could see us using Design System variables (like --wpds--background--primary...) in future, but for now I think consistency is more important.

@@ -452,41 +439,6 @@ export const AdvancedFormatting: Story = {
},
};

// Themed stories
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The themeName control works for all stories now, so these are redundant

Comment on lines -41 to +43
primaryColor: '#3858E9',
secondaryColor: '#80C8FF',
deltaColors: [ '#D63638', '#757575', '#008A20' ], // [negative, neutral, positive]
primaryColor: '#006DAB',
secondaryColor: '#98C8DF',
deltaColors: [ '#FF8C8F', '#757575', '#1F9828' ], // [negative, neutral, positive]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing these from the Woo colors to the Jetpack colors, to match the rest of the default theme colors. They look very out of place when all charts are using the same theme.

Comment on lines 126 to 132
colors: [
'#3858E9', // WooCommerce brand blue
'#66BDFF', // Light blue
'#873EFF', // Purple
'#7B90FF', // Periwinkle blue
'#EB6594', // Pink/rose
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the colors from Next Woo Analytics, with the second and third colors switched, as the light blue seems to be the true secondary color looking at the widgets there.

@adamwoodnz adamwoodnz added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Sep 4, 2025
@adamwoodnz adamwoodnz force-pushed the charts-110-leaderboard-chart-make-theming-consistent-with-other-charts branch 2 times, most recently from 771975c to db03cd6 Compare September 4, 2025 05:28
@adamwoodnz adamwoodnz requested a review from Copilot September 4, 2025 05:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the LeaderboardChart component to use the Global Context theming system, making it consistent with other chart components. The change enables automatic theme integration while maintaining support for custom color overrides.

  • Updates LeaderboardChart to support Global Context theming and Legend composition
  • Modifies default theme colors to better align with Woo Analytics expectations
  • Removes hardcoded color values and integrates with the centralized theme system

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
leaderboard-chart.tsx Refactored to use GlobalChartsProvider and resolveGroupColor for theme integration
leaderboard-chart.module.scss Simplified CSS by removing color-specific classes and using inline styles
themes.ts Updated default theme colors for leaderboard and expanded Woo theme color palette
stories/index.stories.tsx Removed hardcoded colors from stories to demonstrate theme integration
theme-config.tsx Added leaderboard theme configuration to custom theme example
chart-context/stories/index.stories.tsx Added LeaderboardChart examples to chart context stories
changelog Added changelog entry documenting the theme integration change

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -18,7 +19,7 @@ export const GlobalChartsProvider: FC< GlobalChartsProviderProps > = ( {
} ) => {
const [ charts, setCharts ] = useState< Map< string, ChartRegistration > >( () => new Map() );

const providerTheme: ChartTheme = useMemo( () => ( { ...defaultTheme, ...theme } ), [ theme ] );
const providerTheme: ChartTheme = useMemo( () => mergeThemes( defaultTheme, theme ), [ theme ] );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a deepmerge ensures nested properties are preserved

/**
* Default settings for LeaderboardChart component
*/
const DEFAULT_LEADERBOARD_SETTINGS = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are guaranteed to come from the theme now that we're using the global theme

@adamwoodnz adamwoodnz marked this pull request as ready for review September 4, 2025 22:46
@adamwoodnz adamwoodnz requested a review from a team September 4, 2025 22:46
@adamwoodnz adamwoodnz force-pushed the charts-110-leaderboard-chart-make-theming-consistent-with-other-charts branch from e854358 to d54f825 Compare September 4, 2025 22:49
@annacmc annacmc added the [Status] Needs Review This PR is ready for review. label Sep 4, 2025
annacmc
annacmc previously approved these changes Sep 4, 2025
Copy link
Contributor

@annacmc annacmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good and tests out well for me, love it! Just one small non-blocking question but otherwise nice job. Always a great feeling to remove more lines than you add 😄

withComparison: true,
withOverlayLabel: true,
loading: false,
primaryColor: '#ddd',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, just curious to understand why we aren't using one of the default theme colours for the primaryColor here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good question, the story needs a neutral or low opacity color to look good and I couldn't find one in the palette. Updated now to use a tint of the primary color like the design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[JS Package] Charts RNA [Status] In Progress [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants