Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,38 +45,32 @@ def ensure_tooltip_css():
|
|
| 45 |
.help-tt{display:inline-flex; justify-content:center; align-items:center;
|
| 46 |
width:1.1rem; height:1.1rem; border-radius:999px; font-weight:700;
|
| 47 |
border:1px solid rgba(0,0,0,.3); color:rgba(0,0,0,.75);
|
| 48 |
-
background:rgba(0,0,0,.04); cursor:help; margin-left:.5rem;
|
| 49 |
-
}
|
| 50 |
.help-tt::before{content:"?"; font-size:.8rem; line-height:1;}
|
| 51 |
-
.tt-panel{
|
| 52 |
-
position:absolute; z-index:9999; left:0; top:140%;
|
| 53 |
background:#111; color:#fff; padding:.6rem .8rem; border-radius:.5rem;
|
| 54 |
width:max-content; max-width:32rem; box-shadow:0 8px 24px rgba(0,0,0,.2);
|
| 55 |
opacity:0; transform:translateY(-4px); pointer-events:none;
|
| 56 |
-
transition:opacity .12s ease, transform .12s ease;
|
| 57 |
-
}
|
| 58 |
.tt-wrap:hover .tt-panel, .help-tt:focus + .tt-panel{
|
| 59 |
-
opacity:1; transform:translateY(0); pointer-events:auto;
|
| 60 |
-
}
|
| 61 |
-
.tt-panel dl{margin:0;}
|
| 62 |
-
.tt-panel dt{font-weight:700; margin:.25rem 0 0;}
|
| 63 |
.tt-panel dd{margin:0 0 .25rem 0;}
|
| 64 |
</style>
|
| 65 |
""", unsafe_allow_html=True)
|
| 66 |
st.session_state["_tt_css_done"] = True
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
def deflist_tooltip_html(defs: list[tuple[str, str]]) -> str:
|
| 70 |
-
# build the <dl> content
|
| 71 |
-
import html as _html
|
| 72 |
-
dl = "".join(
|
| 73 |
-
f"<dt>{_html.escape(k)}</dt><dd>{_html.escape(v)}</dd>"
|
| 74 |
-
for k, v in defs
|
| 75 |
-
)
|
| 76 |
-
return f"""<span class="tt-wrap">
|
| 77 |
-
<span class="help-tt" tabindex="0" aria-label="definitions"></span>
|
| 78 |
-
<div class="tt-panel"><dl>{dl}</dl></div>
|
| 79 |
-
</span>"""
|
| 80 |
|
| 81 |
########################################################################################
|
| 82 |
|
|
@@ -491,12 +485,7 @@ def validate_current_page(fields: List[Field], index: int) -> bool:
|
|
| 491 |
st.error("Please fill in all mandatory fields.")
|
| 492 |
return ok
|
| 493 |
|
| 494 |
-
|
| 495 |
-
ensure_tooltip_css()
|
| 496 |
-
tip = deflist_tooltip_html(defs) if defs else ""
|
| 497 |
-
# Title supports Markdown; append HTML “?” fragment
|
| 498 |
-
st.markdown(f"{title_md} {tip}", unsafe_allow_html=True)
|
| 499 |
-
|
| 500 |
#################################### Streamlit App ####################################
|
| 501 |
|
| 502 |
# Function to navigate rows
|
|
|
|
| 45 |
.help-tt{display:inline-flex; justify-content:center; align-items:center;
|
| 46 |
width:1.1rem; height:1.1rem; border-radius:999px; font-weight:700;
|
| 47 |
border:1px solid rgba(0,0,0,.3); color:rgba(0,0,0,.75);
|
| 48 |
+
background:rgba(0,0,0,.04); cursor:help; margin-left:.5rem;}
|
|
|
|
| 49 |
.help-tt::before{content:"?"; font-size:.8rem; line-height:1;}
|
| 50 |
+
.tt-panel{position:absolute; z-index:9999; left:0; top:140%;
|
|
|
|
| 51 |
background:#111; color:#fff; padding:.6rem .8rem; border-radius:.5rem;
|
| 52 |
width:max-content; max-width:32rem; box-shadow:0 8px 24px rgba(0,0,0,.2);
|
| 53 |
opacity:0; transform:translateY(-4px); pointer-events:none;
|
| 54 |
+
transition:opacity .12s ease, transform .12s ease;}
|
|
|
|
| 55 |
.tt-wrap:hover .tt-panel, .help-tt:focus + .tt-panel{
|
| 56 |
+
opacity:1; transform:translateY(0); pointer-events:auto;}
|
| 57 |
+
.tt-panel dl{margin:0;} .tt-panel dt{font-weight:700; margin:.25rem 0 0;}
|
|
|
|
|
|
|
| 58 |
.tt-panel dd{margin:0 0 .25rem 0;}
|
| 59 |
</style>
|
| 60 |
""", unsafe_allow_html=True)
|
| 61 |
st.session_state["_tt_css_done"] = True
|
| 62 |
|
| 63 |
+
def deflist_tooltip_html(defs):
|
| 64 |
+
import html
|
| 65 |
+
dl = "".join(f"<dt>{html.escape(k)}</dt><dd>{html.escape(v)}</dd>" for k,v in defs)
|
| 66 |
+
return f'<span class="tt-wrap"><span class="help-tt" tabindex="0" aria-label="definitions"></span><div class="tt-panel"><dl>{dl}</dl></div></span>'
|
| 67 |
+
|
| 68 |
+
def render_container_header(title_md, defs):
|
| 69 |
+
ensure_tooltip_css()
|
| 70 |
+
tip = deflist_tooltip_html(defs)
|
| 71 |
+
st.markdown(f"{title_md} {tip}", unsafe_allow_html=True)
|
| 72 |
+
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
########################################################################################
|
| 76 |
|
|
|
|
| 485 |
st.error("Please fill in all mandatory fields.")
|
| 486 |
return ok
|
| 487 |
|
| 488 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
#################################### Streamlit App ####################################
|
| 490 |
|
| 491 |
# Function to navigate rows
|