Spaces:
Running
Running
File size: 972 Bytes
f3141ae 6ff3d12 b470e8d 6ff3d12 b470e8d f3141ae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import mesop as me
import components as mex
import handlers
from constants import DIALOG_INPUT_WIDTH
from state import State
@me.component
def update_title():
state = me.state(State)
with mex.dialog(state.dialog_show_title):
me.text("Update Prompt Title", type="headline-6")
me.input(
label="Title",
value=state.temp_title,
on_blur=handlers.on_update_input,
key="temp_title",
style=me.Style(width=DIALOG_INPUT_WIDTH),
)
with mex.dialog_actions():
mex.button(
"Cancel",
on_click=handlers.on_close_dialog,
key="dialog_show_title",
)
mex.button(
"Save",
type="flat",
disabled=not state.temp_title.strip(),
on_click=on_save_title,
)
def on_save_title(e: me.InputBlurEvent):
"""Saves the title and closes the dialog."""
state = me.state(State)
if state.temp_title:
state.title = state.temp_title
state.dialog_show_title = False
|