-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[APM] Use theme variables for components #68157
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
💚 CLA has been signed |
Not sure about the refresh time on your CLA bot, but it's signed |
Pinging @elastic/apm-ui (Team:apm) |
Thanks a lot @balthazar
We have an issue to setup the ThemeProvider. I'll try to get around to it today. |
retest |
Note to self: Should be merged after #68242 |
@balthazar that would be greatly appreciated! |
@sqren I got lost in translation and refactored every APM component (minus Just like other plugins seemed to import the I think some tests target the light theme colors so as long as these tests use the light theme setting from the There's a lot of things I don't think I can test like the ServiceMap as our company is using the Open-Source plan and not a paid one. Speaking of it, I decided to update the That's a ton of changes so 🐻 with me! Also as a side note I would have loved to be able to import modules using their absolute paths rather than relative and have to count the level of nesting (especially on vim haha), but I know changing something like that for such a codebase is going to be tricky. |
This is simply amazing. Great work @balthazar! I have one nit, that is not required for merging this PR but would be the neat: since we are moving away from higher-order-components (like import { useTheme } from 'styled-components';
function MyComponent() {
const theme = useTheme();
console.log('Current theme: ', theme);
// ...
} WDYT? |
Thanks! 😄 Yeah I also prefer hooks over the HoC, but since that's what I saw was being used most of the time I chose to use that since there would be less risk of it breaking stuff. I think in some cases there is still some classes though, so hooks would not work for those. So I should be able to simply replace the |
Oh yeah, you mean like? const theme = useTheme();
console.log('Current theme: ', theme.eui); |
Yeah, alright going to start the refactor |
@sqren I think that should be it! 😃 While I was at it, I decided to convert I also did a subsequent commit to change the hardcoded white background color to Let me know! |
0489031
to
d973aa2
Compare
This looks great! Me or someone from the team will give this a test drive next week and merge. |
retest |
@balthazar Can you try running the jest test? You might need to update the snapshots.
|
@sqren Updated the snapshots and fixed a syntax error I introduced, lots of the tests are obviously failing since I do not have the Provider setup |
@@ -74,19 +78,19 @@ export function Controls() { | |||
if (cy) { | |||
const eles = cy.nodes(); | |||
cy.animate({ | |||
...animationOptions, | |||
...getAnimationOptions(theme.eui), |
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.
I think you should pass in theme
so we can use EuiTheme
type consistently
...getAnimationOptions(theme.eui), | |
...getAnimationOptions(theme), |
@sqren You're right, I for some reason thought |
If you can post the error here I can try looking into it. |
Well @cauemarcondes asked me to change it to that so it should probably live in another PR as an improvement, because this is working effectively. |
The reason for having the const theme = useContext(ThemeContext); |
@elasticmachine merge upstream |
…ents, since it's been moved to a new component.
retest |
Thanks @ogupte - I've created an issue for optimizing the styles a bit for dark mode, not to block this PR. |
retest |
All eslint and tsc issues in apm should now be fixed. 🤞 that this doesn't affect too many other plugins |
x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestions.js
Outdated
Show resolved
Hide resolved
…/Suggestions.js Co-authored-by: Casper Hübertz <casper@formgeist.com>
retest |
💔 Build Failed
Failed CI StepsBuild metricspage load asset sizeHistory
To update your PR or re-run it, just comment with: |
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.
Overall this looks great - I've updated our dark mode support issue to check all the fixes, and update the list of remaining issues. #30048
Summary
The current APM stacktrace display does not get the current theme variables but rather imports the light theme directly, making it quite unreadable on dark mode:
Assuming the
ThemeProvider
is setup correctly for APM and following other components examples using thetheme
prop, this is what the same stacktrace would look like:For maintainers