Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,22 +8,27 @@ def filter_table(query):
|
|
| 8 |
if query.strip() == "":
|
| 9 |
filtered = df.copy()
|
| 10 |
else:
|
| 11 |
-
filtered = df[
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
style = """
|
| 16 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
.styled-table {
|
| 18 |
width: 100%;
|
| 19 |
border-collapse: collapse;
|
| 20 |
font-family: 'Segoe UI', sans-serif;
|
| 21 |
color: #e0e0e0;
|
| 22 |
background-color: #1e1e1e;
|
| 23 |
-
border: 1px solid #333;
|
| 24 |
-
border-radius: 8px;
|
| 25 |
-
box-shadow: 0 0 12px #00000044;
|
| 26 |
-
overflow: hidden;
|
| 27 |
}
|
| 28 |
.styled-table th {
|
| 29 |
background-color: #2c2c2c;
|
|
@@ -31,6 +36,9 @@ def filter_table(query):
|
|
| 31 |
text-align: left;
|
| 32 |
color: #64b5f6;
|
| 33 |
border-bottom: 2px solid #444;
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
.styled-table td {
|
| 36 |
padding: 10px;
|
|
@@ -42,23 +50,28 @@ def filter_table(query):
|
|
| 42 |
</style>
|
| 43 |
"""
|
| 44 |
|
| 45 |
-
html_table = f"{style}<table class='styled-table'>"
|
| 46 |
html_table += "<tr><th>Paper</th><th>Note</th><th>Status</th></tr>"
|
| 47 |
|
| 48 |
for _, row in filtered.iterrows():
|
| 49 |
html_table += f"<tr><td>{row['Paper name']}</td><td>{row['Note']}</td><td>{row['Status']}</td></tr>"
|
| 50 |
|
| 51 |
-
html_table += "</table>"
|
| 52 |
return html_table
|
| 53 |
|
| 54 |
-
# Gradio
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
demo.launch()
|
| 64 |
|
|
|
|
|
|
| 8 |
if query.strip() == "":
|
| 9 |
filtered = df.copy()
|
| 10 |
else:
|
| 11 |
+
filtered = df[
|
| 12 |
+
df['Paper name'].str.contains(query, case=False, na=False) |
|
| 13 |
+
df['Note'].str.contains(query, case=False, na=False)
|
| 14 |
+
]
|
| 15 |
|
| 16 |
+
# Styled HTML with full-width scrollable table
|
| 17 |
style = """
|
| 18 |
<style>
|
| 19 |
+
.scroll-container {
|
| 20 |
+
max-height: 500px;
|
| 21 |
+
overflow-y: auto;
|
| 22 |
+
border: 1px solid #333;
|
| 23 |
+
border-radius: 6px;
|
| 24 |
+
background-color: #1e1e1e;
|
| 25 |
+
}
|
| 26 |
.styled-table {
|
| 27 |
width: 100%;
|
| 28 |
border-collapse: collapse;
|
| 29 |
font-family: 'Segoe UI', sans-serif;
|
| 30 |
color: #e0e0e0;
|
| 31 |
background-color: #1e1e1e;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
.styled-table th {
|
| 34 |
background-color: #2c2c2c;
|
|
|
|
| 36 |
text-align: left;
|
| 37 |
color: #64b5f6;
|
| 38 |
border-bottom: 2px solid #444;
|
| 39 |
+
position: sticky;
|
| 40 |
+
top: 0;
|
| 41 |
+
z-index: 1;
|
| 42 |
}
|
| 43 |
.styled-table td {
|
| 44 |
padding: 10px;
|
|
|
|
| 50 |
</style>
|
| 51 |
"""
|
| 52 |
|
| 53 |
+
html_table = f"{style}<div class='scroll-container'><table class='styled-table'>"
|
| 54 |
html_table += "<tr><th>Paper</th><th>Note</th><th>Status</th></tr>"
|
| 55 |
|
| 56 |
for _, row in filtered.iterrows():
|
| 57 |
html_table += f"<tr><td>{row['Paper name']}</td><td>{row['Note']}</td><td>{row['Status']}</td></tr>"
|
| 58 |
|
| 59 |
+
html_table += "</table></div>"
|
| 60 |
return html_table
|
| 61 |
|
| 62 |
+
# Gradio Blocks layout for better positioning
|
| 63 |
+
with gr.Blocks(title="Reading Notes Viewer") as demo:
|
| 64 |
+
gr.Markdown("### Search and browse your reading notes")
|
| 65 |
+
|
| 66 |
+
query = gr.Textbox(label="Search", placeholder="Type a keyword...")
|
| 67 |
+
output = gr.HTML()
|
| 68 |
+
|
| 69 |
+
query.change(fn=filter_table, inputs=query, outputs=output)
|
| 70 |
+
|
| 71 |
+
# Show full table by default
|
| 72 |
+
output.style(full_width=True)
|
| 73 |
+
output.update(value=filter_table(""))
|
| 74 |
|
| 75 |
demo.launch()
|
| 76 |
|
| 77 |
+
|