Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +37 -58
src/streamlit_app.py
CHANGED
|
@@ -85,30 +85,20 @@ header, footer, #MainMenu, .stDeployButton,
|
|
| 85 |
color:rgba(255,182,193,.4); line-height:1.6; }
|
| 86 |
|
| 87 |
/* ββ BUTTONS (Global Styles) ββ */
|
| 88 |
-
.btn-row {
|
| 89 |
-
position: relative; z-index: 10;
|
| 90 |
-
display: flex;
|
| 91 |
-
justify-content: center;
|
| 92 |
-
align-items: center;
|
| 93 |
-
gap: 14px;
|
| 94 |
-
margin-top: 4px;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
div[data-testid="stButton"] > button {
|
| 98 |
background: linear-gradient(135deg, #ff1493, #ff69b4);
|
| 99 |
color: #fff;
|
| 100 |
border: none;
|
| 101 |
border-radius: 50px;
|
| 102 |
font-family: 'Lato', sans-serif;
|
| 103 |
-
font-size:
|
| 104 |
font-weight: 700;
|
| 105 |
-
letter-spacing: 1.
|
| 106 |
text-transform: uppercase;
|
| 107 |
-
padding:
|
| 108 |
box-shadow: 0 4px 18px rgba(255,20,147,0.38);
|
| 109 |
-
transition: all 0.
|
| 110 |
-
width:
|
| 111 |
-
min-width: 110px;
|
| 112 |
}
|
| 113 |
div[data-testid="stButton"] > button:active {
|
| 114 |
transform: scale(0.96);
|
|
@@ -117,7 +107,7 @@ div[data-testid="stButton"] > button:active {
|
|
| 117 |
/* ββ OVERLAY (No image + Yes image) ββ */
|
| 118 |
.overlay {
|
| 119 |
position: fixed; top:0; left:0; width:100vw; height:100vh;
|
| 120 |
-
background: rgba(0,0,0,0.92);
|
| 121 |
backdrop-filter: blur(12px);
|
| 122 |
z-index: 2000;
|
| 123 |
display: flex; flex-direction: column;
|
|
@@ -133,7 +123,7 @@ div[data-testid="stButton"] > button:active {
|
|
| 133 |
border: 1px solid rgba(255,105,180,0.2);
|
| 134 |
box-shadow: 0 0 50px rgba(255,20,147,0.18), 0 16px 40px rgba(0,0,0,0.5);
|
| 135 |
animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
|
| 136 |
-
margin-top: -20px;
|
| 137 |
}
|
| 138 |
@keyframes popIn { from{transform:scale(0.75);opacity:0} to{transform:scale(1);opacity:1} }
|
| 139 |
|
|
@@ -314,64 +304,53 @@ if st.session_state.show_yes:
|
|
| 314 |
st.stop()
|
| 315 |
|
| 316 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 317 |
-
# NO OVERLAY (
|
| 318 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 319 |
if st.session_state.showing_no:
|
| 320 |
no_stems = ["no1", "no2", "no3"]
|
| 321 |
idx = st.session_state.no_index % 3
|
| 322 |
|
| 323 |
-
# Load Image
|
| 324 |
b64, mime = img_to_b64(no_stems[idx])
|
| 325 |
img_tag = f'<img src="data:{mime};base64,{b64}"/>' if b64 \
|
| 326 |
else '<div style="font-size:72px;margin-bottom:4px">π’</div>'
|
| 327 |
|
| 328 |
-
# Titles
|
| 329 |
titles = ["Why though... π₯Ί", "Really? π", "My poor heart...", "Please reconsider π"]
|
| 330 |
t = titles[st.session_state.no_index % 4]
|
| 331 |
|
| 332 |
-
# Show Overlay (Note: No button inside HTML)
|
| 333 |
st.markdown(f"""
|
| 334 |
<div class="overlay">
|
| 335 |
{img_tag}
|
| 336 |
<p class="overlay-title">{t}</p>
|
| 337 |
<p class="overlay-sub">I'm not letting you leave until you say Yes. π€<br>(Tap the X to try again)</p>
|
| 338 |
</div>
|
| 339 |
-
|
| 340 |
<style>
|
| 341 |
-
/*
|
| 342 |
-
div[data-testid="stButton"]
|
| 343 |
position: fixed !important;
|
| 344 |
-
top:
|
| 345 |
-
right:
|
| 346 |
z-index: 2005 !important;
|
| 347 |
-
|
| 348 |
background: rgba(0,0,0,0.5) !important;
|
| 349 |
color: rgba(255,255,255,0.8) !important;
|
| 350 |
border: 1px solid rgba(255,255,255,0.3) !important;
|
| 351 |
border-radius: 50% !important;
|
| 352 |
-
width:
|
| 353 |
-
height:
|
| 354 |
-
min-width: 0 !important;
|
| 355 |
padding: 0 !important;
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
line-height: 1 !important;
|
| 359 |
-
display: flex !important;
|
| 360 |
-
align-items: center !important;
|
| 361 |
-
justify-content: center !important;
|
| 362 |
}}
|
| 363 |
-
div[data-testid="stButton"]
|
| 364 |
background: rgba(255,20,147,0.8) !important;
|
| 365 |
-
color: #fff !important;
|
| 366 |
border-color: #ff69b4 !important;
|
|
|
|
| 367 |
}}
|
| 368 |
</style>
|
| 369 |
""", unsafe_allow_html=True)
|
| 370 |
|
| 371 |
-
# The "X" Button
|
| 372 |
if st.button("β", key="close_overlay_btn"):
|
| 373 |
st.session_state.showing_no = False
|
| 374 |
-
st.session_state.no_index += 1 # Increment
|
| 375 |
st.rerun()
|
| 376 |
|
| 377 |
st.stop()
|
|
@@ -390,34 +369,36 @@ st.markdown("""
|
|
| 390 |
</div>
|
| 391 |
""", unsafe_allow_html=True)
|
| 392 |
|
| 393 |
-
# ββ Dynamic
|
| 394 |
-
# Calculate scale based on how many times "No" has been clicked
|
| 395 |
click_count = st.session_state.no_index
|
| 396 |
-
#
|
| 397 |
-
scale_factor = max(0.
|
| 398 |
|
| 399 |
-
#
|
|
|
|
| 400 |
st.markdown(f"""
|
| 401 |
<style>
|
| 402 |
-
/*
|
| 403 |
-
div[data-testid="column"]:nth-of-type(
|
| 404 |
transform: scale({scale_factor});
|
| 405 |
transform-origin: center center;
|
| 406 |
-
transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
|
| 407 |
}}
|
| 408 |
-
/*
|
| 409 |
-
div[data-testid="column"]:nth-of-type(
|
| 410 |
-
|
| 411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
}}
|
| 413 |
</style>
|
| 414 |
""", unsafe_allow_html=True)
|
| 415 |
|
| 416 |
# ββ Buttons ββ
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
# Columns: [spacer, Yes, gap, No, spacer]
|
| 420 |
-
_, c1, gap, c2, _ = st.columns([1, 2, 0.3, 2, 1])
|
| 421 |
|
| 422 |
with c1:
|
| 423 |
if st.button("β¦ Yes! β¦", key="yes_btn", use_container_width=True):
|
|
@@ -429,8 +410,6 @@ with c2:
|
|
| 429 |
st.session_state.showing_no = True
|
| 430 |
st.rerun()
|
| 431 |
|
| 432 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
| 433 |
-
|
| 434 |
# Guilt Trip Text
|
| 435 |
no_messages = [
|
| 436 |
"Are you sure? π₯Ί", "Please reconsider... π",
|
|
|
|
| 85 |
color:rgba(255,182,193,.4); line-height:1.6; }
|
| 86 |
|
| 87 |
/* ββ BUTTONS (Global Styles) ββ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
div[data-testid="stButton"] > button {
|
| 89 |
background: linear-gradient(135deg, #ff1493, #ff69b4);
|
| 90 |
color: #fff;
|
| 91 |
border: none;
|
| 92 |
border-radius: 50px;
|
| 93 |
font-family: 'Lato', sans-serif;
|
| 94 |
+
font-size: 16px; /* Bigger Font */
|
| 95 |
font-weight: 700;
|
| 96 |
+
letter-spacing: 1.5px;
|
| 97 |
text-transform: uppercase;
|
| 98 |
+
padding: 16px 32px; /* Bigger Padding = Longer Button */
|
| 99 |
box-shadow: 0 4px 18px rgba(255,20,147,0.38);
|
| 100 |
+
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
| 101 |
+
width: 100%; /* Fill the column */
|
|
|
|
| 102 |
}
|
| 103 |
div[data-testid="stButton"] > button:active {
|
| 104 |
transform: scale(0.96);
|
|
|
|
| 107 |
/* ββ OVERLAY (No image + Yes image) ββ */
|
| 108 |
.overlay {
|
| 109 |
position: fixed; top:0; left:0; width:100vw; height:100vh;
|
| 110 |
+
background: rgba(0,0,0,0.92);
|
| 111 |
backdrop-filter: blur(12px);
|
| 112 |
z-index: 2000;
|
| 113 |
display: flex; flex-direction: column;
|
|
|
|
| 123 |
border: 1px solid rgba(255,105,180,0.2);
|
| 124 |
box-shadow: 0 0 50px rgba(255,20,147,0.18), 0 16px 40px rgba(0,0,0,0.5);
|
| 125 |
animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
|
| 126 |
+
margin-top: -20px;
|
| 127 |
}
|
| 128 |
@keyframes popIn { from{transform:scale(0.75);opacity:0} to{transform:scale(1);opacity:1} }
|
| 129 |
|
|
|
|
| 304 |
st.stop()
|
| 305 |
|
| 306 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 307 |
+
# NO OVERLAY (X Button)
|
| 308 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 309 |
if st.session_state.showing_no:
|
| 310 |
no_stems = ["no1", "no2", "no3"]
|
| 311 |
idx = st.session_state.no_index % 3
|
| 312 |
|
|
|
|
| 313 |
b64, mime = img_to_b64(no_stems[idx])
|
| 314 |
img_tag = f'<img src="data:{mime};base64,{b64}"/>' if b64 \
|
| 315 |
else '<div style="font-size:72px;margin-bottom:4px">π’</div>'
|
| 316 |
|
|
|
|
| 317 |
titles = ["Why though... π₯Ί", "Really? π", "My poor heart...", "Please reconsider π"]
|
| 318 |
t = titles[st.session_state.no_index % 4]
|
| 319 |
|
|
|
|
| 320 |
st.markdown(f"""
|
| 321 |
<div class="overlay">
|
| 322 |
{img_tag}
|
| 323 |
<p class="overlay-title">{t}</p>
|
| 324 |
<p class="overlay-sub">I'm not letting you leave until you say Yes. π€<br>(Tap the X to try again)</p>
|
| 325 |
</div>
|
|
|
|
| 326 |
<style>
|
| 327 |
+
/* Explicitly target the Close Button (X) */
|
| 328 |
+
div[data-testid="stButton"] button {{
|
| 329 |
position: fixed !important;
|
| 330 |
+
top: 24px !important;
|
| 331 |
+
right: 24px !important;
|
| 332 |
z-index: 2005 !important;
|
|
|
|
| 333 |
background: rgba(0,0,0,0.5) !important;
|
| 334 |
color: rgba(255,255,255,0.8) !important;
|
| 335 |
border: 1px solid rgba(255,255,255,0.3) !important;
|
| 336 |
border-radius: 50% !important;
|
| 337 |
+
width: 44px !important;
|
| 338 |
+
height: 44px !important;
|
|
|
|
| 339 |
padding: 0 !important;
|
| 340 |
+
font-size: 20px !important;
|
| 341 |
+
display: flex !important; align-items: center !important; justify-content: center !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
}}
|
| 343 |
+
div[data-testid="stButton"] button:hover {{
|
| 344 |
background: rgba(255,20,147,0.8) !important;
|
|
|
|
| 345 |
border-color: #ff69b4 !important;
|
| 346 |
+
color: white !important;
|
| 347 |
}}
|
| 348 |
</style>
|
| 349 |
""", unsafe_allow_html=True)
|
| 350 |
|
|
|
|
| 351 |
if st.button("β", key="close_overlay_btn"):
|
| 352 |
st.session_state.showing_no = False
|
| 353 |
+
st.session_state.no_index += 1 # Increment to shrink button next time
|
| 354 |
st.rerun()
|
| 355 |
|
| 356 |
st.stop()
|
|
|
|
| 369 |
</div>
|
| 370 |
""", unsafe_allow_html=True)
|
| 371 |
|
| 372 |
+
# ββ Dynamic Shrinking Logic ββ
|
|
|
|
| 373 |
click_count = st.session_state.no_index
|
| 374 |
+
# Start at 100%, shrink by 15% each time, don't go below 20%
|
| 375 |
+
scale_factor = max(0.2, 1.0 - (click_count * 0.15))
|
| 376 |
|
| 377 |
+
# CSS to target the 2nd column (NO Button) and 1st column (YES Button)
|
| 378 |
+
# We use 'nth-of-type(2)' which maps to the second column div
|
| 379 |
st.markdown(f"""
|
| 380 |
<style>
|
| 381 |
+
/* Target the Second Column (NO Button) */
|
| 382 |
+
div[data-testid="column"]:nth-of-type(2) button {{
|
| 383 |
transform: scale({scale_factor});
|
| 384 |
transform-origin: center center;
|
| 385 |
+
transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
|
| 386 |
}}
|
| 387 |
+
/* Target the First Column (YES Button) - Pulse slightly */
|
| 388 |
+
div[data-testid="column"]:nth-of-type(1) button {{
|
| 389 |
+
animation: pulseBtn 2s infinite;
|
| 390 |
+
}}
|
| 391 |
+
@keyframes pulseBtn {{
|
| 392 |
+
0% {{ transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 20, 147, 0.7); }}
|
| 393 |
+
70% {{ transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 20, 147, 0); }}
|
| 394 |
+
100% {{ transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 20, 147, 0); }}
|
| 395 |
}}
|
| 396 |
</style>
|
| 397 |
""", unsafe_allow_html=True)
|
| 398 |
|
| 399 |
# ββ Buttons ββ
|
| 400 |
+
# 2 Columns for reliability (Yes = 1st, No = 2nd)
|
| 401 |
+
c1, c2 = st.columns(2)
|
|
|
|
|
|
|
| 402 |
|
| 403 |
with c1:
|
| 404 |
if st.button("β¦ Yes! β¦", key="yes_btn", use_container_width=True):
|
|
|
|
| 410 |
st.session_state.showing_no = True
|
| 411 |
st.rerun()
|
| 412 |
|
|
|
|
|
|
|
| 413 |
# Guilt Trip Text
|
| 414 |
no_messages = [
|
| 415 |
"Are you sure? π₯Ί", "Please reconsider... π",
|