Skip to content

inline styles; tabular nums #579

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

Merged
merged 3 commits into from
Oct 26, 2021
Merged

inline styles; tabular nums #579

merged 3 commits into from
Oct 26, 2021

Conversation

mbostock
Copy link
Member

Inlines the stylesheet into the SVG element. Fixes #578. This was carefully designed so that you can still specify inline styles via the style option which override the default styles. Also, it ensures that any other elements on the page that happen to have the class “plot” are no longer affected by Plot’s global styles.

The text white-space: pre style is tricky. I would rather define this on the SVG attribute, but the user agent style sheet will override it with white-space: nowrap if I do. So the only way to do this (without manually setting the style on every text element that Plot creates, including those inside D3 axes) is with a selector.

Also adds font-variant: tabular-nums. Fixes #577.

@mbostock mbostock requested review from Fil and shancarter October 21, 2021 18:01
Copy link

@shancarter shancarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mbostock mbostock force-pushed the mbostock/inline-styles branch from dc6feed to 822aebf Compare October 21, 2021 19:54
@Fil
Copy link
Contributor

Fil commented Oct 21, 2021

Related: #253 lets the user set the plot's class name.

I don't love the call to Math.random but I guess there's no other way to scope this :-/

Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #581 I suggest a more faithful unit test.

Also, I'd like to have the possibility of specifying a className as in #582 (but maybe defer this to #253?)

@Fil Fil mentioned this pull request Oct 25, 2021
Fil and others added 2 commits October 25, 2021 19:09
* keep inline stylesheet

* inline stylesheets
* keep inline stylesheet

* inline stylesheets

* top-level className

* coerce className to string

Co-authored-by: Mike Bostock <[email protected]>
@mbostock mbostock merged commit 45b2148 into main Oct 26, 2021
@mbostock mbostock deleted the mbostock/inline-styles branch October 26, 2021 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants