Skip to content
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

reduce specificity of generated stylesheets to 0 #1941

Merged
merged 4 commits into from
Dec 8, 2023
Merged

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Dec 8, 2023

Fixes #1930.

mstade and others added 4 commits November 21, 2023 22:29
By reducing the specificity of selectors in the generated stylesheets to 0,
consumers of Plot can much more easily override these styles using their
own stylesheets while still enjoying the default styling of Plot.
Because the change in selector specificity affects every chart, all
snapshots will need regenerating. The rendered output should yield no
differences however.
This test renders two categorical legends, one using default Plot styles and
the other using styles by setting the `className` option. The styles being
overridden have the same selector specificity as those set by Plot, would
it not be for the `:where()` selector resetting Plot's specificity to 0.

This is easily verified by reverting b2ff68e.
@mbostock mbostock merged commit 96c93cb into main Dec 8, 2023
1 check passed
@mbostock mbostock deleted the mbostock/where branch December 8, 2023 03:58
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* fix!: reduce specificity of generated stylesheets to 0

By reducing the specificity of selectors in the generated stylesheets to 0,
consumers of Plot can much more easily override these styles using their
own stylesheets while still enjoying the default styling of Plot.

* chore: generate new snapshots

Because the change in selector specificity affects every chart, all
snapshots will need regenerating. The rendered output should yield no
differences however.

* chore: add simple test case for style overrides

This test renders two categorical legends, one using default Plot styles and
the other using styles by setting the `className` option. The styles being
overridden have the same selector specificity as those set by Plot, would
it not be for the `:where()` selector resetting Plot's specificity to 0.

This is easily verified by reverting b2ff68e.

---------

Co-authored-by: Marcus Stade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants