refactor: update styles to use CSS Layers and Scope for better isolation #2504
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the core stylesheet handling in
default-base.cssandfont-awesome.cssto leverage modern CSS features (@layerand@scope) for cleaner style isolation, specifically preventing styles from leaking into.unapicomponents.Changes:
Default Base:
@layer defaultand@scope (:root) to (.unapi).:where(:not(.unapi *))exclusion selectors in favor of a more robust@scopemechanism..Theme--sidebarto:scope.Theme--sidebarto align with the new scoping.Font Awesome:
@layer defaultand@scope (:root) to (.unapi)to ensure icons outside the unapi scope render correctly (fixing an issue in CA where a small number of plugin icons were too small).Reasoning
These changes were primarily made because file-modifications for the new notifications refactor in the api were becoming too tedious and brittle, and I wasn't confident in the direction we were going.
In addition, previous attempts to isolate legacy styles using complex
:not()selectors were becoming unwieldy and causing specificity battles. Using@scopeallows us to explicitly define the "donut scope" for these styles (stopping at.unapi), preventing them from bleeding into the API-driven UI components while maintaining proper cascading for the rest of the interface.@layeris used to lower the specificity of these base styles so they are easier to override when necessary.Resources
You can read more about @scope and @layer in the MDN docs.
Please Note
These changes are not ready to be merged yet. Please coordinate with the API team. @elibosley and @zackspear are aware of both the API and Webgui changes.
Related PRs
api:
- PR (#1860)
community apps:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.