Spaces:
Running
Running
Daryl Lim Claude Sonnet 4.6 commited on
Commit ·
ea7372a
1
Parent(s): 77df3a5
feat: replace standalone Clear button with inline clear on input
Browse files- app.py +2 -7
- tests/test_app.py +0 -5
app.py
CHANGED
|
@@ -104,6 +104,7 @@ def _build_demo() -> gr.Blocks:
|
|
| 104 |
input_text = gr.Textbox(
|
| 105 |
lines=6,
|
| 106 |
show_label=False,
|
|
|
|
| 107 |
)
|
| 108 |
with gr.Row():
|
| 109 |
char_count = gr.Markdown("0 / 2,000")
|
|
@@ -123,9 +124,7 @@ def _build_demo() -> gr.Blocks:
|
|
| 123 |
buttons=["copy"],
|
| 124 |
)
|
| 125 |
|
| 126 |
-
|
| 127 |
-
clear_btn = gr.Button("Clear")
|
| 128 |
-
translate_btn = gr.Button("Translate", variant="primary")
|
| 129 |
|
| 130 |
translate_btn.click(
|
| 131 |
fn=translate,
|
|
@@ -142,10 +141,6 @@ def _build_demo() -> gr.Blocks:
|
|
| 142 |
inputs=input_text,
|
| 143 |
outputs=char_count,
|
| 144 |
)
|
| 145 |
-
clear_btn.click(
|
| 146 |
-
fn=lambda: ("", "", "0 / 2,000"),
|
| 147 |
-
outputs=[input_text, output_text, char_count],
|
| 148 |
-
)
|
| 149 |
|
| 150 |
return demo
|
| 151 |
|
|
|
|
| 104 |
input_text = gr.Textbox(
|
| 105 |
lines=6,
|
| 106 |
show_label=False,
|
| 107 |
+
buttons=["clear"],
|
| 108 |
)
|
| 109 |
with gr.Row():
|
| 110 |
char_count = gr.Markdown("0 / 2,000")
|
|
|
|
| 124 |
buttons=["copy"],
|
| 125 |
)
|
| 126 |
|
| 127 |
+
translate_btn = gr.Button("Translate", variant="primary")
|
|
|
|
|
|
|
| 128 |
|
| 129 |
translate_btn.click(
|
| 130 |
fn=translate,
|
|
|
|
| 141 |
inputs=input_text,
|
| 142 |
outputs=char_count,
|
| 143 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
return demo
|
| 146 |
|
tests/test_app.py
CHANGED
|
@@ -127,11 +127,6 @@ def test_demo_has_translate_button(demo):
|
|
| 127 |
assert any(b.value == "Translate" for b in buttons), "Expected a 'Translate' button"
|
| 128 |
|
| 129 |
|
| 130 |
-
def test_demo_has_clear_button(demo):
|
| 131 |
-
"""UI should have a Clear button."""
|
| 132 |
-
buttons = [b for b in demo.blocks.values() if type(b).__name__ == "Button"]
|
| 133 |
-
assert any(b.value == "Clear" for b in buttons), "Expected a 'Clear' button"
|
| 134 |
-
|
| 135 |
|
| 136 |
def test_translate_handlers_wire_text_and_language(demo):
|
| 137 |
"""Translate click and submit handlers should wire input text and target language."""
|
|
|
|
| 127 |
assert any(b.value == "Translate" for b in buttons), "Expected a 'Translate' button"
|
| 128 |
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
def test_translate_handlers_wire_text_and_language(demo):
|
| 132 |
"""Translate click and submit handlers should wire input text and target language."""
|