Skip to content
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

Add Panel Modal #5896

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add Panel Modal #5896

wants to merge 2 commits into from

Conversation

MarcSkovMadsen
Copy link
Collaborator

This PR migrates the Panel-Modal to Panel as agreed with Philipp. Having a standalone modal provides more flexibility than the modal built into templates. For example it also works in notebooks. The user experience is also better.

panel/layout/modal.py Outdated Show resolved Hide resolved


_template = """
<style id="pnx_dialog_style">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should maybe find another way to include the style. The problem is that with the fast templates this style needs to be available globally while with other templates it does not have to.

Whether or not the modal is open. Set to True to open. Set to False to close.""")
show_close_button = param.Boolean(True, doc="Whether to show a close button in the modal")

open = param.Event(doc="Click here to open the modal")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I would like to have actions instead of events as they are more natural to use from Python. But when I do, I get serialization error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand on this? We explicitly introduced Event because Action seemed weird and hacky.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because its more natural than an action from the Python side as a function.

Copy link
Member

@philippjfr philippjfr Dec 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess that's true, the problem was that param.Action(lambda p: p.param.trigger('open')) just is a very bizarre thing. I do agree from an enduser perspective it's clearer than having to call .param.trigger('open') yourself though.

}
"""

class Modal(ReactiveHTML, NamedListLike): # pylint: disable=too-many-ancestors
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Should figure out if its possible to add parameter to disable the closing of the modal when clicking the back drop.

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f0b1832) 84.41% compared to head (f1c3599) 84.19%.
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5896      +/-   ##
==========================================
- Coverage   84.41%   84.19%   -0.23%     
==========================================
  Files         291      293       +2     
  Lines       42655    42811     +156     
==========================================
+ Hits        36007    36043      +36     
- Misses       6648     6768     +120     
Flag Coverage Δ
ui-tests 40.97% <66.66%> (+0.14%) ⬆️
unitexamples-tests 72.46% <100.00%> (-0.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants