-
Notifications
You must be signed in to change notification settings - Fork 949
Button Icons/FontAwesome regression no longer supports fa-spin #2477
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
Comments
@jasongrout what would be the path forward to allow multiple font awesome parameters? Are there existing accommodations for this that I am missing? |
I was just wishing yesterday for multiple icons on a button and found this discussion. The implication is that it used to work and such behavior was explicitly removed? Why not leave it in and let the user decide if they find multiple icons useful? I could use it frankly. Thanks. |
@kebwi I ended up creating a custom widget for my purposes using the ipywidgets cookiecutter template. But, yeah, disappointed this support is no longer available with little explanation why. |
Here is an example custom font awesome button: Python Model:
Javascript View:
Usage:
|
Hmmm. Thanks. I admit, I've haven't delved into custom widgets yet. I guess it's time to roll up my sleeves. |
I did a bit of digging in the code, and I think this is where this behavior was changed: #427 (after this it was no longer possible to define multiple icon classes). That is three years ago, although the deprecation warning was added a few months later. The purpose of that was to reduce/remove our dependency on jQuery. It might be possible to get accepted a PR that re-adds support for multiple classes. Change this:
To this: i.className += 'fa-' + icon; You would then be able to use (the slightly hackish): from ipywidgets import Button
Button(description='Running...', icon='gear fa-spin fa-lg') |
Perhaps something like: icon.split(/[\s]+/).filter(Boolean).map(v => `fa-${v}`).join(' ') would let the icon take multiple values. |
Note: The change above only outlines how to support multiple icon classes. The other change that was done was to automatically prefix with |
This may be a simpler way to prepend the fa- to each word: icon.replace(/\b(\w)/g, 'fa-$1') |
That was introduced in 6.0, apparently (at least #555 was in 6.0). |
I think it would be great if someone put in a PR adding back in support for multiple icons, probably by just changing the one line that Vidar points out above (I give several different ways to prepend Setting as a good first issue. |
Yes, which is why I think we simply said "this is the new behavior now" instead of saying "this is a bug, lets fix it". 🤷♂ |
Thanks for the encouragement. It would be great to download and otherwise contribute to ipywidgets as opposed to just using it. But I admit, I'm not sure I have time to ramp up on the code or otherwise become a quality contributor right now. I'll weigh my priorities. Cheers! |
I'm hoping that this fix is literally just changing
i.classList.add(...icon.split(/[\s]+/).filter(Boolean).map(v => `fa-${v}`)); |
And maybe changing the documentation at
|
I'll try to have a look at this issue tomorrow |
PR opened #2685 @kebwi Please note that this PR does not add support for multiple icons in a Button. It is only fixing the regression that appeared in 6.0, allowing:
Which I understand is the original issue here. Maybe we could open another issue for multiple icons support? |
since this was added:
https://github.com/jupyter-widgets/ipywidgets/blob/master/ipywidgets/widgets/widget_button.py#L65-L73
we are no longer able to pass in additional fa classes to specify fa-spin or fa-lg etc.
I really liked my spinning gear icon button before this change...
i.e.
it will error on the add of the DOMTokenList due to the spaces in the string
https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/controls/src/widget_button.ts#L91
The text was updated successfully, but these errors were encountered: