-
Notifications
You must be signed in to change notification settings - Fork 826
Leaderboard chart: make theming consistent with other charts #45067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Leaderboard chart: make theming consistent with other charts #45067
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
background-color: var(--bar-color, #3858e9); | ||
|
||
border-radius: var(--bar-border, 9999px); | ||
border-radius: var(--a8c--charts--leaderboard--bar--border-radius, 9999px); |
There was a problem hiding this comment.
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.
Code Coverage SummaryCoverage changed in 2 files.
|
0717309
to
f96d339
Compare
.primaryBar { | ||
--bar-color: var(--primary-color, #3858e9); | ||
} | ||
|
||
.secondaryBar { | ||
--bar-color: var(--secondary-color, #66bdff); | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
primaryColor: '#3858E9', | ||
secondaryColor: '#80C8FF', | ||
deltaColors: [ '#D63638', '#757575', '#008A20' ], // [negative, neutral, positive] | ||
primaryColor: '#006DAB', | ||
secondaryColor: '#98C8DF', | ||
deltaColors: [ '#FF8C8F', '#757575', '#1F9828' ], // [negative, neutral, positive] |
There was a problem hiding this comment.
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.
colors: [ | ||
'#3858E9', // WooCommerce brand blue | ||
'#66BDFF', // Light blue | ||
'#873EFF', // Purple | ||
'#7B90FF', // Periwinkle blue | ||
'#EB6594', // Pink/rose | ||
], |
There was a problem hiding this comment.
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.
771975c
to
db03cd6
Compare
There was a problem hiding this 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.
projects/js-packages/charts/src/components/leaderboard-chart/leaderboard-chart.tsx
Show resolved
Hide resolved
projects/js-packages/charts/src/components/leaderboard-chart/leaderboard-chart.tsx
Outdated
Show resolved
Hide resolved
@@ -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 ] ); |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
e854358
to
d54f825
Compare
There was a problem hiding this 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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Fixes CHARTS-110: Leaderboard Chart: Make theming consistent with other charts
Proposed changes:
Screenshots
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
group
functionality so those controls don't change anything)