From 7d7c6e5d4f092bba54448f0d99672dbbd5450dfd Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Wed, 27 Sep 2023 15:54:58 +0200 Subject: [PATCH] make pretty --- solara/lab/components/confirmation_dialog.py | 41 ++++++++++--------- .../website/pages/api/confirmation_dialog.py | 8 +++- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/solara/lab/components/confirmation_dialog.py b/solara/lab/components/confirmation_dialog.py index 1a24a66fd..6ba944535 100644 --- a/solara/lab/components/confirmation_dialog.py +++ b/solara/lab/components/confirmation_dialog.py @@ -40,7 +40,7 @@ def delete_user(): @solara.component def Page(): solara.Button(label="Delete user", on_click=lambda: open_delete_confirmation.set(True)) - solara.lab.ConfirmationDialog(open_delete_confirmation, on_ok=delete_user, content="Are you sure you want to delete this user?") + solara.lab.ConfirmationDialog(open_delete_confirmation, ok="Ok, Delete", on_ok=delete_user, content="Are you sure you want to delete this user?") ``` ## Arguments @@ -92,28 +92,29 @@ def on_v_model(value): persistent=persistent, max_width=max_width, ): - with solara.Card(title=title): - if isinstance(content, str): - solara.Markdown(content) - else: - solara.display(content) - if children: - solara.display(*children) - with solara.CardActions(): - - if isinstance(ok, str): - solara.Button(label=ok, on_click=perform_ok) + with solara.v.Card(): + solara.v.Toolbar(color="primary", dark=True, children=[title]) + with solara.v.CardText(class_="pa-4"): + if isinstance(content, str): + solara.Text(content) else: - # the user may have passed in on_click already - user_on_click_ok = ok.kwargs.get("on_click") - # override or add our own on_click handler - ok.kwargs = {**ok.kwargs, "on_click": perform_ok} - solara.display(ok) - - # similar as ok + solara.display(content) + if children: + solara.display(*children) + with solara.v.CardActions(class_="justify-end"): if isinstance(cancel, str): - solara.Button(label=cancel, on_click=perform_cancel) + solara.Button(label=cancel, on_click=perform_cancel, outlined=True, color="primary") else: + # the user may have passed in on_click already user_on_click_cancel = cancel.kwargs.get("on_click") + # override or add our own on_click handler cancel.kwargs = {**cancel.kwargs, "on_click": perform_cancel} solara.display(cancel) + + # similar as cancel + if isinstance(ok, str): + solara.Button(label=ok, on_click=perform_ok, color="primary") + else: + user_on_click_ok = ok.kwargs.get("on_click") + ok.kwargs = {**ok.kwargs, "on_click": perform_ok} + solara.display(ok) diff --git a/solara/website/pages/api/confirmation_dialog.py b/solara/website/pages/api/confirmation_dialog.py index 20bd4b81f..18e03ef24 100644 --- a/solara/website/pages/api/confirmation_dialog.py +++ b/solara/website/pages/api/confirmation_dialog.py @@ -47,7 +47,13 @@ def Page(): style="max-width: 400px;", disabled=not users.value, ) - ConfirmationDialog(is_open, on_ok=delete_user, title="Delete user", content=f"Are you sure you want to delete user **{user_to_be_deleted.value}**?") + with ConfirmationDialog( + is_open, + on_ok=delete_user, + ok="Ok, Delete", + title="Delete user", + ): + solara.Markdown(f"Are you sure you want to delete user **{user_to_be_deleted.value}**?") __doc__ += apidoc(solara.lab.components.confirmation_dialog.ConfirmationDialog.f) # type: ignore