vsj0702 commited on
Commit
3934d18
·
verified ·
1 Parent(s): f66144d

Fixing bug

Browse files
Files changed (1) hide show
  1. layout.py +92 -101
layout.py CHANGED
@@ -1,111 +1,102 @@
1
  import streamlit as st
2
 
3
  def init_session_state():
4
- st.session_state.setdefault("code", "")
5
- st.session_state.setdefault("stdin", "")
6
- st.session_state.setdefault("theme", "light")
 
 
 
7
 
8
- def apply_theme(theme):
9
- import streamlit as st
10
 
11
- LIGHT = {
12
- "bg": "#f5f5f5",
13
- "panel": "#ffffff",
14
- "text": "#1a1a1a",
15
- "border": "#dddddd",
16
- "button": "#ff5252",
17
- "button_text": "#ffffff",
18
- "placeholder": "#888888"
19
- }
20
- DARK = {
21
- "bg": "#0f1620",
22
- "panel": "#1c2330",
23
- "text": "#e3e8f1",
24
- "border": "#2a3240",
25
- "button": "#ff5252",
26
- "button_text": "#ffffff",
27
- "placeholder": "#999999"
28
- }
29
-
30
- colors = DARK if theme == "dark" else LIGHT
31
-
32
- st.markdown(f"""
33
- <style>
34
- /* Background & global text */
35
- .stApp {{
36
- background-color: {colors["bg"]};
37
- color: {colors["text"]};
38
- }}
39
-
40
- /* Sidebar */
41
- [data-testid="stSidebar"] {{
42
- background-color: {colors["panel"]} !important;
43
- }}
44
 
45
- /* Form elements */
46
- textarea, input[type="text"], .stTextArea textarea {{
47
- background-color: {colors["panel"]} !important;
48
- color: {colors["text"]} !important;
49
- border: 1px solid {colors["border"]} !important;
50
- border-radius: 4px !important;
51
- }}
52
 
53
- /* Placeholder styling */
54
- textarea::placeholder,
55
- input::placeholder {{
56
- color: {colors["placeholder"]} !important;
57
- }}
58
 
59
- /* Markdown label text */
60
- label[data-testid="stMarkdownContainer"] > div > div {{
61
- color: {colors["text"]} !important;
62
- }}
63
-
64
- /* Button */
65
- button, .stButton > button, .stDownloadButton > button {{
66
- background-color: {colors["button"]} !important;
67
- color: {colors["button_text"]} !important;
68
- border-radius: 6px !important;
69
- border: none !important;
70
- transition: transform 0.1s;
71
- }}
72
- button:hover {{
73
- transform: scale(1.02) !important;
74
- }}
75
-
76
- /* Radio buttons */
77
- .stRadio > label {{
78
- color: {colors["text"]} !important;
79
- }}
80
 
81
- /* Assistant styles */
82
- .chat-container {{
83
- background: {colors["panel"]} !important;
84
- border: 1px solid {colors["border"]} !important;
85
- border-radius: 8px !important;
86
- padding: 1rem;
87
- max-height: 480px;
88
- overflow-y: auto;
89
- }}
90
- .chat-message {{
91
- margin-bottom: 1rem;
92
- padding: 0.75rem 1rem;
93
- border-radius: 12px;
94
- }}
95
- .user-message {{
96
- background: rgba(100,149,237,0.2);
97
- align-self: flex-end;
98
- }}
99
- .bot-message {{
100
- background: rgba(200,200,200,0.2);
101
- align-self: flex-start;
102
- }}
103
- pre code {{
104
- display: block;
105
- padding: 0.5rem;
106
- background: rgba(0,0,0,0.1);
107
- border-radius: 4px;
108
- overflow-x: auto;
109
- }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  </style>
111
- """, unsafe_allow_html=True)
 
 
 
 
 
1
  import streamlit as st
2
 
3
  def init_session_state():
4
+ if "dark_mode" not in st.session_state:
5
+ st.session_state.dark_mode = False
6
+ if "code" not in st.session_state:
7
+ st.session_state.code = ""
8
+ if "stdin" not in st.session_state:
9
+ st.session_state.stdin = ""
10
 
 
 
11
 
12
+ def theme_toggle():
13
+ theme_choice = st.radio(
14
+ "🎨 Theme",
15
+ options=["☀️", "🌙"],
16
+ horizontal=True,
17
+ label_visibility="collapsed"
18
+ )
19
+ st.session_state.dark_mode = (theme_choice == "🌙")
20
+ return st.session_state.dark_mode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
 
 
 
 
 
 
22
 
23
+ def apply_theme():
24
+ dm = st.session_state.dark_mode
 
 
 
25
 
26
+ colors = {
27
+ "bg": "#0f1620" if dm else "#f5f5f5",
28
+ "panel_bg": "#1c2330" if dm else "#ffffff",
29
+ "text": "#e3e8f1" if dm else "#1a1a1a",
30
+ "accent": "#ff5252",
31
+ "border": "#2a3240" if dm else "#dddddd",
32
+ "shadow": "rgba(0,0,0,0.3)" if dm else "rgba(0,0,0,0.1)",
33
+ "ace_theme": "monokai" if dm else "chrome",
34
+ }
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ st.markdown(
37
+ f"""
38
+ <style>
39
+ .stApp {{
40
+ background-color: {colors["bg"]};
41
+ color: {colors["text"]};
42
+ }}
43
+ [data-testid="stSidebar"] {{
44
+ background-color: {colors["panel_bg"]} !important;
45
+ }}
46
+ .ace_editor, .ace_scroller {{
47
+ background: {colors["panel_bg"]} !important;
48
+ box-shadow: 0 4px 8px {colors["shadow"]} !important;
49
+ border-radius: 8px !important;
50
+ }}
51
+ textarea, input, .stTextArea textarea {{
52
+ background: {colors["panel_bg"]} !important;
53
+ color: {colors["text"]} !important;
54
+ border: 1px solid {colors["border"]} !important;
55
+ border-radius: 4px !important;
56
+ }}
57
+ label, .stTextLabel, .stTextArea label {{
58
+ color: {colors["text"]} !important;
59
+ }}
60
+ button, .stDownloadButton > button {{
61
+ background-color: {colors["accent"]} !important;
62
+ color: #fff !important;
63
+ border-radius: 6px !important;
64
+ transition: transform 0.1s;
65
+ }}
66
+ button:hover {{
67
+ transform: scale(1.02) !important;
68
+ }}
69
+ .chat-container {{
70
+ background: {colors["panel_bg"]} !important;
71
+ border: 1px solid {colors["border"]} !important;
72
+ border-radius: 8px !important;
73
+ padding: 1rem;
74
+ max-height: 480px;
75
+ overflow-y: auto;
76
+ }}
77
+ .chat-message {{
78
+ margin-bottom: 1rem;
79
+ padding: 0.75rem 1rem;
80
+ border-radius: 12px;
81
+ }}
82
+ .user-message {{
83
+ background: rgba(100,149,237,0.2);
84
+ align-self: flex-end;
85
+ }}
86
+ .bot-message {{
87
+ background: rgba(200,200,200,0.2);
88
+ align-self: flex-start;
89
+ }}
90
+ pre code {{
91
+ display: block;
92
+ padding: 0.5rem;
93
+ background: rgba(0,0,0,0.1);
94
+ border-radius: 4px;
95
+ overflow-x: auto;
96
+ }}
97
  </style>
98
+ """,
99
+ unsafe_allow_html=True,
100
+ )
101
+
102
+ return colors