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

Move JS/CSS links to class attributes #1416

Merged
merged 4 commits into from
Nov 10, 2020

Conversation

Conengmo
Copy link
Member

I wanted to do this before we release. We recently moved the links to external JS and CSS resources to module variables: #1312. This was a good thing. But I was thinking that it would make things much more DRY if we move them to the classes instead, because then we can render them in one place.

I made a mixin class that renders JS and CSS links. I thought about subclassing MacroElement and using that subclass throughout the code, but I think using a mixin is a bit more clean here.

This change allows us to remove duplicated code while still allowing users to replace the JS/CSS links.

from branca.element import Figure, Element, JavascriptLink, CssLink


class JSCSSMixin(Element):
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! This reduces a lot of code duplication!

@ocefpaf ocefpaf merged commit 0de6914 into python-visualization:master Nov 10, 2020
@Conengmo Conengmo deleted the js-css-in-class branch November 15, 2020 10:28
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.

3 participants