Spaces:
Sleeping
Sleeping
Adding dark mode on entire application
Browse files
app.py
CHANGED
|
@@ -1,22 +1,76 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
# 1οΈβ£ PAGE CONFIG (MUST
|
| 5 |
st.set_page_config(
|
| 6 |
page_title="Interactive Code Editor with AI Assistant",
|
| 7 |
page_icon="π»",
|
| 8 |
layout="wide"
|
| 9 |
)
|
| 10 |
-
#
|
| 11 |
|
| 12 |
# 2οΈβ£ THEME SELECTOR
|
| 13 |
-
theme = st.sidebar.selectbox("π¨
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
from utils import execute_code, export_session
|
| 18 |
-
from chatbot import render_chatbot
|
| 19 |
-
import json
|
| 20 |
|
| 21 |
# Initialize session state
|
| 22 |
if 'code_output' not in st.session_state:
|
|
@@ -40,7 +94,7 @@ with col1:
|
|
| 40 |
code = st_ace.st_ace(
|
| 41 |
placeholder="Write your Python code here...",
|
| 42 |
language="python",
|
| 43 |
-
theme=ace_theme, # β use the selected theme
|
| 44 |
keybinding="vscode",
|
| 45 |
font_size=14,
|
| 46 |
min_lines=25,
|
|
@@ -99,6 +153,6 @@ with col2_export:
|
|
| 99 |
# Footer
|
| 100 |
st.markdown("""
|
| 101 |
<div style='text-align: center'>
|
| 102 |
-
<p>Built with Streamlit β€οΈ</p>
|
| 103 |
</div>
|
| 104 |
""", unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit_ace as st_ace
|
| 3 |
+
from utils import execute_code, export_session
|
| 4 |
+
from chatbot import render_chatbot
|
| 5 |
+
import json
|
| 6 |
|
| 7 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
+
# 1οΈβ£ PAGE CONFIG (MUST be the first Streamlit call)
|
| 9 |
st.set_page_config(
|
| 10 |
page_title="Interactive Code Editor with AI Assistant",
|
| 11 |
page_icon="π»",
|
| 12 |
layout="wide"
|
| 13 |
)
|
| 14 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 15 |
|
| 16 |
# 2οΈβ£ THEME SELECTOR
|
| 17 |
+
theme = st.sidebar.selectbox("π¨ App Theme", ["Light", "Dark"])
|
| 18 |
+
is_dark = (theme == "Dark")
|
| 19 |
+
|
| 20 |
+
# 3οΈβ£ MAP TO ACE EDITOR THEME
|
| 21 |
+
ace_theme = "monokai" if is_dark else "chrome"
|
| 22 |
+
|
| 23 |
+
# 4οΈβ£ DEFINE COLORS FOR GLOBAL CSS
|
| 24 |
+
bg_color = "#1e1e1e" if is_dark else "#ffffff"
|
| 25 |
+
text_color = "#e5e5e5" if is_dark else "#000000"
|
| 26 |
+
sidebar_bg = "#252526" if is_dark else "#f0f2f6"
|
| 27 |
+
button_bg = "#3a3d41" if is_dark else "#e7eaf0"
|
| 28 |
+
chat_bg = "#2e2e2e" if is_dark else "#f9f9f9"
|
| 29 |
+
border_color = "#444444" if is_dark else "#dddddd"
|
| 30 |
+
user_bg = "#3d5a80" if is_dark else "#e3f2fd"
|
| 31 |
+
bot_bg = "#555555" if is_dark else "#f5f5f5"
|
| 32 |
+
|
| 33 |
+
# 5οΈβ£ INJECT GLOBAL CSS
|
| 34 |
+
st.markdown(f"""
|
| 35 |
+
<style>
|
| 36 |
+
/* Main app background and text */
|
| 37 |
+
.stApp {{
|
| 38 |
+
background-color: {bg_color};
|
| 39 |
+
color: {text_color};
|
| 40 |
+
}}
|
| 41 |
+
/* Sidebar styling */
|
| 42 |
+
.css-1d391kg .css-1d391kg {{ /* wrapper class Streamlit uses for sidebar */
|
| 43 |
+
background-color: {sidebar_bg} !important;
|
| 44 |
+
color: {text_color};
|
| 45 |
+
}}
|
| 46 |
+
/* Buttons */
|
| 47 |
+
.stButton>button {{
|
| 48 |
+
background-color: {button_bg} !important;
|
| 49 |
+
color: {text_color} !important;
|
| 50 |
+
}}
|
| 51 |
+
/* Chat container and messages */
|
| 52 |
+
.chat-container {{
|
| 53 |
+
background-color: {chat_bg} !important;
|
| 54 |
+
color: {text_color} !important;
|
| 55 |
+
border: 1px solid {border_color} !important;
|
| 56 |
+
}}
|
| 57 |
+
.user-message {{
|
| 58 |
+
background-color: {user_bg} !important;
|
| 59 |
+
color: {text_color} !important;
|
| 60 |
+
}}
|
| 61 |
+
.bot-message {{
|
| 62 |
+
background-color: {bot_bg} !important;
|
| 63 |
+
color: {text_color} !important;
|
| 64 |
+
}}
|
| 65 |
+
/* Text area output box */
|
| 66 |
+
textarea {{
|
| 67 |
+
background-color: {chat_bg} !important;
|
| 68 |
+
color: {text_color} !important;
|
| 69 |
+
}}
|
| 70 |
+
</style>
|
| 71 |
+
""", unsafe_allow_html=True)
|
| 72 |
|
| 73 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
# Initialize session state
|
| 76 |
if 'code_output' not in st.session_state:
|
|
|
|
| 94 |
code = st_ace.st_ace(
|
| 95 |
placeholder="Write your Python code here...",
|
| 96 |
language="python",
|
| 97 |
+
theme=ace_theme, # β use the selected ACE theme
|
| 98 |
keybinding="vscode",
|
| 99 |
font_size=14,
|
| 100 |
min_lines=25,
|
|
|
|
| 153 |
# Footer
|
| 154 |
st.markdown("""
|
| 155 |
<div style='text-align: center'>
|
| 156 |
+
<p>Built with Streamlit By Vibhav with β€οΈ</p>
|
| 157 |
</div>
|
| 158 |
""", unsafe_allow_html=True)
|