Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -73,13 +73,24 @@ def handle_magic_click(current_text):
|
|
73 |
"""
|
74 |
When the magic button is clicked, this function gets the improved text,
|
75 |
and returns the new and previous text to update the UI.
|
76 |
-
|
77 |
"""
|
78 |
improved_text = magic_function(current_text)
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
|
82 |
-
with gr.Blocks() as demo:
|
83 |
gr.Markdown("# Time Entry Improvement")
|
84 |
with gr.Row():
|
85 |
with gr.Column(scale=4):
|
|
|
73 |
"""
|
74 |
When the magic button is clicked, this function gets the improved text,
|
75 |
and returns the new and previous text to update the UI.
|
76 |
+
If the improved text has no "[" or "]" characters, make text area light green and hide previous text.
|
77 |
"""
|
78 |
improved_text = magic_function(current_text)
|
79 |
+
|
80 |
+
# Check if improved text contains "[" or "]"
|
81 |
+
if "[" not in improved_text and "]" not in improved_text:
|
82 |
+
# No brackets found - make text area light green and hide previous text
|
83 |
+
return (
|
84 |
+
gr.update(value=improved_text, elem_classes="success-text"),
|
85 |
+
current_text,
|
86 |
+
gr.update(visible=False)
|
87 |
+
)
|
88 |
+
else:
|
89 |
+
# Brackets found - keep normal behavior
|
90 |
+
return improved_text, current_text, gr.update(visible=True)
|
91 |
|
92 |
|
93 |
+
with gr.Blocks(css=".success-text { background-color: #d4edda !important; }") as demo:
|
94 |
gr.Markdown("# Time Entry Improvement")
|
95 |
with gr.Row():
|
96 |
with gr.Column(scale=4):
|