Update app.py
Browse files
app.py
CHANGED
@@ -369,6 +369,7 @@ st.markdown("""
|
|
369 |
<style>
|
370 |
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;700&display=swap');
|
371 |
|
|
|
372 |
.thai-eng {
|
373 |
font-size: 1.1em;
|
374 |
padding: 10px;
|
@@ -397,6 +398,101 @@ st.markdown("""
|
|
397 |
margin: 15px 0;
|
398 |
border-left: 4px solid #ff9800;
|
399 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
</style>
|
401 |
""", unsafe_allow_html=True)
|
402 |
|
@@ -1928,39 +2024,53 @@ with st.sidebar:
|
|
1928 |
col1, col2 = st.columns([3, 1])
|
1929 |
|
1930 |
with col1:
|
1931 |
-
#
|
1932 |
st.markdown("""
|
1933 |
<div class="thai-eng">
|
1934 |
<div class="thai">📖 เรื่องราวของคุณ</div>
|
1935 |
<div class="eng">Your Story</div>
|
1936 |
</div>
|
1937 |
""", unsafe_allow_html=True)
|
1938 |
-
|
1939 |
-
# เรียกใช้ show_story() แทนโค้ดเดิม
|
1940 |
-
show_story()
|
1941 |
|
1942 |
-
#
|
1943 |
-
st.
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
# Submit button with callback
|
1959 |
-
st.button(
|
1960 |
-
"ส่งคำตอบ | Submit",
|
1961 |
-
on_click=submit_story
|
1962 |
-
)
|
1963 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1964 |
|
1965 |
with col2:
|
1966 |
# 1. Feedback Section (Most Important)
|
|
|
369 |
<style>
|
370 |
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;700&display=swap');
|
371 |
|
372 |
+
/* ส่วน CSS เดิม */
|
373 |
.thai-eng {
|
374 |
font-size: 1.1em;
|
375 |
padding: 10px;
|
|
|
398 |
margin: 15px 0;
|
399 |
border-left: 4px solid #ff9800;
|
400 |
}
|
401 |
+
|
402 |
+
/* เพิ่ม CSS สำหรับ Theme Cards */
|
403 |
+
.theme-header {
|
404 |
+
text-align: center;
|
405 |
+
margin-bottom: 20px;
|
406 |
+
}
|
407 |
+
|
408 |
+
.theme-header h3 {
|
409 |
+
color: #1e88e5;
|
410 |
+
font-family: 'Sarabun', sans-serif;
|
411 |
+
}
|
412 |
+
|
413 |
+
.theme-card {
|
414 |
+
position: relative;
|
415 |
+
overflow: hidden;
|
416 |
+
}
|
417 |
+
|
418 |
+
.theme-card:hover {
|
419 |
+
transform: translateY(-5px);
|
420 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
421 |
+
}
|
422 |
+
|
423 |
+
.theme-card:before {
|
424 |
+
content: '';
|
425 |
+
position: absolute;
|
426 |
+
top: 0;
|
427 |
+
left: 0;
|
428 |
+
width: 100%;
|
429 |
+
height: 100%;
|
430 |
+
background: linear-gradient(45deg, rgba(255,255,255,0.1), rgba(255,255,255,0.5));
|
431 |
+
opacity: 0;
|
432 |
+
transition: opacity 0.3s ease;
|
433 |
+
}
|
434 |
+
|
435 |
+
.theme-card:hover:before {
|
436 |
+
opacity: 1;
|
437 |
+
}
|
438 |
+
|
439 |
+
.theme-card.selected {
|
440 |
+
transform: scale(0.98);
|
441 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
442 |
+
}
|
443 |
+
|
444 |
+
/* CSS สำหรับปุ่ม Change Theme */
|
445 |
+
.stButton button {
|
446 |
+
padding: 0.5rem 1rem;
|
447 |
+
border-radius: 0.5rem;
|
448 |
+
border: 1px solid rgba(49, 51, 63, 0.2);
|
449 |
+
background-color: #ffffff;
|
450 |
+
color: #31333f;
|
451 |
+
transition: all 0.2s ease;
|
452 |
+
}
|
453 |
+
|
454 |
+
.stButton button:hover {
|
455 |
+
border-color: #1e88e5;
|
456 |
+
color: #1e88e5;
|
457 |
+
transform: translateY(-1px);
|
458 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
459 |
+
}
|
460 |
+
|
461 |
+
/* ปรับแต่ง tooltip */
|
462 |
+
.stTooltipIcon {
|
463 |
+
color: #1e88e5;
|
464 |
+
}
|
465 |
+
|
466 |
+
/* Responsive Design */
|
467 |
+
@media (max-width: 768px) {
|
468 |
+
.theme-card {
|
469 |
+
min-height: 120px;
|
470 |
+
}
|
471 |
+
|
472 |
+
.theme-card h4 {
|
473 |
+
font-size: 0.9em;
|
474 |
+
}
|
475 |
+
|
476 |
+
.theme-card p {
|
477 |
+
font-size: 0.8em;
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
/* Story Display Styling */
|
482 |
+
.story-message {
|
483 |
+
padding: 10px;
|
484 |
+
margin: 5px 0;
|
485 |
+
border-radius: 5px;
|
486 |
+
}
|
487 |
+
.story-message.ai {
|
488 |
+
background-color: #f0f7ff;
|
489 |
+
}
|
490 |
+
.story-message.user {
|
491 |
+
background-color: #fff;
|
492 |
+
}
|
493 |
+
.story-message.corrected {
|
494 |
+
background-color: #f0f9ff;
|
495 |
+
}
|
496 |
</style>
|
497 |
""", unsafe_allow_html=True)
|
498 |
|
|
|
2024 |
col1, col2 = st.columns([3, 1])
|
2025 |
|
2026 |
with col1:
|
2027 |
+
# แสดงส่วนบนของหน้า
|
2028 |
st.markdown("""
|
2029 |
<div class="thai-eng">
|
2030 |
<div class="thai">📖 เรื่องราวของคุณ</div>
|
2031 |
<div class="eng">Your Story</div>
|
2032 |
</div>
|
2033 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
2034 |
|
2035 |
+
# ตรวจสอบว่ามีธีมที่เลือกแล้วหรือไม่
|
2036 |
+
if not st.session_state.current_theme:
|
2037 |
+
# ถ้ายังไม่มีธีม แสดงส่วนเลือกธีม
|
2038 |
+
show_theme_selection()
|
2039 |
+
else:
|
2040 |
+
# ถ้ามีธีมแล้ว แสดงปุ่ม Change Theme
|
2041 |
+
if st.button("🔄 Change Theme", key="change_theme_button",
|
2042 |
+
help="คลิกเพื่อเปลี่ยนธีมเรื่องราว"):
|
2043 |
+
# รีเซ็ตค่าเมื่อต้องการเปลี่ยนธีม
|
2044 |
+
st.session_state.current_theme = None
|
2045 |
+
st.session_state.theme_story_starter = None
|
2046 |
+
st.session_state.story = []
|
2047 |
+
st.rerun()
|
2048 |
+
|
2049 |
+
# แสดงเนื้อเรื่อง
|
2050 |
+
show_story()
|
|
|
|
|
|
|
|
|
|
|
2051 |
|
2052 |
+
# User Input Box (แสดงเฉพาะเมื่อมีธีมแล้ว)
|
2053 |
+
if st.session_state.current_theme:
|
2054 |
+
st.markdown("""
|
2055 |
+
<div class="thai-eng">
|
2056 |
+
<div class="thai">✏️ ถึงตาคุณแล้ว</div>
|
2057 |
+
<div class="eng">Your Turn</div>
|
2058 |
+
</div>
|
2059 |
+
""", unsafe_allow_html=True)
|
2060 |
+
|
2061 |
+
# Text input with callback
|
2062 |
+
st.text_area(
|
2063 |
+
"เขียนต่อจากเรื่องราว | Continue the story:",
|
2064 |
+
height=100,
|
2065 |
+
key="text_input",
|
2066 |
+
label_visibility="collapsed"
|
2067 |
+
)
|
2068 |
+
|
2069 |
+
# Submit button with callback
|
2070 |
+
st.button(
|
2071 |
+
"ส่งคำตอบ | Submit",
|
2072 |
+
on_click=submit_story
|
2073 |
+
)
|
2074 |
|
2075 |
with col2:
|
2076 |
# 1. Feedback Section (Most Important)
|