deadshot2003 commited on
Commit
b2f1e8a
Β·
verified Β·
1 Parent(s): 021f415

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +65 -31
src/streamlit_app.py CHANGED
@@ -84,7 +84,7 @@ header, footer, #MainMenu, .stDeployButton,
84
  .card-sub { font-family:'Lato',sans-serif; font-size:12px;
85
  color:rgba(255,182,193,.4); line-height:1.6; }
86
 
87
- /* ── BUTTONS (General) ── */
88
  .btn-row {
89
  position: relative; z-index: 10;
90
  display: flex;
@@ -100,16 +100,15 @@ div[data-testid="stButton"] > button {
100
  border: none;
101
  border-radius: 50px;
102
  font-family: 'Lato', sans-serif;
103
- font-size: 12px;
104
  font-weight: 700;
105
  letter-spacing: 1.3px;
106
  text-transform: uppercase;
107
- padding: 11px 26px;
108
  box-shadow: 0 4px 18px rgba(255,20,147,0.38);
109
- transition: all 0.2s ease;
110
  width: auto;
111
- min-width: 100px;
112
- max-width: 160px;
113
  }
114
  div[data-testid="stButton"] > button:active {
115
  transform: scale(0.96);
@@ -118,7 +117,7 @@ div[data-testid="stButton"] > button:active {
118
  /* ── OVERLAY (No image + Yes image) ── */
119
  .overlay {
120
  position: fixed; top:0; left:0; width:100vw; height:100vh;
121
- background: rgba(0,0,0,0.88);
122
  backdrop-filter: blur(12px);
123
  z-index: 2000;
124
  display: flex; flex-direction: column;
@@ -129,24 +128,26 @@ div[data-testid="stButton"] > button:active {
129
  @keyframes fadeIn { from{opacity:0} to{opacity:1} }
130
 
131
  .overlay img {
132
- max-width: 280px; width: 82%;
133
  border-radius: 18px;
134
  border: 1px solid rgba(255,105,180,0.2);
135
  box-shadow: 0 0 50px rgba(255,20,147,0.18), 0 16px 40px rgba(0,0,0,0.5);
136
  animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
 
137
  }
138
  @keyframes popIn { from{transform:scale(0.75);opacity:0} to{transform:scale(1);opacity:1} }
139
 
140
  .overlay-title {
141
  font-family: 'Playfair Display', serif;
142
- font-size: 22px; color: #ff69b4;
143
  font-style: italic; text-align: center;
 
144
  }
145
  .overlay-title.white { color: #fff; font-style: normal; font-weight: 700; }
146
  .overlay-sub {
147
  font-family: 'Lato', sans-serif;
148
- font-size: 12px; color: rgba(255,182,193,0.45);
149
- text-align: center; line-height: 1.65;
150
  }
151
 
152
  /* ── NO MSG UNDER BUTTONS ── */
@@ -313,11 +314,10 @@ if st.session_state.show_yes:
313
  st.stop()
314
 
315
  # ══════════════════════════════════════════════════════════════════════════════
316
- # NO OVERLAY (Fixed for Mobile - "Go Back" Button)
317
  # ══════════════════════════════════════════════════════════════════════════════
318
  if st.session_state.showing_no:
319
  no_stems = ["no1", "no2", "no3"]
320
- # Logic to cycle images based on clicks
321
  idx = st.session_state.no_index % 3
322
 
323
  # Load Image
@@ -329,41 +329,51 @@ if st.session_state.showing_no:
329
  titles = ["Why though... πŸ₯Ί", "Really? πŸ’”", "My poor heart...", "Please reconsider πŸ™"]
330
  t = titles[st.session_state.no_index % 4]
331
 
332
- # Show Overlay
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>(Just kidding... press the button below)</p>
338
  </div>
339
 
340
  <style>
 
341
  div[data-testid="stButton"] > button {{
342
  position: fixed !important;
343
- bottom: 15% !important;
344
- left: 50% !important;
345
- transform: translateX(-50%) !important;
346
- z-index: 2001 !important; /* Higher than overlay (2000) */
347
- background: transparent !important;
348
- border: 2px solid rgba(255,105,180,0.5) !important;
349
- color: #ffb6c1 !important;
350
- box-shadow: none !important;
 
 
 
 
 
 
 
 
 
 
351
  }}
352
  div[data-testid="stButton"] > button:hover {{
353
- background: rgba(255,105,180,0.1) !important;
354
- border-color: #ff69b4 !important;
355
  color: #fff !important;
 
356
  }}
357
  </style>
358
  """, unsafe_allow_html=True)
359
 
360
- # The Button
361
- if st.button("Okay, I'll reconsider πŸ™„", key="go_back_btn"):
362
  st.session_state.showing_no = False
363
- st.session_state.no_index += 1 # Increment counter for next time
364
  st.rerun()
365
 
366
- # STOP here so main page doesn't load underneath
367
  st.stop()
368
 
369
  # ══════════════════════════════════════════════════════════════════════════════
@@ -380,9 +390,33 @@ st.markdown("""
380
  </div>
381
  """, unsafe_allow_html=True)
382
 
383
- # ── Two buttons, same row, centered ───────────────────────────────────────────
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  st.markdown("<div class='btn-row'>", unsafe_allow_html=True)
385
 
 
386
  _, c1, gap, c2, _ = st.columns([1, 2, 0.3, 2, 1])
387
 
388
  with c1:
@@ -397,7 +431,7 @@ with c2:
397
 
398
  st.markdown("</div>", unsafe_allow_html=True)
399
 
400
- # No message shown below buttons (Guilt Trip Text)
401
  no_messages = [
402
  "Are you sure? πŸ₯Ί", "Please reconsider... πŸ’”",
403
  "My heart is shattering...", "I'll wait forever 🌸",
 
84
  .card-sub { font-family:'Lato',sans-serif; font-size:12px;
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;
 
100
  border: none;
101
  border-radius: 50px;
102
  font-family: 'Lato', sans-serif;
103
+ font-size: 14px; /* Increased Base Size */
104
  font-weight: 700;
105
  letter-spacing: 1.3px;
106
  text-transform: uppercase;
107
+ padding: 14px 30px; /* Increased Base Padding */
108
  box-shadow: 0 4px 18px rgba(255,20,147,0.38);
109
+ transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy transition */
110
  width: auto;
111
+ min-width: 110px;
 
112
  }
113
  div[data-testid="stButton"] > button:active {
114
  transform: scale(0.96);
 
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); /* Darker for better contrast */
121
  backdrop-filter: blur(12px);
122
  z-index: 2000;
123
  display: flex; flex-direction: column;
 
128
  @keyframes fadeIn { from{opacity:0} to{opacity:1} }
129
 
130
  .overlay img {
131
+ max-width: 280px; width: 85%;
132
  border-radius: 18px;
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; /* Shift up slightly */
137
  }
138
  @keyframes popIn { from{transform:scale(0.75);opacity:0} to{transform:scale(1);opacity:1} }
139
 
140
  .overlay-title {
141
  font-family: 'Playfair Display', serif;
142
+ font-size: 24px; color: #ff69b4;
143
  font-style: italic; text-align: center;
144
+ margin-top: 10px;
145
  }
146
  .overlay-title.white { color: #fff; font-style: normal; font-weight: 700; }
147
  .overlay-sub {
148
  font-family: 'Lato', sans-serif;
149
+ font-size: 13px; color: rgba(255,182,193,0.6);
150
+ text-align: center; line-height: 1.6;
151
  }
152
 
153
  /* ── NO MSG UNDER BUTTONS ── */
 
314
  st.stop()
315
 
316
  # ══════════════════════════════════════════════════════════════════════════════
317
+ # NO OVERLAY (Fixed: X Button Top Right)
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
 
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
+ /* Target the ONLY button visible in this state */
342
  div[data-testid="stButton"] > button {{
343
  position: fixed !important;
344
+ top: 20px !important;
345
+ right: 20px !important;
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: 40px !important;
353
+ height: 40px !important;
354
+ min-width: 0 !important;
355
+ padding: 0 !important;
356
+
357
+ font-size: 18px !important;
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"] > button:hover {{
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 counter to shrink next time
375
  st.rerun()
376
 
 
377
  st.stop()
378
 
379
  # ══════════════════════════════════════════════════════════════════════════════
 
390
  </div>
391
  """, unsafe_allow_html=True)
392
 
393
+ # ── Dynamic Button Sizing Logic ──
394
+ # Calculate scale based on how many times "No" has been clicked
395
+ click_count = st.session_state.no_index
396
+ # Shrinks by 15% per click, stops at 40% size
397
+ scale_factor = max(0.4, 1.0 - (click_count * 0.15))
398
+
399
+ # Inject specific CSS for the No button (Column 4)
400
+ st.markdown(f"""
401
+ <style>
402
+ /* 4th child in the column layout is the 'No' button wrapper */
403
+ div[data-testid="column"]:nth-of-type(4) div[data-testid="stButton"] button {{
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); /* Elastic ease */
407
+ }}
408
+ /* Make 'Yes' button slightly larger to encourage clicking */
409
+ div[data-testid="column"]:nth-of-type(2) div[data-testid="stButton"] button {{
410
+ transform: scale(1.1);
411
+ transform-origin: center center;
412
+ }}
413
+ </style>
414
+ """, unsafe_allow_html=True)
415
+
416
+ # ── Buttons ──
417
  st.markdown("<div class='btn-row'>", unsafe_allow_html=True)
418
 
419
+ # Columns: [spacer, Yes, gap, No, spacer]
420
  _, c1, gap, c2, _ = st.columns([1, 2, 0.3, 2, 1])
421
 
422
  with c1:
 
431
 
432
  st.markdown("</div>", unsafe_allow_html=True)
433
 
434
+ # Guilt Trip Text
435
  no_messages = [
436
  "Are you sure? πŸ₯Ί", "Please reconsider... πŸ’”",
437
  "My heart is shattering...", "I'll wait forever 🌸",