modal.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import reflex as rx
  2. from ...webui.state import State
  3. def modal() -> rx.Component:
  4. """A modal to create a new chat.
  5. Returns:
  6. The modal component.
  7. """
  8. return rx.modal(
  9. rx.modal_overlay(
  10. rx.modal_content(
  11. rx.modal_header(
  12. rx.hstack(
  13. rx.text("Create new chat"),
  14. rx.icon(
  15. tag="close",
  16. font_size="sm",
  17. on_click=State.toggle_modal,
  18. color="#fff8",
  19. _hover={"color": "#fff"},
  20. cursor="pointer",
  21. ),
  22. align_items="center",
  23. justify_content="space-between",
  24. )
  25. ),
  26. rx.modal_body(
  27. rx.input(
  28. placeholder="Type something...",
  29. on_blur=State.set_new_chat_name,
  30. bg="#222",
  31. border_color="#fff3",
  32. _placeholder={"color": "#fffa"},
  33. ),
  34. ),
  35. rx.modal_footer(
  36. rx.button(
  37. "Create",
  38. bg="#5535d4",
  39. box_shadow="md",
  40. px="4",
  41. py="2",
  42. h="auto",
  43. _hover={"bg": "#4c2db3"},
  44. on_click=State.create_chat,
  45. ),
  46. ),
  47. bg="#222",
  48. color="#fff",
  49. ),
  50. ),
  51. is_open=State.modal_open,
  52. )