-
Notifications
You must be signed in to change notification settings - Fork 22
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
CSS refactor #312
CSS refactor #312
Conversation
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.
some CSS rules need to be built from python variables ( see central_view.py:L307)
For these, could you use the functionality I introduced #257?
some widgets seem immune to modifiers, depending on how they're built. For instance, all the widgets from the ChatInterface like ChatMessage, and "source info" buttons, cannot be styled with modifiers. I think it's a bug in Panel and I need to dig to identify the root cause. Eventually every widget should be modifiable using modifiers.
I believe this was fixed in holoviz/panel#6304. Should we wait for this to be released before we merge this PR?
Yes that's what I'm doing, see here
I confirm this fixes the issue. Yes, we will have to wait for it to be released before merging. |
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 @pierrotsmnrd, this is awesome! This resolves most of my gripes that I had with the way we styled the UI. I left a bunch of comments below. Two higher-level comments:
-
I see the
styles.py
file still has massive CSS stylesheets. Can they be moved to CSS files as well? -
Since we now only rarely need to use
ui.stylesheets
(basically only if the style is only known at runtime), should we simplify the helper function? I'm thinking of it only accepting one class selector at a time. That would turnstylesheets=ui.stylesheets(("class-selector", {...}))
into
stylesheets=[ui.stylesheet("class-selector", {...})]
Not a massive improvement, but I think this is easier to read. If you want to go for this in this PR, here is the new definition:
def stylesheet( selectors: Union[str, Iterable[str]], declarations: dict[str, str] ) -> str: return "\n".join( [ f"{selectors if isinstance(selectors, str) else ', '.join(selectors)} {{", *[f" {property}: {value};" for property, value in declarations.items()], "}", ] )
I can also send a follow-up PR if you prefer that.
The goal is to get rid of all the CSS currently in python files and move that in proper CSS files. So yes, they'll be moved.
Totally ok with the concept, but I suggest to name it |
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
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.
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
There was indeed a problem with the separator in the configuration modal. |
@pierrotsmnrd panel==1.4.0 (tracked in #379) also introduced new ways of styling the chat messages: https://blog.holoviz.org/posts/panel_release_1.4/#other-enhancements Can this be adopted here to simplify stuff? |
commit 04168ab Author: Arjun Verma <arjunverma.oc@gmail.com> Date: Wed May 1 12:35:41 2024 +0530 #373 Include documentation_helpers in module (#395) Co-authored-by: Philip Meier <github.pmeier@posteo.de> commit f947f2d Author: Philip Meier <github.pmeier@posteo.de> Date: Mon Apr 29 17:08:40 2024 +0200 bump mypy to 1.10 (#398) commit e0fe014 Author: Kevin Klein <7267523+kklein@users.noreply.github.com> Date: Mon Apr 29 12:52:49 2024 +0200 Add instructions to install from conda-forge. (#396) Co-authored-by: Philip Meier <github.pmeier@posteo.de> commit 7963453 Author: Philip Meier <github.pmeier@posteo.de> Date: Thu Apr 25 20:38:50 2024 +0200 use custom JSON type for database for more generic support (#389) commit 3a5b82d Author: William Black <125844868+smokestacklightnin@users.noreply.github.com> Date: Wed Apr 24 01:37:48 2024 -0700 Remove Mosaic Assistant (#387)
"Source info" button looks different from the copy button. This has nothing to do with |
I'm seeing the issue on Firefox and Chromium both with cleared caches. |
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 a ton Pierre! This looks awesome!
Work in progress - do not mergeReady for reviewThis PR uses a better approach for CSS styling in Panel.
The method we used so far showed its limitations : too much CSS code inside the python code, preventing CSS code completion, linting breaking indentation, hard to maintain.
The new method relies on design modifiers.
css_classes=['my_class_name', ]
). Imagine we have 2 kinds of buttons, A and B, we want to style in a different way. We can add them css classmy_button_A
andmy_button_B
, do the following :and each css file should contain rules starting with :
and similarly for button B
This PR applies to method to Ragna UI.
Currently WIP, the auth page and part of the main view are handled.
Caveat : not all CSS can be removed from python code.