Spaces:
Running
Running
update UX
Browse files
app.py
CHANGED
|
@@ -75,7 +75,7 @@ GLOBAL_CSS = """
|
|
| 75 |
.card-force-dark div {
|
| 76 |
color: #000000 !important;
|
| 77 |
.card-force-dark summary {
|
| 78 |
-
color: #
|
| 79 |
}
|
| 80 |
"""
|
| 81 |
|
|
@@ -168,11 +168,11 @@ def search_free_text_animated(query_text, max_results):
|
|
| 168 |
|
| 169 |
def find_book_cards_animated(partial_title):
|
| 170 |
# FASE 1: Spinner ON, Dataset OFF
|
| 171 |
-
yield gr.update(visible=True), gr.update(visible=False), []
|
| 172 |
time.sleep(0.3)
|
| 173 |
|
| 174 |
if not partial_title or len(partial_title) < 2:
|
| 175 |
-
yield gr.update(visible=False), gr.update(samples=[], visible=False), []
|
| 176 |
return
|
| 177 |
|
| 178 |
conn = None
|
|
@@ -185,11 +185,11 @@ def find_book_cards_animated(partial_title):
|
|
| 185 |
full_data_state = [{"id": row[0], "title": row[1]} for row in rows]
|
| 186 |
|
| 187 |
# FASE 2: Spinner OFF, Dataset ON
|
| 188 |
-
yield gr.update(visible=False), gr.update(samples=card_data, visible=True), full_data_state
|
| 189 |
|
| 190 |
except Exception as e:
|
| 191 |
print(f"Error: {e}")
|
| 192 |
-
yield gr.update(visible=False), gr.update(visible=False), []
|
| 193 |
finally:
|
| 194 |
if conn: conn.close()
|
| 195 |
|
|
@@ -271,8 +271,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=GLOBAL_CSS) as demo:
|
|
| 271 |
btn_search.click(fn=search_free_text_animated, inputs=[txt_input, num_results], outputs=[loader_results, out_results])
|
| 272 |
txt_input.submit(fn=search_free_text_animated, inputs=[txt_input, num_results], outputs=[loader_results, out_results])
|
| 273 |
|
| 274 |
-
btn_find.click(fn=find_book_cards_animated, inputs=[txt_title], outputs=[loader_cards, cards_view, books_state])
|
| 275 |
-
txt_title.submit(fn=find_book_cards_animated, inputs=[txt_title], outputs=[loader_cards, cards_view, books_state])
|
| 276 |
|
| 277 |
cards_view.click(
|
| 278 |
fn=on_card_click_animated,
|
|
|
|
| 75 |
.card-force-dark div {
|
| 76 |
color: #000000 !important;
|
| 77 |
.card-force-dark summary {
|
| 78 |
+
color: #000000 !important;
|
| 79 |
}
|
| 80 |
"""
|
| 81 |
|
|
|
|
| 168 |
|
| 169 |
def find_book_cards_animated(partial_title):
|
| 170 |
# FASE 1: Spinner ON, Dataset OFF
|
| 171 |
+
yield gr.update(visible=True), gr.update(visible=False), [], gr.update(value="", visible=False)
|
| 172 |
time.sleep(0.3)
|
| 173 |
|
| 174 |
if not partial_title or len(partial_title) < 2:
|
| 175 |
+
yield gr.update(visible=False), gr.update(samples=[], visible=False), [], gr.update(visible=False)
|
| 176 |
return
|
| 177 |
|
| 178 |
conn = None
|
|
|
|
| 185 |
full_data_state = [{"id": row[0], "title": row[1]} for row in rows]
|
| 186 |
|
| 187 |
# FASE 2: Spinner OFF, Dataset ON
|
| 188 |
+
yield gr.update(visible=False), gr.update(samples=card_data, visible=True), full_data_state, gr.update(visible=False)
|
| 189 |
|
| 190 |
except Exception as e:
|
| 191 |
print(f"Error: {e}")
|
| 192 |
+
yield gr.update(visible=False), gr.update(visible=False), [], gr.update(visible=False)
|
| 193 |
finally:
|
| 194 |
if conn: conn.close()
|
| 195 |
|
|
|
|
| 271 |
btn_search.click(fn=search_free_text_animated, inputs=[txt_input, num_results], outputs=[loader_results, out_results])
|
| 272 |
txt_input.submit(fn=search_free_text_animated, inputs=[txt_input, num_results], outputs=[loader_results, out_results])
|
| 273 |
|
| 274 |
+
btn_find.click(fn=find_book_cards_animated, inputs=[txt_title], outputs=[loader_cards, cards_view, books_state, out_results])
|
| 275 |
+
txt_title.submit(fn=find_book_cards_animated, inputs=[txt_title], outputs=[loader_cards, cards_view, books_state, out_results])
|
| 276 |
|
| 277 |
cards_view.click(
|
| 278 |
fn=on_card_click_animated,
|