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
Create Warning, Info modals #4518
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4518-all-demos |
Absolutely. Already on it 😊 |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
Nice @aliabid94! I'm still doing some testing, but I noticed that if there's a import gradio as gr
import time
def test(x):
gr.Warning("step 1")
yield "step 1"
time.sleep(1)
gr.Warning("step 2")
yield "step 2"
time.sleep(1)
gr.Warning("done")
# time.sleep(1) # If you uncomment this line, it works
yield "done"
gr.Interface(test, "textbox", "textbox").queue().launch() Speaking of, it would be good to write some tests |
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.
Apart from one small comment, I'm happy with the frontend code so far. When we're happy with the core implementation, I guess @hannahblair will take over to add the new UI.
* create abstract toast component for info/warning/error * add icons * add light mode theming * add theme mode check and dark mode styles * update theme_mode on update * clean up render of toast content * replace dynamic css vars with toast type css selectors * tweak colours * change error pill border colour to align with toasts * formatting * fix failed test * rename icon files and clean up css
ready for re-review |
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.
Reviewed the frontend code a few times now, and looks good to me! Thanks @hannahblair and @aliabid94!
Chromatic build successful 🎉 |
Introduce
gr.Warning
andgr.Info
, which can be written anywhere in a function and will cause a Modal to pop up instantly. Requires websockets.Example code:
Did not try to capture every
warnings.warn
that was raised, as it would be quite tricky (having to hijack the warnings library just as we did with tqdm) and I don't think there would be many use cases.The modal looks the same for Error, Info, and Warning - @hannahblair would you like to take on styling those as well?