Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,41 +36,6 @@ def get_param_from_url(param):
|
|
| 36 |
user_id = st.query_params.get(param, "")
|
| 37 |
return user_id
|
| 38 |
|
| 39 |
-
def ensure_tooltip_css():
|
| 40 |
-
if st.session_state.get("_tt_css_done"):
|
| 41 |
-
return
|
| 42 |
-
st.markdown("""
|
| 43 |
-
<style>
|
| 44 |
-
.tt-wrap{display:inline-block; position:relative;}
|
| 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 |
|
|
@@ -167,12 +132,7 @@ fields: List[Field] = [
|
|
| 167 |
title="Level of priority", other_params={'labels': priority_labels}, mandatory=True),
|
| 168 |
]),
|
| 169 |
|
| 170 |
-
Field(type="container", title="##### Rupture Markers",
|
| 171 |
-
"defs": [
|
| 172 |
-
("Withdrawal", "Patient moves away from therapist/therapy."),
|
| 173 |
-
("Confrontation", "Patient moves against therapist/therapy."),
|
| 174 |
-
("Mixed", "Both withdrawal and confrontation markers present."),
|
| 175 |
-
]}, children=[
|
| 176 |
Field(type="expander", title="**Overview of rupture markers** *(expand)*", children=[
|
| 177 |
Field(type="markdown", title="", other_params={"path": "rupture_marker_overview.md"}),
|
| 178 |
]),
|
|
@@ -571,8 +531,6 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 571 |
show_field(child, index, data_collected)
|
| 572 |
|
| 573 |
case 'container':
|
| 574 |
-
defs = f.other_params.get("defs") if f.other_params else None
|
| 575 |
-
render_container_header(f.title, defs)
|
| 576 |
with st.container(border=True):
|
| 577 |
st.markdown(f.title)
|
| 578 |
for child in (f.children or []):
|
|
|
|
| 36 |
user_id = st.query_params.get(param, "")
|
| 37 |
return user_id
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
########################################################################################
|
| 41 |
|
|
|
|
| 132 |
title="Level of priority", other_params={'labels': priority_labels}, mandatory=True),
|
| 133 |
]),
|
| 134 |
|
| 135 |
+
Field(type="container", title="##### Rupture Markers", children=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
Field(type="expander", title="**Overview of rupture markers** *(expand)*", children=[
|
| 137 |
Field(type="markdown", title="", other_params={"path": "rupture_marker_overview.md"}),
|
| 138 |
]),
|
|
|
|
| 531 |
show_field(child, index, data_collected)
|
| 532 |
|
| 533 |
case 'container':
|
|
|
|
|
|
|
| 534 |
with st.container(border=True):
|
| 535 |
st.markdown(f.title)
|
| 536 |
for child in (f.children or []):
|