-
Notifications
You must be signed in to change notification settings - Fork 945
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
Styling buttons, text inputs, bool inputs. Raw CSS attributes. #2728
Conversation
Thanks for this! It'll be a great addition! You should probably rebase your branch off upstream master. You're still building the conda environment in readthedocs, so you must have branched off a very old master. Since we've done lots of entire source changes like eslint, it's important to remain close to upstream. I think it would be useful to have a conversation about what interface we want to expose to users. There's two reasonable ways to do this, I think:
I suspect that most widget users (as opposed to widget developers) are not familiar with CSS at all. This is certainly true at my work. If a user wanted to underline text, I suspect they would look for some underline boolean traitlet called An alternative interface, more in line with 2, would be: font = String() # normal font family CSS string
font_size = String() # normal CSS size
italic = Boolean() # set font-style
underline = Union(Boolean(), String()) # either true or a string like "dotted red"
overline = Union(Boolean(), String()) # either true or a string like "dotted red"
small_caps = Boolean()
text_color = Color() I'd be keen to hear both what other maintainers and widget users think. |
Hi @pbugnion, That's a very good question. There are merits in staying close to CSS, for those that readily know it (or will learn it at this occasion), for the amount of existing documentation and examples on-line, for the ability to relate the code-side configuration and what appears in the browser inspector. Yet indeed, a big selling point of Jupyter widgets is their ability to leverage all the UI technology stack to casual users. I believe that the important points for such casual users:
Well, sorry, just 2 cents of rambling; not really bringing immediately operational solutions ... |
I've made something (06172ee)
I'd be interested in your opinions .. |
3769c35
to
06172ee
Compare
@ivanov and I debated this for a while, and we both come down on the side of using straight CSS names, even for text-decoration.
Thoughts? |
Signed-off-by: Itay Dafna <[email protected]>
@jasongrout all conflicts resolved - starting review! |
To make reviewing easier, here is a code block exercising all of these new options in the various controls: from ipywidgets import *
display(Checkbox(description='Option A', style=dict(background='lightblue')))
display(Valid(value=False, style=dict(background='lightblue')))
display(ToggleButton(description="Option A", style=dict(
background='lightblue',
font_family="Times New Roman",
font_size="20px",
font_style="italic",
font_variant="small-caps",
font_weight="bold",
text_color="red",
text_decoration="underline",
)))
display(Button(description="Button", style=dict(
button_color="lightblue",
font_family="Times New Roman",
font_size="20px",
font_style="italic",
font_variant="small-caps",
font_weight="bold",
text_color="red",
text_decoration="underline",
)))
display(HTML(value='Some HTML text',style=dict(
background="lightblue",
font_size="30px",
text_color="red"
)))
display(HTMLMath(value='Some HTML text and math: $$\int \sqrt{x^2} dx$$',style=dict(
background="lightblue",
font_size="30px",
text_color="red"
)))
display(Label(value="Label text", style=dict(
background='lightblue',
font_family="Times New Roman",
font_size="20px",
font_style="italic",
font_variant="small-caps",
font_weight="bold",
text_color="red",
text_decoration="underline",
)))
display(Textarea(value='Text area text',style=dict(
background="lightblue",
font_size="30px",
text_color="red"
)))
display(Text(value='Text area text',style=dict(
background="lightblue",
font_size="30px",
text_color="red"
)))
display(Password(value='Text area text',style=dict(
background="lightblue",
font_size="30px",
text_color="red"
)))
display(Combobox(value='option B', options=['option A', 'option B', 'Another option'], style=dict(
background="lightblue",
font_size="30px",
text_color="red"
))) |
Since the toggle button changes its background color to visually indicate state, fixing the background color makes the control very confusing.
These fields are inherited properly, just like in other Style classes.
I pushed three more commits, two cleaning up the code a bit, and one that eliminated the option to set the background color on a ToggleButton, since a toggle button changes the background color to visually indicate state (so fixing the background color makes the control appear to not work). |
…onvenience base class.
…ttributes including underlining.
These were removed in the squashed branch for this PR, so removing here as well.
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.
Many thanks again @zerline for pushing through with this for so long.
@jasongrout thank you so much for moving so quickly with this! I tested locally and the only outstanding issue I could find is |
Closed by mistake - apologies! |
Let's make a follow-up issue about auditing background attributes across other widgets. |
Adding
font-family
,font-size
,font-style
,font-variant
,text-color
,text-decoration
.