-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Load custom CSS #6841
Load custom CSS #6841
Conversation
Thanks @RRosio for looking into this!
Maybe it's because the handler gives a 404? (which would be an HTML page). What does the network tab of the dev tools say? |
Hi @jtpio! Thank you for taking a look here! Yes that is exactly the issue I overlooked! I updated the href for the file to |
My guess is that it is added alongside the existing template CSS file? So that it doesn't need to override, but instead provide additional CSS rules. |
I did some brief investigations on the follow-up question to add the option of enabling/disabling this functionality. My current understanding is that the CLI flag and the user setting options could look a bit like the following: CLI Flag
User Setting
I'm not certain some of these steps are entirely viable so if something stands out in these options I appreciate feedback! In particular I am wondering about if and how I can access the values set in the settings editor from the html templates. |
PR currently implements a CLI flag for custom CSS, with a
|
Maybe it's because According to the docs: https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html#jinja-templating-from-frontend-extensions
|
Oh thank you for pointing that out @jtpio! I will update with the import and check on the CI job result! |
I ended up adding a type hint to resolve the issue. It seems like all the checks look okay now so I've gone ahead and un-drafted the PR. After merging main to this branch, there are two checks failing, UI Tests (firefox) and the RTD build |
Ah nice looking good! Curious if the error was relevant? Does the functionality work with the type ignore comment? |
I think that it is okay, locally I didn't experience any errors. My thinking for it is that in the function where I am calling this line I use the |
Currently, only the RTD CI Job is failing with the following traceback:
It doesn't seem like any of the changes introduced in this PR would cause this issue, but I can see that it is not typical for this failure to appear. The line right before the error is |
Hmm that's strange. I triggered a new CI run on #6887 and the docs build seems to be passing there. |
@@ -26,6 +26,10 @@ and editing settings is similar for all the Jupyter applications. | |||
> - [traitlets](https://traitlets.readthedocs.io/en/latest/config.html#module-traitlets.config) | |||
> provide a low-level architecture for configuration. | |||
|
|||
### Disabling Custom CSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up (could be another PR), maybe it could be interesting to document the feature more (for example in the user guide), to show an example of such custom.css
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jtpio I can follow this PR up with one that includes the example!
I believe the reason for the RTD build failing was due to me adding the placeholder CSS file in the |
There is indeed some logic in the Lines 165 to 168 in 245bc87
|
Yeah I am not entirely sure what is going on but the RTD build with only the addition of the placeholder file was failing: https://readthedocs.org/projects/jupyter-notebook/builds/20949880/. Removing that or changing the position of the file has been allowing the RTD build to pass consistently...
I thought maybe it was getting stuck at the following build hook?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Ah looks like there is a small conflict to fix. Otherwise this should be good to go 👍 |
Thank you @jtpio! I have just resolved that conflict! |
Thanks! |
To FixCurrent error is
Refused to apply style from 'http://localhost:8888/custom/custom.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.