From 1f4c24482b0b8b1d94a136e185dbe851eee6470d Mon Sep 17 00:00:00 2001 From: Lendemor Date: Thu, 16 May 2024 17:35:03 +0200 Subject: [PATCH 1/3] update README to use 0.5.0 --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 675f29cc31d..bb81c9fa2d0 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ class State(rx.State): def get_image(self): """Get the image from the prompt.""" if self.prompt == "": - return rx.window_alert("Prompt Empty") + return rx._x.toast.error("Prompt Empty") self.processing, self.complete = True, False yield @@ -120,20 +120,21 @@ def index(): on_blur=State.set_prompt, width="25em", ), - rx.button("Generate Image", on_click=State.get_image, width="25em"), + rx.button( + "Generate Image", + on_click=State.get_image, + width="25em", + loading=State.processing + ), rx.cond( - State.processing, - rx.chakra.circular_progress(is_indeterminate=True), - rx.cond( - State.complete, - rx.image(src=State.image_url, width="20em"), - ), + State.complete, + rx.image(src=State.image_url, width="20em"), ), align="center", ), width="100%", height="100vh", - ) + ), rx._x.toast.provider() # Add state and page to the app. app = rx.App() @@ -185,7 +186,7 @@ class State(rx.State): The state defines all the variables (called vars) in an app that can change and the functions that change them. -Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to show the circular progress and image. +Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to block the button and when to show the image. ### **Event Handlers** @@ -193,7 +194,7 @@ Here the state is comprised of a `prompt` and `image_url`. There are also the bo def get_image(self): """Get the image from the prompt.""" if self.prompt == "": - return rx.window_alert("Prompt Empty") + return rx._x.toast.error("Prompt Empty") self.processing, self.complete = True, False yield From 8fdac09454a215f9d8cc8daffb6179cdfaee3e20 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Fri, 17 May 2024 02:11:10 +0200 Subject: [PATCH 2/3] remove toast, fix desc --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb81c9fa2d0..0c7a5f2fc90 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ class State(rx.State): def get_image(self): """Get the image from the prompt.""" if self.prompt == "": - return rx._x.toast.error("Prompt Empty") + return rx.window_alert("Prompt Empty") self.processing, self.complete = True, False yield @@ -134,7 +134,7 @@ def index(): ), width="100%", height="100vh", - ), rx._x.toast.provider() + ) # Add state and page to the app. app = rx.App() @@ -186,7 +186,7 @@ class State(rx.State): The state defines all the variables (called vars) in an app that can change and the functions that change them. -Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to block the button and when to show the image. +Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to disable the button (during image generation) and when to show the resulting image. ### **Event Handlers** From 57e3f3371e4091f78d3b32c91adcdcedad7b75ac Mon Sep 17 00:00:00 2001 From: Lendemor Date: Fri, 17 May 2024 03:43:04 +0200 Subject: [PATCH 3/3] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c7a5f2fc90..c6270f120e4 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ Here the state is comprised of a `prompt` and `image_url`. There are also the bo def get_image(self): """Get the image from the prompt.""" if self.prompt == "": - return rx._x.toast.error("Prompt Empty") + return rx.window_alert("Prompt Empty") self.processing, self.complete = True, False yield