Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +34 -34
src/streamlit_app.py
CHANGED
|
@@ -91,14 +91,14 @@ div[data-testid="stButton"] > button {
|
|
| 91 |
border: none;
|
| 92 |
border-radius: 50px;
|
| 93 |
font-family: 'Lato', sans-serif;
|
| 94 |
-
font-size: 16px;
|
| 95 |
font-weight: 700;
|
| 96 |
letter-spacing: 1.5px;
|
| 97 |
text-transform: uppercase;
|
| 98 |
-
padding: 16px 32px;
|
| 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%;
|
| 102 |
}
|
| 103 |
div[data-testid="stButton"] > button:active {
|
| 104 |
transform: scale(0.96);
|
|
@@ -304,19 +304,29 @@ if st.session_state.show_yes:
|
|
| 304 |
st.stop()
|
| 305 |
|
| 306 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 307 |
-
# NO OVERLAY (
|
| 308 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 309 |
if st.session_state.showing_no:
|
| 310 |
-
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = ["My poor heart...", "Really? π", "Why though... π₯Ί", "Please reconsider π"]
|
| 318 |
-
t = titles[st.session_state.no_index % 4]
|
| 319 |
|
|
|
|
| 320 |
st.markdown(f"""
|
| 321 |
<div class="overlay">
|
| 322 |
{img_tag}
|
|
@@ -324,33 +334,24 @@ if st.session_state.showing_no:
|
|
| 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 |
-
/*
|
| 328 |
div[data-testid="stButton"] button {{
|
| 329 |
-
position: fixed !important;
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 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
|
| 354 |
st.rerun()
|
| 355 |
|
| 356 |
st.stop()
|
|
@@ -363,7 +364,7 @@ st.markdown("""
|
|
| 363 |
<span class="rose">πΉ</span>
|
| 364 |
<p class="eyebrow">A Special Request</p>
|
| 365 |
<div class="deco"></div>
|
| 366 |
-
<p class="question">Chondi, will you give me the
|
| 367 |
<p class="hearts-deco">β‘ β‘ β‘</p>
|
| 368 |
<p class="card-sub">No pressure... but also, just a little. πΈ</p>
|
| 369 |
</div>
|
|
@@ -374,8 +375,7 @@ 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
|
| 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) */
|
|
@@ -384,7 +384,7 @@ div[data-testid="column"]:nth-of-type(2) button {{
|
|
| 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)
|
| 388 |
div[data-testid="column"]:nth-of-type(1) button {{
|
| 389 |
animation: pulseBtn 2s infinite;
|
| 390 |
}}
|
|
@@ -397,7 +397,6 @@ div[data-testid="column"]:nth-of-type(1) button {{
|
|
| 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:
|
|
@@ -410,13 +409,14 @@ with c2:
|
|
| 410 |
st.session_state.showing_no = True
|
| 411 |
st.rerun()
|
| 412 |
|
| 413 |
-
# Guilt Trip Text
|
|
|
|
| 414 |
no_messages = [
|
| 415 |
"Are you sure? π₯Ί", "Please reconsider... π",
|
| 416 |
"My heart is shattering...", "I'll wait forever πΈ",
|
| 417 |
"Pretty please? π", "This wasn't supposed to happen π’",
|
| 418 |
-
"One more chance? π", "Your finger slipped, right? π",
|
| 419 |
]
|
| 420 |
if st.session_state.no_index > 0:
|
|
|
|
| 421 |
idx = (st.session_state.no_index - 1) % len(no_messages)
|
| 422 |
st.markdown(f"<p class='no-msg'>{no_messages[idx]}</p>", unsafe_allow_html=True)
|
|
|
|
| 91 |
border: none;
|
| 92 |
border-radius: 50px;
|
| 93 |
font-family: 'Lato', sans-serif;
|
| 94 |
+
font-size: 16px;
|
| 95 |
font-weight: 700;
|
| 96 |
letter-spacing: 1.5px;
|
| 97 |
text-transform: uppercase;
|
| 98 |
+
padding: 16px 32px;
|
| 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%;
|
| 102 |
}
|
| 103 |
div[data-testid="stButton"] > button:active {
|
| 104 |
transform: scale(0.96);
|
|
|
|
| 304 |
st.stop()
|
| 305 |
|
| 306 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 307 |
+
# NO OVERLAY (Strictly Paired Logic)
|
| 308 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 309 |
if st.session_state.showing_no:
|
| 310 |
+
# 1. Define strict pairs so they never desync
|
| 311 |
+
# Format: (Image_Name, Text_Message)
|
| 312 |
+
pairs = [
|
| 313 |
+
("no1", "Why though... π₯Ί"), # 1st Click (Index 0)
|
| 314 |
+
("no2", "Really? π"), # 2nd Click (Index 1)
|
| 315 |
+
("no3", "My poor heart... π"), # 3rd Click (Index 2)
|
| 316 |
+
]
|
| 317 |
|
| 318 |
+
# 2. Calculate Index
|
| 319 |
+
# If index is 3, modulo 3 = 0 (Back to start).
|
| 320 |
+
# If index is 50, modulo 3 = 2 (Correctly shows 3rd pair).
|
| 321 |
+
idx = st.session_state.no_index % len(pairs)
|
| 322 |
+
stem, t = pairs[idx]
|
| 323 |
+
|
| 324 |
+
# 3. Load Image
|
| 325 |
+
b64, mime = img_to_b64(stem)
|
| 326 |
img_tag = f'<img src="data:{mime};base64,{b64}"/>' if b64 \
|
| 327 |
else '<div style="font-size:72px;margin-bottom:4px">π’</div>'
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
+
# 4. Show Overlay
|
| 330 |
st.markdown(f"""
|
| 331 |
<div class="overlay">
|
| 332 |
{img_tag}
|
|
|
|
| 334 |
<p class="overlay-sub">I'm not letting you leave until you say Yes. π€<br>(Tap the X to try again)</p>
|
| 335 |
</div>
|
| 336 |
<style>
|
| 337 |
+
/* X Button Styling */
|
| 338 |
div[data-testid="stButton"] button {{
|
| 339 |
+
position: fixed !important; top: 24px !important; right: 24px !important;
|
| 340 |
+
z-index: 2005 !important; background: rgba(0,0,0,0.5) !important;
|
| 341 |
+
color: rgba(255,255,255,0.8) !important; border: 1px solid rgba(255,255,255,0.3) !important;
|
| 342 |
+
border-radius: 50% !important; width: 44px !important; height: 44px !important;
|
| 343 |
+
padding: 0 !important; font-size: 20px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
display: flex !important; align-items: center !important; justify-content: center !important;
|
| 345 |
}}
|
| 346 |
div[data-testid="stButton"] button:hover {{
|
| 347 |
+
background: rgba(255,20,147,0.8) !important; border-color: #ff69b4 !important; color: white !important;
|
|
|
|
|
|
|
| 348 |
}}
|
| 349 |
</style>
|
| 350 |
""", unsafe_allow_html=True)
|
| 351 |
|
| 352 |
if st.button("β", key="close_overlay_btn"):
|
| 353 |
st.session_state.showing_no = False
|
| 354 |
+
st.session_state.no_index += 1 # Increment Counter
|
| 355 |
st.rerun()
|
| 356 |
|
| 357 |
st.stop()
|
|
|
|
| 364 |
<span class="rose">πΉ</span>
|
| 365 |
<p class="eyebrow">A Special Request</p>
|
| 366 |
<div class="deco"></div>
|
| 367 |
+
<p class="question">Chondi, will you give me the hounour of being your<br><em>platonic Valentine</em><br>this year?</p>
|
| 368 |
<p class="hearts-deco">β‘ β‘ β‘</p>
|
| 369 |
<p class="card-sub">No pressure... but also, just a little. πΈ</p>
|
| 370 |
</div>
|
|
|
|
| 375 |
# Start at 100%, shrink by 15% each time, don't go below 20%
|
| 376 |
scale_factor = max(0.2, 1.0 - (click_count * 0.15))
|
| 377 |
|
| 378 |
+
# CSS: Target NO button (2nd col) and YES button (1st col)
|
|
|
|
| 379 |
st.markdown(f"""
|
| 380 |
<style>
|
| 381 |
/* Target the Second Column (NO Button) */
|
|
|
|
| 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) */
|
| 388 |
div[data-testid="column"]:nth-of-type(1) button {{
|
| 389 |
animation: pulseBtn 2s infinite;
|
| 390 |
}}
|
|
|
|
| 397 |
""", unsafe_allow_html=True)
|
| 398 |
|
| 399 |
# ββ Buttons ββ
|
|
|
|
| 400 |
c1, c2 = st.columns(2)
|
| 401 |
|
| 402 |
with c1:
|
|
|
|
| 409 |
st.session_state.showing_no = True
|
| 410 |
st.rerun()
|
| 411 |
|
| 412 |
+
# Guilt Trip Text (Synced Logic)
|
| 413 |
+
# Define same messages for bottom text (can be different or same, but cycled safely)
|
| 414 |
no_messages = [
|
| 415 |
"Are you sure? π₯Ί", "Please reconsider... π",
|
| 416 |
"My heart is shattering...", "I'll wait forever πΈ",
|
| 417 |
"Pretty please? π", "This wasn't supposed to happen π’",
|
|
|
|
| 418 |
]
|
| 419 |
if st.session_state.no_index > 0:
|
| 420 |
+
# Use modulo length of messages to ensure it never breaks
|
| 421 |
idx = (st.session_state.no_index - 1) % len(no_messages)
|
| 422 |
st.markdown(f"<p class='no-msg'>{no_messages[idx]}</p>", unsafe_allow_html=True)
|