code-slicer commited on
Commit
2a0f7e9
Β·
verified Β·
1 Parent(s): 314d8fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -46
app.py CHANGED
@@ -188,60 +188,53 @@ st.markdown(
188
  )
189
 
190
  # κ³ μ • 이미지 URL
191
- BG_URL = "https://plus.unsplash.com/premium_photo-1679830513869-cd3648acb1db?q=80&w=2127&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
192
 
193
- # === λ°°κ²½ μ„€μ • UI ===
194
- st.sidebar.subheader("🎨 λ°°κ²½ μ„€μ •")
195
- st.sidebar.toggle("λ°°κ²½ 이미지 μ‚¬μš©", key="bg_on", value=True)
196
 
197
  def apply_background():
198
- # 보호: κΈ°μ‘΄ ::before 배경이 있으면 끄기 (κ²ΉμΉ¨/λŠκΉ€ λ°©μ§€)
199
- base_reset_css = """
200
  <style>
201
- .stApp::before, .block-container::before{ content:none !important; }
202
- /* 컨텐츠/μ‚¬μ΄λ“œλ°”λŠ” λ°°κ²½ λ ˆμ΄μ–΄ μœ„μ— μ˜€λ„λ‘ */
203
- .block-container, [data-testid="stSidebar"]{ position:relative; z-index:1; }
204
- /* μž…λ ₯λ°•μŠ€ μ•„λž˜ μ—¬λ°± (μš”μ²­ 2번) */
205
- div[data-testid="stTextInput"]{ margin-bottom:18px !important; }
 
 
 
 
 
 
 
 
 
 
 
 
206
  </style>
207
- """
208
- st.markdown(base_reset_css, unsafe_allow_html=True)
209
-
210
- if st.session_state.get("bg_on") and st.session_state.get("bg_url"):
211
- url = st.session_state["bg_url"]
212
- # 0~1 둜 λ³€ν™˜ (흰 μ˜€λ²„λ ˆμ΄λ‘œ 밝기/가독성 쑰절)
213
- overlay_alpha = float(st.session_state.get("bg_overlay_pct", 15)) / 100.0
214
-
215
- # βœ… 이미지 λ°°κ²½ (λŠκΉ€ λ°©μ§€: νŽ˜μ΄μ§€ 전체 .stApp에 κ³ μ • λ°°κ²½)
216
- st.markdown(f"""
217
- <style>
218
- .stApp{{
219
- background: url('{url}') center / cover no-repeat fixed;
220
- }}
221
- /* μ˜€λ²„λ ˆμ΄: 이미지 μœ„μ— 흰색 막을 μ–Ήμ–΄ 가독성 확보 (투λͺ…도 쑰절 κ°€λŠ₯) */
222
- .stApp::after{{
223
- content:""; position:fixed; inset:0; z-index:0; pointer-events:none;
224
- background: rgba(255,255,255,{overlay_alpha});
225
- }}
226
- /* λͺ¨λ°”일은 fixed μ΄μŠˆκ°€ μžˆμ–΄ κ³ μ • ν•΄μ œ */
227
- @media (max-width:768px){{
228
- .stApp{{ background-attachment: initial; }}
229
- }}
230
- </style>
231
- """, unsafe_allow_html=True)
232
 
233
- else:
234
- # βœ… 단색 λ°°κ²½ (λŠκΉ€ μ—†μŒ: μš”μ†Œ 자체의 background-color μ‚¬μš©)
235
- color = st.session_state.get("bg_color", "#F1F1F1")
236
- st.markdown(f"""
237
- <style>
238
- .stApp{{ background-color: {color} !important; }}
239
- </style>
240
- """, unsafe_allow_html=True)
241
-
242
- # 호좜
243
  apply_background()
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  # ───────────────────────────────────── region mode
246
  def region_ui(travel_df, external_score_df, festival_df, weather_df, package_df,
247
  country_filter, city_filter, chat_container, log_and_render):
 
188
  )
189
 
190
  # κ³ μ • 이미지 URL
191
+ #BG_URL = "https://plus.unsplash.com/premium_photo-1679830513869-cd3648acb1db?q=80&w=2127&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
192
 
193
+ COLOR = "#F1F1F1" # ν•„μš”ν•˜λ©΄ μ›ν•˜λŠ” HEX둜 λ³€κ²½
194
+ # COLOR = st.sidebar.color_picker("배경색", "#F1F1F1") # <- μ‚¬μ΄λ“œλ°”μ—μ„œ κ³ λ₯΄κ³  μ‹ΆμœΌλ©΄ 이 쀄 μ‚¬μš©
 
195
 
196
  def apply_background():
197
+ st.markdown(f"""
 
198
  <style>
199
+ /* μž”μ—¬ λ°°κ²½ λ ˆμ΄μ–΄ 제거 */
200
+ .stApp::before, .stApp::after,
201
+ .block-container::before, .block-container::after {{ content: none !important; }}
202
+ .stApp {{ background: transparent !important; }}
203
+
204
+ /* 쀑앙 μ»¬λŸΌμ—λ§Œ 단색 λ°°κ²½ */
205
+ .block-container {{
206
+ position: relative;
207
+ min-height: 100vh; /* ν™”λ©΄ λ†’μ΄λ§ŒνΌ μ±„μš°κΈ° */
208
+ background: {COLOR} !important; /* 단색 */
209
+ }}
210
+
211
+ /* μ»¨ν…μΈ λŠ” λ°°κ²½ μœ„ */
212
+ .block-container > * {{ position: relative; z-index: 1; }}
213
+
214
+ /* (μ˜΅μ…˜) μž…λ ₯λ°•μŠ€ μ•„λž˜ μ—¬λ°± μœ μ§€ */
215
+ div[data-testid="stTextInput"] {{ margin-bottom: 18px !important; }}
216
  </style>
217
+ """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
 
 
 
 
 
 
 
 
 
 
219
  apply_background()
220
 
221
+ # ── P κΈ€κΌ΄ 크기 14 px ───────────────────────────────────
222
+ st.markdown("""
223
+ <style>
224
+ /* κΈ°λ³Έ p νƒœκ·Έ κΈ€κΌ΄ 크기 */
225
+ html, body, p {
226
+ font-size: 14px !important; /* ← 14 px κ³ μ • */
227
+ line-height: 1.5; /* (선택) 가독성을 μœ„ν•œ 쀄간격 */
228
+ }
229
+
230
+ /* Streamlit κΈ°λ³Έ λ§ˆμ§„ 제거둜 λΆˆν•„μš”ν•œ μ—¬λ°± λ°©μ§€ (선택) */
231
+ p {
232
+ margin-top: 0;
233
+ margin-bottom: 0.5rem;
234
+ }
235
+ </style>
236
+ """, unsafe_allow_html=True)
237
+
238
  # ───────────────────────────────────── region mode
239
  def region_ui(travel_df, external_score_df, festival_df, weather_df, package_df,
240
  country_filter, city_filter, chat_container, log_and_render):