vsj0702 commited on
Commit
1a353ec
·
verified ·
1 Parent(s): b966d8e

adding dark mode

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -2,24 +2,20 @@ import streamlit as st
2
  import streamlit_ace as st_ace
3
  from utils import execute_code
4
  from chatbot import render_chatbot
5
- from styles import get_theme_colors, inject_global_css
6
- from layout import init_session_state
7
 
8
- # Page configuration
9
  st.set_page_config(page_title="Pro Code Playground", page_icon="💻", layout="wide")
10
 
11
- # Session init
12
  init_session_state()
13
 
14
- # Dark mode toggle
15
- dm = st.checkbox("🌙 Dark mode", value=st.session_state.dark_mode)
16
- st.session_state.dark_mode = dm
 
17
 
18
- # Theme + CSS injection
19
- colors = get_theme_colors(dm)
20
- inject_global_css(colors)
21
-
22
- # Header
23
  st.title("Pro Code Playground")
24
  st.markdown("Write, execute & export Python snippets, with built‑in AI assistance.")
25
 
@@ -28,12 +24,12 @@ gen, bot = st.columns((2, 1), gap="large")
28
 
29
  with gen:
30
  st.subheader("Editor")
31
-
32
  code = st_ace.st_ace(
33
  value=st.session_state.code,
34
  placeholder="Start typing your Python code…",
35
  language="python",
36
- theme=colors["ACE_THEME"],
37
  keybinding="vscode",
38
  font_size=14,
39
  min_lines=20,
@@ -75,8 +71,8 @@ with bot:
75
  )
76
 
77
  # Footer
78
- st.markdown(f"""
79
- <div style='text-align:center; margin-top:1rem; color:{colors["TEXT"]}66;'>
80
  Built with ❤️ & Streamlit by Vaibhav
81
  </div>
82
  """, unsafe_allow_html=True)
 
2
  import streamlit_ace as st_ace
3
  from utils import execute_code
4
  from chatbot import render_chatbot
5
+ from layout import init_session_state, apply_theme
 
6
 
7
+ # Set initial page config
8
  st.set_page_config(page_title="Pro Code Playground", page_icon="💻", layout="wide")
9
 
10
+ # Init session
11
  init_session_state()
12
 
13
+ # Theme Toggle
14
+ theme_option = st.radio("🎨 Theme", options=["Light", "Dark"], index=0 if st.session_state.theme == "light" else 1, horizontal=True)
15
+ st.session_state.theme = "light" if theme_option == "Light" else "dark"
16
+ apply_theme(st.session_state.theme)
17
 
18
+ # App Header
 
 
 
 
19
  st.title("Pro Code Playground")
20
  st.markdown("Write, execute & export Python snippets, with built‑in AI assistance.")
21
 
 
24
 
25
  with gen:
26
  st.subheader("Editor")
27
+
28
  code = st_ace.st_ace(
29
  value=st.session_state.code,
30
  placeholder="Start typing your Python code…",
31
  language="python",
32
+ theme="chrome" if st.session_state.theme == "light" else "monokai",
33
  keybinding="vscode",
34
  font_size=14,
35
  min_lines=20,
 
71
  )
72
 
73
  # Footer
74
+ st.markdown("""
75
+ <div style='text-align:center; margin-top:1rem; opacity:0.6;'>
76
  Built with ❤️ & Streamlit by Vaibhav
77
  </div>
78
  """, unsafe_allow_html=True)