-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Remove CSS template substitution in estimators' HTML Display #32839
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
base: main
Are you sure you want to change the base?
Conversation
|
I recall @rouk1 complained about the way we were doing our CSS there. Was it this way you thought it would be better done? |
thomasjpfan
left a comment
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.
From memory, I had the $id because I did not know how dynamic the CSS would be in the future. For example, lets say we had a CSS very specific to a particular estimator, then the id prevents that CSS from impacting all the other estimators.
From looking at the code now, I do not think thats the case, so I'm okay with a global selector.
(An interesting follow is to only write the CSS on the first repr call that is also in Jupyter, so it does not get copied over and over again.)
| @@ -1,4 +1,4 @@ | |||
| #$id { | |||
| .css-selector { | |||
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.
Can this be prefixed with sk, i.e. .sk-css-selector? There is the edge case where another library may add CSS to the page with the same name and override our selector.
In this case, I think that we should do something similar to |
@thomasjpfan It would be great, that's what I wanted to do here*: RFC: Potential improvement of HTML Display's css logic. But Olivier thought that it wasn't possible. Moreover, Guillaume prefers to aim for the shadow DOM. *Just sharing for background. |
Using a class is fine, as stated above the only edge case is if something uses the same class name. So I advise to use something long and semantically consistent to avoid collision. Using a shadow DOM cover this edge case but adds complexity that's a tradeoff... Note: vscode uses iframe to render cell outputs so serializing only once the css code will lead to un-styled estimator. |
Reference Issues/PRs
#32834
What does this implement/fix? Explain your changes.
Maybe the template/substitution can be avoided.
The css doesn't change for each estimator, so why do we need a dynamic selector?
Edit: Removed
#$idtoestimator.cssto avoid the dynamic behaviour. Added a selector calledcss-selectorinstead.On
estimator.pyI'm adding a class with the same name -css-selector.That way we don't need to substitute the id number, that I believe it's not needed.
Worked locally with vscode and jupyter notebook.
AI usage disclosure
I used AI assistance for:
Any other comments?