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

Add extra_css for custom css injection #1950

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

paololazzari
Copy link
Contributor

Fixes #1949.

I tested this locally by adding the following to testing/local-binder-mocked-hub/binderhub_config.py:

c.BinderHub.banner_message = 'This is headline <a href="#">news.</a>'
c.BinderHub.extra_css = """
.p-3.bg-light.shadow-sm.text-center {
    color: red;
}
"""

the style was loaded and the headline color changed.

Copy link
Contributor

@rgaiacs rgaiacs left a comment

Choose a reason for hiding this comment

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

It looks good to me. Before merge, can we

  • use if-clause in the HTML template
  • document it for the Helm chart

@paololazzari
Copy link
Contributor Author

@rgaiacs Thanks! Where should I document this for the helm chart?

@rgaiacs
Copy link
Contributor

rgaiacs commented Mar 13, 2025

Where should I document this for the helm chart?

I believe that the traitlets are "magic" connected to the helm chart. But it is nice to add to

config:
# These c.BinderHub properties are referenced by the Helm chart
BinderHub:
# auth_enabled:
base_url: /
build_node_selector: {}
# hub_url:
# hub_url_local:
use_registry: true
KubernetesBuildExecutor: {}
like

config:
  # These c.BinderHub properties are referenced by the Helm chart
  BinderHub:
    ...
    # extra_css: |
    #  .p-3.bg-light.shadow-sm.text-center {
    #      color: red;
    #  }

Also mention it in the documentation

I would like to merge #1923 before this one.

@paololazzari
Copy link
Contributor Author

@rgaiacs I did think about documenting extra_css in those two files, but I did not do it because I found that extra_footer_scripts was not documented there. I assumed whatever reasoning was behind not documenting extra_footer_scripts would hold true in this case too.

@rgaiacs
Copy link
Contributor

rgaiacs commented Mar 28, 2025

Hi @paololazzari, thanks again for the PR. I noticed that this PR will only work in some scenarios. To enable custom CSS as CSS was originally design for, we also need #1952.

The scenario that the solution that you proposed will not work is when you try to change some style from https://github.com/jupyterhub/binderhub/blob/main/binderhub/static/js/index.scss. For example, I was trying to change the font used in the page but using your solution resulted in

grafik

@paololazzari
Copy link
Contributor Author

My proposal was to add CSS, not replace the existing one

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.

Provide way to inject custom css in page
2 participants