style the modals

This commit is contained in:
Tim Bendt
2025-05-04 19:53:27 -06:00
parent b26674ff4e
commit f56625c9cf
7 changed files with 54 additions and 18 deletions

View File

@@ -14,16 +14,18 @@ class CreateTaskScreen(ModalScreen[str]):
Input(placeholder="arguments", id="task_input"),
),
Horizontal(
Button("Cancel"),
Button("Submit")
Button("Cancel", id="cancel"),
Button("Submit", id="submit", variant="primary"),
),
id="create_task_container",
classes="modal_screen"
)
@on(Input.Submitted)
def handle_task_args(self) -> None:
input_widget = self.query_one("#task_input", Input)
self.visible = False
self.disabled = True
self.loading = True
task_args = input_widget.value
@@ -32,3 +34,11 @@ class CreateTaskScreen(ModalScreen[str]):
def on_key(self, event) -> None:
if (event.key == "escape" or event.key == "ctrl+c"):
self.dismiss()
def button_on_click(self, event):
if event.button.id == "cancel":
self.dismiss()
elif event.button.id == "submit":
input_widget = self.query_one("#task_input", Input)
task_args = input_widget.value
self.dismiss(task_args)