|
@@ -4,21 +4,21 @@ import reflex as rx
|
|
from ..states.form_state import FormState, UploadState
|
|
from ..states.form_state import FormState, UploadState
|
|
from ..styles import *
|
|
from ..styles import *
|
|
|
|
|
|
-forms_1_code = """rx.vstack(
|
|
|
|
- rx.form(
|
|
|
|
- rx.vstack(
|
|
|
|
- rx.input(
|
|
|
|
|
|
+forms_1_code = """rx.chakra.vstack(
|
|
|
|
+ rx.chakra.form(
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.input(
|
|
placeholder="First Name",
|
|
placeholder="First Name",
|
|
id="first_name",
|
|
id="first_name",
|
|
),
|
|
),
|
|
- rx.input(
|
|
|
|
|
|
+ rx.chakra.input(
|
|
placeholder="Last Name", id="last_name"
|
|
placeholder="Last Name", id="last_name"
|
|
),
|
|
),
|
|
- rx.hstack(
|
|
|
|
- rx.checkbox("Checked", id="check"),
|
|
|
|
- rx.switch("Switched", id="switch"),
|
|
|
|
|
|
+ rx.chakra.hstack(
|
|
|
|
+ rx.chakra.checkbox("Checked", id="check"),
|
|
|
|
+ rx.chakra.switch("Switched", id="switch"),
|
|
),
|
|
),
|
|
- rx.button("Submit",
|
|
|
|
|
|
+ rx.chakra.button("Submit",
|
|
type_="submit",
|
|
type_="submit",
|
|
bg="#ecfdf5",
|
|
bg="#ecfdf5",
|
|
color="#047857",
|
|
color="#047857",
|
|
@@ -27,9 +27,9 @@ forms_1_code = """rx.vstack(
|
|
),
|
|
),
|
|
on_submit=FormState.handle_submit,
|
|
on_submit=FormState.handle_submit,
|
|
),
|
|
),
|
|
- rx.divider(),
|
|
|
|
- rx.heading("Results"),
|
|
|
|
- rx.text(FormState.form_data.to_string()),
|
|
|
|
|
|
+ rx.chakra.divider(),
|
|
|
|
+ rx.chakra.heading("Results"),
|
|
|
|
+ rx.chakra.text(FormState.form_data.to_string()),
|
|
width="100%",
|
|
width="100%",
|
|
)"""
|
|
)"""
|
|
|
|
|
|
@@ -44,35 +44,35 @@ forms_1_state = """class FormState(rx.State):
|
|
self.form_data = form_data"""
|
|
self.form_data = form_data"""
|
|
|
|
|
|
|
|
|
|
-forms_2_code = """rx.vstack(
|
|
|
|
|
|
+forms_2_code = """rx.chakra.vstack(
|
|
rx.upload(
|
|
rx.upload(
|
|
- rx.vstack(
|
|
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.button(
|
|
"Select File",
|
|
"Select File",
|
|
color=color,
|
|
color=color,
|
|
bg="white",
|
|
bg="white",
|
|
border=f"1px solid {color}",
|
|
border=f"1px solid {color}",
|
|
),
|
|
),
|
|
- rx.text(
|
|
|
|
|
|
+ rx.chakra.text(
|
|
"Drag and drop files here or click to select files"
|
|
"Drag and drop files here or click to select files"
|
|
),
|
|
),
|
|
),
|
|
),
|
|
border=f"1px dotted {color}",
|
|
border=f"1px dotted {color}",
|
|
padding="5em",
|
|
padding="5em",
|
|
),
|
|
),
|
|
- rx.hstack(rx.foreach(rx.selected_files, rx.text)),
|
|
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)),
|
|
|
|
+ rx.chakra.button(
|
|
"Upload",
|
|
"Upload",
|
|
on_click=lambda: UploadState.handle_upload(
|
|
on_click=lambda: UploadState.handle_upload(
|
|
rx.upload_files()
|
|
rx.upload_files()
|
|
),
|
|
),
|
|
),
|
|
),
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.button(
|
|
"Clear",
|
|
"Clear",
|
|
on_click=rx.clear_selected_files,
|
|
on_click=rx.clear_selected_files,
|
|
),
|
|
),
|
|
rx.foreach(
|
|
rx.foreach(
|
|
- UploadState.img, lambda img: rx.image(src=img, width="20%", height="auto",)
|
|
|
|
|
|
+ UploadState.img, lambda img: rx.chakra.image(src=img, width="20%", height="auto",)
|
|
),
|
|
),
|
|
padding="5em",
|
|
padding="5em",
|
|
width="100%",
|
|
width="100%",
|
|
@@ -109,25 +109,25 @@ def forms_page() -> rx.Component:
|
|
Returns:
|
|
Returns:
|
|
rx.Component: The UI for the settings page.
|
|
rx.Component: The UI for the settings page.
|
|
"""
|
|
"""
|
|
- return rx.box(
|
|
|
|
- rx.vstack(
|
|
|
|
- rx.heading(
|
|
|
|
|
|
+ return rx.chakra.box(
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.heading(
|
|
"Forms Demo",
|
|
"Forms Demo",
|
|
font_size="3em",
|
|
font_size="3em",
|
|
),
|
|
),
|
|
- rx.vstack(
|
|
|
|
- rx.form(
|
|
|
|
- rx.vstack(
|
|
|
|
- rx.input(
|
|
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.form(
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.input(
|
|
placeholder="First Name",
|
|
placeholder="First Name",
|
|
id="first_name",
|
|
id="first_name",
|
|
),
|
|
),
|
|
- rx.input(placeholder="Last Name", id="last_name"),
|
|
|
|
- rx.hstack(
|
|
|
|
- rx.checkbox("Checked", id="check"),
|
|
|
|
- rx.switch("Switched", id="switch"),
|
|
|
|
|
|
+ rx.chakra.input(placeholder="Last Name", id="last_name"),
|
|
|
|
+ rx.chakra.hstack(
|
|
|
|
+ rx.chakra.checkbox("Checked", id="check"),
|
|
|
|
+ rx.chakra.switch("Switched", id="switch"),
|
|
),
|
|
),
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.button(
|
|
"Submit",
|
|
"Submit",
|
|
type_="submit",
|
|
type_="submit",
|
|
bg="#ecfdf5",
|
|
bg="#ecfdf5",
|
|
@@ -137,20 +137,20 @@ def forms_page() -> rx.Component:
|
|
),
|
|
),
|
|
on_submit=FormState.handle_submit,
|
|
on_submit=FormState.handle_submit,
|
|
),
|
|
),
|
|
- rx.divider(),
|
|
|
|
- rx.heading("Results"),
|
|
|
|
- rx.text(FormState.form_data.to_string()),
|
|
|
|
|
|
+ rx.chakra.divider(),
|
|
|
|
+ rx.chakra.heading("Results"),
|
|
|
|
+ rx.chakra.text(FormState.form_data.to_string()),
|
|
width="100%",
|
|
width="100%",
|
|
),
|
|
),
|
|
- rx.tabs(
|
|
|
|
- rx.tab_list(
|
|
|
|
- rx.tab("Code", style=tab_style),
|
|
|
|
- rx.tab("State", style=tab_style),
|
|
|
|
|
|
+ rx.chakra.tabs(
|
|
|
|
+ rx.chakra.tab_list(
|
|
|
|
+ rx.chakra.tab("Code", style=tab_style),
|
|
|
|
+ rx.chakra.tab("State", style=tab_style),
|
|
padding_x=0,
|
|
padding_x=0,
|
|
),
|
|
),
|
|
- rx.tab_panels(
|
|
|
|
- rx.tab_panel(
|
|
|
|
- rx.code_block(
|
|
|
|
|
|
+ rx.chakra.tab_panels(
|
|
|
|
+ rx.chakra.tab_panel(
|
|
|
|
+ rx.chakra.code_block(
|
|
forms_1_code,
|
|
forms_1_code,
|
|
language="python",
|
|
language="python",
|
|
show_line_numbers=True,
|
|
show_line_numbers=True,
|
|
@@ -159,8 +159,8 @@ def forms_page() -> rx.Component:
|
|
padding_x=0,
|
|
padding_x=0,
|
|
padding_y=".25em",
|
|
padding_y=".25em",
|
|
),
|
|
),
|
|
- rx.tab_panel(
|
|
|
|
- rx.code_block(
|
|
|
|
|
|
+ rx.chakra.tab_panel(
|
|
|
|
+ rx.chakra.code_block(
|
|
forms_1_state,
|
|
forms_1_state,
|
|
language="python",
|
|
language="python",
|
|
show_line_numbers=True,
|
|
show_line_numbers=True,
|
|
@@ -177,34 +177,36 @@ def forms_page() -> rx.Component:
|
|
width="100%",
|
|
width="100%",
|
|
padding_top=".5em",
|
|
padding_top=".5em",
|
|
),
|
|
),
|
|
- rx.heading("Upload Example", font_size="3em"),
|
|
|
|
- rx.text("Try uploading some images and see how they look."),
|
|
|
|
- rx.vstack(
|
|
|
|
|
|
+ rx.chakra.heading("Upload Example", font_size="3em"),
|
|
|
|
+ rx.chakra.text("Try uploading some images and see how they look."),
|
|
|
|
+ rx.chakra.vstack(
|
|
rx.upload(
|
|
rx.upload(
|
|
- rx.vstack(
|
|
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.vstack(
|
|
|
|
+ rx.chakra.button(
|
|
"Select File",
|
|
"Select File",
|
|
color=color,
|
|
color=color,
|
|
bg="white",
|
|
bg="white",
|
|
border=f"1px solid {color}",
|
|
border=f"1px solid {color}",
|
|
),
|
|
),
|
|
- rx.text("Drag and drop files here or click to select files"),
|
|
|
|
|
|
+ rx.chakra.text(
|
|
|
|
+ "Drag and drop files here or click to select files"
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
border=f"1px dotted {color}",
|
|
border=f"1px dotted {color}",
|
|
padding="5em",
|
|
padding="5em",
|
|
),
|
|
),
|
|
- rx.hstack(rx.foreach(rx.selected_files, rx.text)),
|
|
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)),
|
|
|
|
+ rx.chakra.button(
|
|
"Upload",
|
|
"Upload",
|
|
on_click=lambda: UploadState.handle_upload(rx.upload_files()),
|
|
on_click=lambda: UploadState.handle_upload(rx.upload_files()),
|
|
),
|
|
),
|
|
- rx.button(
|
|
|
|
|
|
+ rx.chakra.button(
|
|
"Clear",
|
|
"Clear",
|
|
on_click=rx.clear_selected_files,
|
|
on_click=rx.clear_selected_files,
|
|
),
|
|
),
|
|
rx.foreach(
|
|
rx.foreach(
|
|
UploadState.img,
|
|
UploadState.img,
|
|
- lambda img: rx.image(
|
|
|
|
|
|
+ lambda img: rx.chakra.image(
|
|
src=img,
|
|
src=img,
|
|
width="20%",
|
|
width="20%",
|
|
height="auto",
|
|
height="auto",
|
|
@@ -213,15 +215,15 @@ def forms_page() -> rx.Component:
|
|
padding="5em",
|
|
padding="5em",
|
|
width="100%",
|
|
width="100%",
|
|
),
|
|
),
|
|
- rx.tabs(
|
|
|
|
- rx.tab_list(
|
|
|
|
- rx.tab("Code", style=tab_style),
|
|
|
|
- rx.tab("State", style=tab_style),
|
|
|
|
|
|
+ rx.chakra.tabs(
|
|
|
|
+ rx.chakra.tab_list(
|
|
|
|
+ rx.chakra.tab("Code", style=tab_style),
|
|
|
|
+ rx.chakra.tab("State", style=tab_style),
|
|
padding_x=0,
|
|
padding_x=0,
|
|
),
|
|
),
|
|
- rx.tab_panels(
|
|
|
|
- rx.tab_panel(
|
|
|
|
- rx.code_block(
|
|
|
|
|
|
+ rx.chakra.tab_panels(
|
|
|
|
+ rx.chakra.tab_panel(
|
|
|
|
+ rx.chakra.code_block(
|
|
forms_2_code,
|
|
forms_2_code,
|
|
language="python",
|
|
language="python",
|
|
show_line_numbers=True,
|
|
show_line_numbers=True,
|
|
@@ -230,8 +232,8 @@ def forms_page() -> rx.Component:
|
|
padding_x=0,
|
|
padding_x=0,
|
|
padding_y=".25em",
|
|
padding_y=".25em",
|
|
),
|
|
),
|
|
- rx.tab_panel(
|
|
|
|
- rx.code_block(
|
|
|
|
|
|
+ rx.chakra.tab_panel(
|
|
|
|
+ rx.chakra.code_block(
|
|
forms_2_state,
|
|
forms_2_state,
|
|
language="python",
|
|
language="python",
|
|
show_line_numbers=True,
|
|
show_line_numbers=True,
|