code-slicer commited on
Commit
90b496c
·
verified ·
1 Parent(s): 8143a69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -190,13 +190,36 @@ st.markdown(
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
- st.sidebar.text_input("배경 이미지 URL", key="bg_url", value="https://images.unsplash.com/photo-1506744038136-46273834b3fb")
197
- st.sidebar.slider("배경 이미지 오버레이 (%)", 0, 100, 85, key="bg_overlay_pct")
198
- st.sidebar.color_picker("단색 배경 색상", key="bg_color", value="#F1F1F1", "E3E8E3", "D9E1E2", "F0F0EC")
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
  def apply_background():
202
  # 보호: 기존 ::before 배경이 있으면 끄기 (겹침/끊김 방지)
@@ -218,22 +241,21 @@ def apply_background():
218
  <style>
219
  /* 상단·배경 투명 처리 */
220
  header[data-testid="stHeader"],
221
- [data-testid="stAppViewContainer"],
222
  main, section.main {{ background: transparent !important; }}
223
 
224
  [data-testid="stAppViewContainer"] {{
225
  background: url('{url}') center / cover no-repeat fixed;
226
- position: relative; /* 오버레이의 기준점이 되도록 설정 */
227
- z-index: 0; /* 컨텐츠가 위에 오도록 */
228
  }}
229
 
230
  /* 오버레이: 이미지 위에 흰색 막을 얹어 가독성 확보 */
231
  [data-testid="stAppViewContainer"]::after {{
232
  content: "";
233
- position: absolute; /* 부모(stAppViewContainer)를 기준으로 위치 */
234
  inset: 0;
235
  background: rgba(255, 255, 255, {overlay_alpha});
236
- z-index: -1; /* 배경 이미지 바로 위에 오도록 */
237
  pointer-events: none;
238
  }}
239
 
 
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
+ # st.expander를 사용해 UI를 깔끔하게 정리
198
+ with st.sidebar.expander("이미지 배경 옵션", expanded=True):
199
+ st.text_input("배경 이미지 URL", key="bg_url", value="https://images.unsplash.com/photo-1506744038136-46273834b3fb")
200
+ st.slider("배경 이미지 오버레이 (%)", 0, 100, 85, key="bg_overlay_pct")
201
+
202
+ with st.sidebar.expander("단색 배경 옵션", expanded=True):
203
+ # 라디오 버튼으로 추천 색상 팔레트 제공
204
+ palette = {
205
+ "Light Gray": "#F1F1F1",
206
+ "Mint": "#E3E8E3",
207
+ "Sky Blue": "#D9E1E2",
208
+ "Beige": "#F0F0EC"
209
+ }
210
+ selected_color_name = st.radio(
211
+ "추천 색상",
212
+ options=palette.keys(),
213
+ key="selected_color_name",
214
+ horizontal=True # 버튼을 가로로 배열
215
+ )
216
+
217
+ # 선택된 라디오 버튼의 색상 코드를 color_picker의 기본값으로 사용
218
+ st.color_picker(
219
+ "색상 직접 선택",
220
+ key="bg_color",
221
+ value=palette[selected_color_name]
222
+ )
223
 
224
  def apply_background():
225
  # 보호: 기존 ::before 배경이 있으면 끄기 (겹침/끊김 방지)
 
241
  <style>
242
  /* 상단·배경 투명 처리 */
243
  header[data-testid="stHeader"],
 
244
  main, section.main {{ background: transparent !important; }}
245
 
246
  [data-testid="stAppViewContainer"] {{
247
  background: url('{url}') center / cover no-repeat fixed;
248
+ position: relative;
249
+ z-index: 0;
250
  }}
251
 
252
  /* 오버레이: 이미지 위에 흰색 막을 얹어 가독성 확보 */
253
  [data-testid="stAppViewContainer"]::after {{
254
  content: "";
255
+ position: absolute;
256
  inset: 0;
257
  background: rgba(255, 255, 255, {overlay_alpha});
258
+ z-index: -1;
259
  pointer-events: none;
260
  }}
261