Skip to content

Commit

Permalink
make pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Sep 27, 2023
1 parent 7d257ff commit 7d7c6e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
41 changes: 21 additions & 20 deletions solara/lab/components/confirmation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
8 changes: 7 additions & 1 deletion solara/website/pages/api/confirmation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7d7c6e5

Please sign in to comment.