-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
feat: introduce scoped css for default styles #493
feat: introduce scoped css for default styles #493
Conversation
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.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
c18a472
to
a3a6136
Compare
…es/tailwind-scoped-css
Kudos, SonarCloud Quality Gate passed!
|
@kaiszybiak Thanks for great description and solution! Yeah, I went with adding to all classes the prefix but your is better, I like it! That I hadn't thought of something similar either 😅 Thanks again, everything looks great :) I also read the discussion in the attached PR in the backstage and don't worry. The |
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.
🚀
🎉 This PR is included in version 1.0.0-next.25 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
We integrate the
asyncapi
component as a plugin into the backstage ecosystem. During the integration of the pre release version containing the switch to tailwind we noticed, that by including the default stylesimport "@asyncapi/react-component/styles/default.css";
those styles where globally applied and had an effect on other components, as they are not scoped (see related PR).This PR is inspired by #381. Our initial idea was to resolve the merge conflicts and go with the CSS prefix solution. (see branch). However the tailwind prefix does not affect:
Our second approach was to use tailwind selector-strategy:
This made the refactoring easier, as we only had to add one id to the container and were not forced to change all of the tailwind utility classes manually but it still had the same problem as the prefix solution, that there where still styles applied globally e.g.
Solution
We scope all CSS by using the
postcss
plugin postcss-scopify. The default styles will only affect theasyncapi
component. There is a slightly difference between the following screenshots, as thedefault.css
doesn't affect theCodeMirror
component anymore.Essentially all styles stay the same only styles applied to
html
andbody
do not have an effect anymore as they are scoped but the scoping class.aui-root
is applied some levels deeper to theAsyncApiLayout
.Before:

After:

Changes proposed in this pull request:
postcss
plugin postcss-scopifyaui-root
as a scoped class to theAsyncApiLayout
componentleading-normal
to match the line-height applied before to the html tag by@tailwind base
Related issue
Resolves #369
See also #381