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
fix(flamegraph): fix its styling #1388
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1388 +/- ##
==========================================
+ Coverage 67.60% 67.66% +0.06%
==========================================
Files 123 123
Lines 4040 4047 +7
Branches 930 932 +2
==========================================
+ Hits 2731 2738 +7
Misses 1305 1305
Partials 4 4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
size-limit report 📦
|
/create-server |
/create-server |
56009a9
to
d34f3b4
Compare
/create-server |
/create-server |
@@ -0,0 +1,38 @@ | |||
name: Storybook |
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.
storybook is back! ❤️
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.
Interesting solution! LGTM
@pyroscope/flamegraph
andwebapp
have the same styling rules (mostly the normalization ones)sanitize.css
, for some reason I could make it so that a nestedimport ~sanitize.css
would be inlined (tried with postcss plugin and nothing)The original problem is that the webapp and flamegraph (standalone) shipped different sets of CSS. Which means it would look just fine in webapp (which is what most people would be running), then in the standalone version (imported via
@pyroscope/flamegraph
package), it would look slightly off.Turns out the difference is that the flamegraph was not shipping the styles from normalize.css.
However, we can't just ship those styles, since they are global and they may affect end user's style (imagine I embed the flamegraph into my component, and then somehow it overrides my app's button!).
Therefore we need to scope those rules.
However, if we scope those rules, then they start to override the ones from css modules. The reason is simple.
Consider a sanitize.css rule for
table
:If we scope under
.pyroscope
it will become:Then let's say we have a css modules rule, which normally would override the one from sanitize css (since class has higher precedence over a simple tag)
In our case,
.pyroscope table
is higher than.oiJX5Zp1+W8aJOcWSU-baQ==
, therefore our css module style would never be applied.To "solve" this I ended up using a "custom" element (not confuse with real custom elements), here called
pyro-flamegraph
.That way,
pyro-flamegraph table
still has a lower specificity than.oiJX5Zp1+W8aJOcWSU-baQ==
, restoring the original behavior of having classes generated by CSS modules to overwrite the styles from the reset.Disclaimer
This may break for people that assume the flamegraph component has a certain shape, eg in snapshot tests.
Since we publish the component as < 1.0.0, I won't publish as a breaking change (even though it is).