Update app.py
Browse files
app.py
CHANGED
@@ -389,6 +389,21 @@ st.markdown("""
|
|
389 |
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
390 |
transition: all 0.3s ease;
|
391 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
.stButton > button {
|
394 |
width: 100%;
|
@@ -534,6 +549,8 @@ st.markdown("""
|
|
534 |
|
535 |
# Initialize session state variables
|
536 |
def init_session_state():
|
|
|
|
|
537 |
if 'current_theme' not in st.session_state:
|
538 |
st.session_state.current_theme = None
|
539 |
if 'theme_story_starter' not in st.session_state:
|
@@ -1203,6 +1220,10 @@ def init_theme_state():
|
|
1203 |
|
1204 |
# Theme Selection UI
|
1205 |
def show_theme_selection():
|
|
|
|
|
|
|
|
|
1206 |
st.markdown("""
|
1207 |
<div class="theme-header">
|
1208 |
<h3>🎨 เลือกธีมเรื่องราว | Choose Story Theme</h3>
|
@@ -1216,8 +1237,8 @@ def show_theme_selection():
|
|
1216 |
# แสดงธีมในแต่ละ column
|
1217 |
for col, theme in zip(cols, available_themes):
|
1218 |
with col:
|
1219 |
-
# ใช้ ID
|
1220 |
-
button_key = f"
|
1221 |
|
1222 |
if st.button(
|
1223 |
f"{theme['icon']} {theme['name_th']}",
|
@@ -1236,7 +1257,15 @@ def show_theme_selection():
|
|
1236 |
|
1237 |
# คำอธิบายใต้ปุ่ม
|
1238 |
st.markdown(f"""
|
1239 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1240 |
{theme['description_th']}
|
1241 |
</div>
|
1242 |
""", unsafe_allow_html=True)
|
|
|
389 |
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
390 |
transition: all 0.3s ease;
|
391 |
}
|
392 |
+
|
393 |
+
/* Theme button styling */
|
394 |
+
.stButton button {
|
395 |
+
border-radius: 8px 8px 0 0 !important;
|
396 |
+
border-bottom: none !important;
|
397 |
+
margin-bottom: 0 !important;
|
398 |
+
}
|
399 |
+
|
400 |
+
.theme-card-description {
|
401 |
+
transition: all 0.3s ease;
|
402 |
+
}
|
403 |
+
|
404 |
+
.stButton button:hover + .theme-card-description {
|
405 |
+
transform: translateY(2px);
|
406 |
+
}
|
407 |
|
408 |
.stButton > button {
|
409 |
width: 100%;
|
|
|
549 |
|
550 |
# Initialize session state variables
|
551 |
def init_session_state():
|
552 |
+
if 'theme_selection_id' not in st.session_state:
|
553 |
+
st.session_state.theme_selection_id = datetime.now().strftime('%Y%m%d%H%M%S')
|
554 |
if 'current_theme' not in st.session_state:
|
555 |
st.session_state.current_theme = None
|
556 |
if 'theme_story_starter' not in st.session_state:
|
|
|
1220 |
|
1221 |
# Theme Selection UI
|
1222 |
def show_theme_selection():
|
1223 |
+
# สร้าง session key ถ้ายังไม่มี
|
1224 |
+
if 'theme_selection_id' not in st.session_state:
|
1225 |
+
st.session_state.theme_selection_id = datetime.now().strftime('%Y%m%d%H%M%S')
|
1226 |
+
|
1227 |
st.markdown("""
|
1228 |
<div class="theme-header">
|
1229 |
<h3>🎨 เลือกธีมเรื่องราว | Choose Story Theme</h3>
|
|
|
1237 |
# แสดงธีมในแต่ละ column
|
1238 |
for col, theme in zip(cols, available_themes):
|
1239 |
with col:
|
1240 |
+
# ใช้ session ID และ theme ID สร้าง unique key
|
1241 |
+
button_key = f"theme_{theme['id']}_{st.session_state.theme_selection_id}"
|
1242 |
|
1243 |
if st.button(
|
1244 |
f"{theme['icon']} {theme['name_th']}",
|
|
|
1257 |
|
1258 |
# คำอธิบายใต้ปุ่ม
|
1259 |
st.markdown(f"""
|
1260 |
+
<div class="theme-card-description"
|
1261 |
+
style="font-size: 0.85em;
|
1262 |
+
color: #666;
|
1263 |
+
padding: 5px;
|
1264 |
+
background-color: {theme['background_color']};
|
1265 |
+
border-radius: 0 0 8px 8px;
|
1266 |
+
border: 1px solid {theme['accent_color']};
|
1267 |
+
border-top: none;
|
1268 |
+
margin-top: -5px;">
|
1269 |
{theme['description_th']}
|
1270 |
</div>
|
1271 |
""", unsafe_allow_html=True)
|