Skip to content

How to extend ipyleaflet with a python lib that inject CSS and JS in Jupyter? #1130

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

Open
12rambau opened this issue Jul 29, 2023 · 0 comments

Comments

@12rambau
Copy link

cross-posting from SO as the downvoted machinery is already on its way...

I'm writing a python lib to create maps with vuetify based widgets sepal-ui. The lib is based on the ipyleaflet and ipyvutify packages.

To make them work together, I need to inject some extra css and javascript to the page. At the moment I'm doing it via ipywidgets display method:

# load custom styling of sepal_ui
sepal_ui_css = HTML(f"<style>{(CSS_DIR / 'custom.css').read_text()}</style>")

# load fa-6
fa_css = HTML(
    '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"/>'
)

# create a small hack to remove fontawesome from the html output
clean_fa_js = Javascript((JS_DIR / "fontawesome.js").read_text())

# display all
display(sepal_ui_css, fa_css, clean_fa_js)

By looking at ipyleaflet code I realize that you don't need such a mechanism to inject leaflet and css into the notebooks. Can someone explain what is the methodology I should follow ? or maybe link me in the right direction in the Jupyter documentation ?

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

No branches or pull requests

1 participant