Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
"""
|
| 4 |
🪶 Council Matters Classifier – PT
|
| 5 |
-
|
| 6 |
"""
|
| 7 |
|
| 8 |
import gradio as gr
|
|
@@ -183,7 +183,7 @@ button:hover { background-color: #00aaff !important; }
|
|
| 183 |
background-color: #112f50;
|
| 184 |
border-radius: 10px;
|
| 185 |
border: 1px solid #1f3c5a;
|
| 186 |
-
padding: 10px;
|
| 187 |
display: flex;
|
| 188 |
align-items: center;
|
| 189 |
justify-content: center;
|
|
@@ -207,7 +207,7 @@ button:hover { background-color: #00aaff !important; }
|
|
| 207 |
.use-btn:hover { background-color:#99ccff !important; }
|
| 208 |
.suggestion-box .prev-btn { position: absolute; top: 5px; left: 5px; }
|
| 209 |
.suggestion-box .next-btn { position: absolute; top: 5px; right: 5px; }
|
| 210 |
-
.suggestion-
|
| 211 |
"""
|
| 212 |
|
| 213 |
# ---------------- Gradio UI ----------------
|
|
@@ -221,17 +221,34 @@ with gr.Blocks(css=custom_css, theme="gradio/soft") as demo:
|
|
| 221 |
output = gr.HTML()
|
| 222 |
classify_btn.click(fn=classify_display, inputs=input_text, outputs=output)
|
| 223 |
|
| 224 |
-
#
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
# ---------------- Launch ----------------
|
| 237 |
if __name__ == "__main__":
|
|
|
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
"""
|
| 4 |
🪶 Council Matters Classifier – PT
|
| 5 |
+
Dark modern Gradio interface with top corner arrow buttons for suggestions.
|
| 6 |
"""
|
| 7 |
|
| 8 |
import gradio as gr
|
|
|
|
| 183 |
background-color: #112f50;
|
| 184 |
border-radius: 10px;
|
| 185 |
border: 1px solid #1f3c5a;
|
| 186 |
+
padding: 30px 10px 10px 10px;
|
| 187 |
display: flex;
|
| 188 |
align-items: center;
|
| 189 |
justify-content: center;
|
|
|
|
| 207 |
.use-btn:hover { background-color:#99ccff !important; }
|
| 208 |
.suggestion-box .prev-btn { position: absolute; top: 5px; left: 5px; }
|
| 209 |
.suggestion-box .next-btn { position: absolute; top: 5px; right: 5px; }
|
| 210 |
+
.suggestion-text { text-align: center; color: #eee; font-weight: 500; width: 100%; }
|
| 211 |
"""
|
| 212 |
|
| 213 |
# ---------------- Gradio UI ----------------
|
|
|
|
| 221 |
output = gr.HTML()
|
| 222 |
classify_btn.click(fn=classify_display, inputs=input_text, outputs=output)
|
| 223 |
|
| 224 |
+
# Caixa de sugestões com setas no topo
|
| 225 |
+
suggestion_box_html = f"""
|
| 226 |
+
<div class="suggestion-box">
|
| 227 |
+
<button class="arrow-btn prev-btn" onclick="updateSuggestion('prev')">⟨</button>
|
| 228 |
+
<span class="suggestion-text" id="suggestion-text">{suggestions[0]}</span>
|
| 229 |
+
<button class="arrow-btn next-btn" onclick="updateSuggestion('next')">⟩</button>
|
| 230 |
+
</div>
|
| 231 |
+
<div style="text-align:center;margin-top:5px;">
|
| 232 |
+
<button class="use-btn" onclick="useSuggestion()">Usar</button>
|
| 233 |
+
</div>
|
| 234 |
+
"""
|
| 235 |
+
suggestion_html = gr.HTML(suggestion_box_html)
|
| 236 |
+
|
| 237 |
+
# JavaScript para navegar sugestões
|
| 238 |
+
demo.load(lambda: None, [], [], _js=f"""
|
| 239 |
+
let examples = {suggestions};
|
| 240 |
+
let index = 0;
|
| 241 |
+
function updateSuggestion(direction){{
|
| 242 |
+
const el = document.getElementById('suggestion-text');
|
| 243 |
+
if(direction==='next') index=(index+1)%examples.length;
|
| 244 |
+
else index=(index-1+examples.length)%examples.length;
|
| 245 |
+
el.innerText = examples[index];
|
| 246 |
+
}}
|
| 247 |
+
function useSuggestion(){{
|
| 248 |
+
const text = document.getElementById('suggestion-text').innerText;
|
| 249 |
+
document.querySelector('textarea').value = text;
|
| 250 |
+
}}
|
| 251 |
+
""")
|
| 252 |
|
| 253 |
# ---------------- Launch ----------------
|
| 254 |
if __name__ == "__main__":
|