Esmaeilkianii commited on
Commit
4e80d38
·
verified ·
1 Parent(s): fffcbca

Create Styles.py

Browse files
Files changed (1) hide show
  1. Styles.py +277 -0
Styles.py ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def apply_custom_styles():
4
+ """
5
+ Apply custom CSS styles to the application
6
+ """
7
+ # Set default theme if not already set
8
+ if 'selected_theme_name' not in st.session_state:
9
+ st.session_state.selected_theme_name = "پیش‌فرض (آبی تیره)"
10
+
11
+ # Define theme colors (CSS variables)
12
+ # Each theme will override these variables
13
+ THEMES = {
14
+ "پیش‌فرض (آبی تیره)": {
15
+ "--primary-color": "#1a535c", # Dark Teal
16
+ "--secondary-color": "#4ecdc4", # Light Teal
17
+ "--accent-color": "#e76f51", # Coral
18
+ "--background-color": "#f0f2f6", # Light Grey Page BG
19
+ "--container-background-color": "#ffffff", # White Container BG
20
+ "--text-color": "#212529", # Dark Text
21
+ "--header-text-color": "#1a535c",
22
+ "--button-bg-color": "#264653",
23
+ "--button-hover-bg-color": "#2a9d8f",
24
+ "--metric-border-accent": "#4ecdc4",
25
+ "--table-header-bg": "#2a9d8f",
26
+ "--tab-active-bg": "#4ecdc4",
27
+ "--tab-active-text": "white",
28
+ "--info-bg": "#e6f7ff", # Light blue for info boxes
29
+ "--info-border": "#007bff",
30
+ "--warning-bg": "#fff3cd", # Light yellow for warning
31
+ "--warning-border": "#ffc107",
32
+ "--success-bg": "#f0fff0", # Light green for success
33
+ "--success-border": "#28a745",
34
+ },
35
+ "تم سبز (طبیعت)": {
36
+ "--primary-color": "#2d6a4f", # Dark Green
37
+ "--secondary-color": "#74c69d", # Medium Green
38
+ "--accent-color": "#fca311", # Orange accent
39
+ "--background-color": "#f4f9f4",
40
+ "--container-background-color": "#ffffff",
41
+ "--text-color": "#1b4332",
42
+ "--header-text-color": "#2d6a4f",
43
+ "--button-bg-color": "#40916c",
44
+ "--button-hover-bg-color": "#52b788",
45
+ "--metric-border-accent": "#74c69d",
46
+ "--table-header-bg": "#40916c",
47
+ "--tab-active-bg": "#74c69d",
48
+ "--tab-active-text": "white",
49
+ "--info-bg": "#e6fff0",
50
+ "--info-border": "#2d6a4f",
51
+ "--warning-bg": "#fff9e6",
52
+ "--warning-border": "#fca311",
53
+ "--success-bg": "#e6fff0",
54
+ "--success-border": "#2d6a4f",
55
+ },
56
+ "تم قرمز (هشدار)": {
57
+ "--primary-color": "#9d0208", # Dark Red
58
+ "--secondary-color": "#dc2f02", # Medium Red
59
+ "--accent-color": "#ffba08", # Yellow accent
60
+ "--background-color": "#fff5f5",
61
+ "--container-background-color": "#ffffff",
62
+ "--text-color": "#370617",
63
+ "--header-text-color": "#9d0208",
64
+ "--button-bg-color": "#ae2012",
65
+ "--button-hover-bg-color": "#dc2f02",
66
+ "--metric-border-accent": "#dc2f02",
67
+ "--table-header-bg": "#ae2012",
68
+ "--tab-active-bg": "#dc2f02",
69
+ "--tab-active-text": "white",
70
+ "--info-bg": "#ffeeee",
71
+ "--info-border": "#9d0208",
72
+ "--warning-bg": "#fff0e6",
73
+ "--warning-border": "#ffba08",
74
+ "--success-bg": "#eeffee", # Less prominent success
75
+ "--success-border": "#555",
76
+ },
77
+ "تم زرد/نارنجی (گرم)": {
78
+ "--primary-color": "#e76f51", # Coral (Primary)
79
+ "--secondary-color": "#f4a261", # Sandy Brown
80
+ "--accent-color": "#2a9d8f", # Teal Accent
81
+ "--background-color": "#fff8f0",
82
+ "--container-background-color": "#ffffff",
83
+ "--text-color": "#854d0e", # Brown text
84
+ "--header-text-color": "#d95f02", # Dark Orange
85
+ "--button-bg-color": "#e76f51",
86
+ "--button-hover-bg-color": "#f4a261",
87
+ "--metric-border-accent": "#f4a261",
88
+ "--table-header-bg": "#e76f51",
89
+ "--tab-active-bg": "#f4a261",
90
+ "--tab-active-text": "white",
91
+ "--info-bg": "#fff8e1",
92
+ "--info-border": "#e76f51",
93
+ "--warning-bg": "#fff3cd",
94
+ "--warning-border": "#f4a261",
95
+ "--success-bg": "#f0fff0",
96
+ "--success-border": "#2a9d8f",
97
+ },
98
+ "تم قهوه‌ای (خاکی)": {
99
+ "--primary-color": "#544741", # Dark Brown
100
+ "--secondary-color": "#8a786f", # Medium Brown
101
+ "--accent-color": "#c6ac8f", # Light Tan/Beige
102
+ "--background-color": "#f5f2ef",
103
+ "--container-background-color": "#ffffff",
104
+ "--text-color": "#3d2c25",
105
+ "--header-text-color": "#544741",
106
+ "--button-bg-color": "#6f5f55",
107
+ "--button-hover-bg-color": "#8a786f",
108
+ "--metric-border-accent": "#8a786f",
109
+ "--table-header-bg": "#6f5f55",
110
+ "--tab-active-bg": "#8a786f",
111
+ "--tab-active-text": "white",
112
+ "--info-bg": "#f9f6f3",
113
+ "--info-border": "#544741",
114
+ "--warning-bg": "#fef7eT",
115
+ "--warning-border": "#c6ac8f",
116
+ "--success-bg": "#f3f9f3",
117
+ "--success-border": "#777",
118
+ },
119
+ "تم روشن (ساده)": {
120
+ "--primary-color": "#4A5568", # Cool Gray
121
+ "--secondary-color": "#718096", # Medium Gray
122
+ "--accent-color": "#3182CE", # Blue Accent
123
+ "--background-color": "#F7FAFC",
124
+ "--container-background-color": "#FFFFFF",
125
+ "--text-color": "#2D3748",
126
+ "--header-text-color": "#2D3748",
127
+ "--button-bg-color": "#4A5568",
128
+ "--button-hover-bg-color": "#2D3748",
129
+ "--metric-border-accent": "#718096",
130
+ "--table-header-bg": "#E2E8F0",
131
+ "--tab-active-bg": "#4A5568",
132
+ "--tab-active-text": "white",
133
+ "--info-bg": "#EBF8FF",
134
+ "--info-border": "#3182CE",
135
+ "--warning-bg": "#FFFBEB",
136
+ "--warning-border": "#ECC94B",
137
+ "--success-bg": "#F0FFF4",
138
+ "--success-border": "#48BB78",
139
+ }
140
+ }
141
+
142
+ # Get current theme colors
143
+ current_theme_colors = THEMES[st.session_state.selected_theme_name]
144
+
145
+ # Generate CSS variables from theme
146
+ css_vars = "\n".join([f"{var}: {val};" for var, val in current_theme_colors.items()])
147
+
148
+ # Apply custom CSS
149
+ st.markdown(f"""
150
+ <style>
151
+ /* Apply theme variables */
152
+ :root {{
153
+ {css_vars}
154
+ }}
155
+
156
+ /* Right-to-left (RTL) Support */
157
+ .stApp {{
158
+ direction: rtl;
159
+ text-align: right;
160
+ }}
161
+
162
+ /* Headers */
163
+ h1, h2, h3, h4, h5, h6 {{
164
+ color: var(--header-text-color);
165
+ font-family: 'Vazirmatn', 'Arial', sans-serif !important;
166
+ }}
167
+
168
+ /* General text */
169
+ p, div, span, label {{
170
+ color: var(--text-color);
171
+ font-family: 'Vazirmatn', 'Arial', sans-serif !important;
172
+ }}
173
+
174
+ /* Containers */
175
+ .stApp {{
176
+ background-color: var(--background-color);
177
+ }}
178
+
179
+ .block-container, div.stBlock {{
180
+ background-color: var(--container-background-color);
181
+ padding: 2rem;
182
+ border-radius: 10px;
183
+ box-shadow: 0 4px 12px rgba(0,0,0,0.05);
184
+ }}
185
+
186
+ /* Metrics */
187
+ [data-testid="stMetric"] {{
188
+ background-color: var(--container-background-color);
189
+ border-radius: 10px;
190
+ padding: 1rem;
191
+ border-left: 4px solid var(--metric-border-accent);
192
+ box-shadow: 0 2px 6px rgba(0,0,0,0.05);
193
+ }}
194
+
195
+ /* Buttons */
196
+ .stButton > button {{
197
+ background-color: var(--button-bg-color) !important;
198
+ color: white !important;
199
+ border: none !important;
200
+ border-radius: 6px !important;
201
+ padding: 0.5rem 1rem !important;
202
+ transition: all 0.3s ease !important;
203
+ }}
204
+
205
+ .stButton > button:hover {{
206
+ background-color: var(--button-hover-bg-color) !important;
207
+ transform: translateY(-2px);
208
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
209
+ }}
210
+
211
+ /* Tables */
212
+ .stDataFrame {{
213
+ border-radius: 8px;
214
+ overflow: hidden;
215
+ box-shadow: 0 2px 6px rgba(0,0,0,0.05);
216
+ }}
217
+
218
+ .dataframe thead tr th {{
219
+ background-color: var(--table-header-bg) !important;
220
+ color: white !important;
221
+ font-weight: 600 !important;
222
+ }}
223
+
224
+ /* Alerts and Info boxes */
225
+ .stAlert {{
226
+ border-radius: 8px !important;
227
+ border-width: 1px !important;
228
+ }}
229
+
230
+ [data-baseweb="notification"] {{
231
+ border-radius: 8px !important;
232
+ }}
233
+
234
+ /* Tabs */
235
+ .stTabs [data-baseweb="tab-list"] {{
236
+ gap: 1px;
237
+ background-color: #f0f2f6;
238
+ border-radius: 10px;
239
+ padding: 5px;
240
+ }}
241
+
242
+ .stTabs [data-baseweb="tab"] {{
243
+ height: 50px;
244
+ white-space: pre-wrap;
245
+ border-radius: 6px;
246
+ margin-left: 5px;
247
+ margin-right: 5px;
248
+ transition: all 0.3s ease;
249
+ }}
250
+
251
+ .stTabs [aria-selected="true"] {{
252
+ background-color: var(--tab-active-bg) !important;
253
+ color: var(--tab-active-text) !important;
254
+ font-weight: 600;
255
+ }}
256
+
257
+ /* Text areas and inputs */
258
+ .stTextArea textarea, .stTextInput input, .stSelectbox, .stMultiselect {{
259
+ border-radius: 6px !important;
260
+ border: 1px solid #dee2e6 !important;
261
+ padding: 0.5rem !important;
262
+ }}
263
+
264
+ /* Animations */
265
+ @keyframes fadeIn {{
266
+ from {{ opacity: 0; transform: translateY(10px); }}
267
+ to {{ opacity: 1; transform: translateY(0); }}
268
+ }}
269
+
270
+ .stBlock, .stDataFrame, .stMetric, .stText, .stAlert, [data-testid="stExpander"] {{
271
+ animation: fadeIn 0.5s ease-out;
272
+ }}
273
+ </style>
274
+
275
+ <!-- Add Vazirmatn font for Persian language support -->
276
+ <link href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css" rel="stylesheet" type="text/css" />
277
+ """, unsafe_allow_html=True)