EGYADMIN commited on
Commit
3e44ec8
·
verified ·
1 Parent(s): f198205

Update utils/components/improved_sidebar.py

Browse files
Files changed (1) hide show
  1. utils/components/improved_sidebar.py +53 -126
utils/components/improved_sidebar.py CHANGED
@@ -1,5 +1,5 @@
1
  """
2
- مكون الشريط الجانبي المحسن - مع وضع الأيقونات على اليمين وتحسين المظهر الاحترافي
3
  """
4
 
5
  import streamlit as st
@@ -22,20 +22,12 @@ def render_sidebar():
22
  bg_color = "#1e1e1e"
23
  text_color = "#ffffff"
24
  sidebar_bg = "#2d2d2d"
25
- selected_bg = "#ff9a3c"
26
- menu_bg = "#252525"
27
- button_bg = "#3498db"
28
- button_hover = "#2980b9"
29
  else:
30
  primary_color = "#2c3e50"
31
  secondary_color = "#ff9a3c"
32
  bg_color = "#f8f9fa"
33
  text_color = "#333333"
34
  sidebar_bg = "#f0f2f6"
35
- selected_bg = "#ff9a3c"
36
- menu_bg = "#ffffff"
37
- button_bg = "#2c3e50"
38
- button_hover = "#34495e"
39
 
40
  # تطبيق CSS مخصص لتحسين مظهر الشريط الجانبي
41
  st.markdown(f"""
@@ -49,21 +41,9 @@ def render_sidebar():
49
  /* تنسيق حاوية اللوجو */
50
  .logo-container {{
51
  display: flex;
52
- flex-direction: column;
53
- align-items: center;
54
  justify-content: center;
55
- margin: 0 auto;
56
- padding: 20px 0 15px 0;
57
- text-align: center;
58
- width: 100%;
59
- }}
60
-
61
- /* تنسيق الشعار */
62
- .logo-container img {{
63
- border-radius: 50%;
64
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
65
- margin-bottom: 15px;
66
- border: 3px solid {secondary_color};
67
  }}
68
 
69
  /* تنسيق عنوان التطبيق */
@@ -71,11 +51,10 @@ def render_sidebar():
71
  text-align: center;
72
  color: {primary_color};
73
  font-weight: bold;
74
- font-size: 1rem;
75
- margin-bottom: 20px;
76
- padding-bottom: 15px;
77
  border-bottom: 1px solid #e0e0e0;
78
- width: 90%;
79
  }}
80
 
81
  /* تنسيق القوائم */
@@ -83,117 +62,64 @@ def render_sidebar():
83
  padding-right: 0 !important;
84
  }}
85
 
86
- /* تنسيق حاوية القائمة */
87
- div[data-testid="stVerticalBlock"] > div:has(.nav-link) {{
88
- background-color: {menu_bg};
89
- border-radius: 10px;
90
- margin: 0 5px 15px 5px;
91
- overflow: hidden;
92
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
93
- }}
94
-
95
  /* تنسيق عناصر القائمة */
96
  .nav-link {{
97
  text-align: right !important;
98
- padding: 12px 15px !important;
99
- margin: 2px 0 !important;
100
- border-radius: 0 !important;
101
  transition: all 0.3s ease !important;
102
- color: {primary_color} !important;
103
- font-size: 14px !important;
104
- display: flex !important;
105
- flex-direction: row-reverse !important;
106
- align-items: center !important;
107
- justify-content: flex-start !important;
108
  }}
109
 
110
  /* تنسيق الأيقونات */
111
  .nav-link i {{
112
- margin-left: 12px !important;
113
  margin-right: 0 !important;
114
- font-size: 18px !important;
115
- color: {secondary_color} !important;
116
  }}
117
 
118
  /* تنسيق القائمة المحددة */
119
  .nav-link-selected {{
120
- background-color: {selected_bg} !important;
121
  color: white !important;
122
  font-weight: bold !important;
123
  }}
124
 
125
- /* تنسيق أيقونات القائمة المحددة */
126
- .nav-link-selected i {{
127
- color: white !important;
128
- }}
129
-
130
- /* تأثير التحويم على عناصر القائمة */
131
- .nav-link:not(.nav-link-selected):hover {{
132
- background-color: {sidebar_bg} !important;
133
- transform: translateX(-3px);
134
- }}
135
-
136
  /* تنسيق معلومات المشروع */
137
  .project-info {{
138
- background-color: {menu_bg};
139
- padding: 15px;
140
- border-radius: 10px;
141
- margin: 15px 5px;
142
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
143
  }}
144
 
145
  /* تنسيق معلومات المستخدم */
146
  .user-info {{
147
- background-color: {menu_bg};
148
- padding: 15px;
149
- border-radius: 10px;
150
- margin: 15px 5px;
151
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
152
- }}
153
-
154
- /* تنسيق عناوين المعلومات */
155
- .info-title {{
156
- color: {secondary_color};
157
- font-weight: bold;
158
- font-size: 1.1rem;
159
- margin-bottom: 10px;
160
- padding-bottom: 5px;
161
- border-bottom: 1px solid #e0e0e0;
162
  }}
163
 
164
  /* تنسيق الفواصل */
165
  hr {{
166
- margin: 15px 5px;
167
  border-color: #e0e0e0;
168
  }}
169
 
170
  /* تنسيق الأزرار */
171
  .stButton button {{
172
  width: 100%;
173
- background-color: {button_bg};
174
  color: white;
175
  border: none;
176
- padding: 10px 0;
177
- border-radius: 8px;
178
  transition: all 0.3s ease;
179
- font-weight: bold;
180
- margin-top: 8px;
181
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
182
  }}
183
 
184
  .stButton button:hover {{
185
- background-color: {button_hover};
186
- transform: translateY(-2px);
187
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
188
- }}
189
-
190
- /* تنسيق معلومات الإصدار */
191
- .version-info {{
192
- text-align: center;
193
- font-size: 0.8rem;
194
- color: #888;
195
- padding: 10px 0;
196
- margin-top: 20px;
197
  }}
198
  </style>
199
  """, unsafe_allow_html=True)
@@ -201,12 +127,12 @@ def render_sidebar():
201
  with st.sidebar:
202
  # إضافة اللوجو بتنسيق مخصص
203
  st.markdown('<div class="logo-container">', unsafe_allow_html=True)
204
- # ضبط حجم الشعار ليتناسب مع حجم القائمة
205
- logo_width = 140 # حجم متناسب مع عرض القائمة
206
- st.image("static/images/logo.png", width=logo_width)
207
- st.markdown(f'<div class="app-title">{APP_TITLE.split("-")[0].strip()}</div>', unsafe_allow_html=True)
208
  st.markdown('</div>', unsafe_allow_html=True)
209
 
 
 
 
210
  # إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu
211
  selected_module = option_menu(
212
  "", # إزالة العنوان لأننا أضفناه بشكل منفصل أعلاه
@@ -234,36 +160,38 @@ def render_sidebar():
234
  default_index=0,
235
  styles={
236
  "container": {"padding": "0px", "background-color": "transparent"},
237
- "icon": {"color": secondary_color, "font-size": "18px"},
238
- "nav-link": {"font-size": "14px", "text-align": "right", "margin": "0px", "padding": "12px 15px"},
239
- "nav-link-selected": {"background-color": selected_bg, "color": "white", "font-weight": "bold"},
240
  }
241
  )
242
 
243
- # إضافة معلومات المشروع الحالي
 
244
 
245
- if 'current_project' in st.session_state and st.session_state.current_project:
246
- project_id = st.session_state.current_project
247
- project = next((p for p in st.session_state.projects if p['id'] == project_id), None)
248
-
249
- if project:
250
- st.markdown('<div class="project-info">', unsafe_allow_html=True)
251
- st.markdown('<div class="info-title">المشروع الحالي</div>', unsafe_allow_html=True)
252
- st.markdown(f"**{project['name']}**")
253
- st.markdown(f"رقم المناقصة: {project.get('number', 'غير متوفر')}")
254
- st.markdown(f"الجهة المالكة: {project['client']}")
255
- st.markdown('</div>', unsafe_allow_html=True)
256
-
257
- pass
258
- else:
259
- st.warning("لم يتم العثور على تفاصيل المشروع الحالي.")
260
 
261
  # إضافة معلومات المستخدم
262
  if 'user_info' in st.session_state and st.session_state.user_info:
263
  user = st.session_state.user_info
264
 
 
265
  st.markdown('<div class="user-info">', unsafe_allow_html=True)
266
- st.markdown('<div class="info-title">معلومات المستخدم</div>', unsafe_allow_html=True)
267
  st.markdown(f"**{user['full_name']}**")
268
  st.markdown(f"الدور: {user['role']}")
269
  st.markdown('</div>', unsafe_allow_html=True)
@@ -276,9 +204,8 @@ if 'current_project' in st.session_state and st.session_state.current_project:
276
 
277
  # إضافة معلومات النسخة
278
  st.markdown("<hr>", unsafe_allow_html=True)
279
- st.markdown('<div class="version-info">', unsafe_allow_html=True)
280
  st.markdown(f"الإصدار: 1.0.0")
 
281
  st.markdown(f"© 2025 شركة شبه الجزيرة للمقاولات")
282
- st.markdown('</div>', unsafe_allow_html=True)
283
 
284
- return selected_module
 
1
  """
2
+ مكون الشريط الجانبي المحسن
3
  """
4
 
5
  import streamlit as st
 
22
  bg_color = "#1e1e1e"
23
  text_color = "#ffffff"
24
  sidebar_bg = "#2d2d2d"
 
 
 
 
25
  else:
26
  primary_color = "#2c3e50"
27
  secondary_color = "#ff9a3c"
28
  bg_color = "#f8f9fa"
29
  text_color = "#333333"
30
  sidebar_bg = "#f0f2f6"
 
 
 
 
31
 
32
  # تطبيق CSS مخصص لتحسين مظهر الشريط الجانبي
33
  st.markdown(f"""
 
41
  /* تنسيق حاوية اللوجو */
42
  .logo-container {{
43
  display: flex;
 
 
44
  justify-content: center;
45
+ margin-bottom: 10px;
46
+ padding: 15px 0;
 
 
 
 
 
 
 
 
 
 
47
  }}
48
 
49
  /* تنسيق عنوان التطبيق */
 
51
  text-align: center;
52
  color: {primary_color};
53
  font-weight: bold;
54
+ font-size: 1.2rem;
55
+ margin-bottom: 15px;
56
+ padding-bottom: 10px;
57
  border-bottom: 1px solid #e0e0e0;
 
58
  }}
59
 
60
  /* تنسيق القوائم */
 
62
  padding-right: 0 !important;
63
  }}
64
 
 
 
 
 
 
 
 
 
 
65
  /* تنسيق عناصر القائمة */
66
  .nav-link {{
67
  text-align: right !important;
68
+ padding: 10px 15px !important;
69
+ margin: 5px 0 !important;
70
+ border-radius: 5px !important;
71
  transition: all 0.3s ease !important;
 
 
 
 
 
 
72
  }}
73
 
74
  /* تنسيق الأيقونات */
75
  .nav-link i {{
76
+ margin-left: 10px !important;
77
  margin-right: 0 !important;
 
 
78
  }}
79
 
80
  /* تنسيق القائمة المحددة */
81
  .nav-link-selected {{
82
+ background-color: {secondary_color} !important;
83
  color: white !important;
84
  font-weight: bold !important;
85
  }}
86
 
 
 
 
 
 
 
 
 
 
 
 
87
  /* تنسيق معلومات المشروع */
88
  .project-info {{
89
+ background-color: {sidebar_bg};
90
+ padding: 10px;
91
+ border-radius: 5px;
92
+ margin-top: 10px;
93
+ margin-bottom: 10px;
94
  }}
95
 
96
  /* تنسيق معلومات المستخدم */
97
  .user-info {{
98
+ background-color: {sidebar_bg};
99
+ padding: 10px;
100
+ border-radius: 5px;
101
+ margin-top: 10px;
 
 
 
 
 
 
 
 
 
 
 
102
  }}
103
 
104
  /* تنسيق الفواصل */
105
  hr {{
106
+ margin: 15px 0;
107
  border-color: #e0e0e0;
108
  }}
109
 
110
  /* تنسيق الأزرار */
111
  .stButton button {{
112
  width: 100%;
113
+ background-color: {primary_color};
114
  color: white;
115
  border: none;
116
+ padding: 8px 0;
117
+ border-radius: 5px;
118
  transition: all 0.3s ease;
 
 
 
119
  }}
120
 
121
  .stButton button:hover {{
122
+ background-color: {primary_color}dd;
 
 
 
 
 
 
 
 
 
 
 
123
  }}
124
  </style>
125
  """, unsafe_allow_html=True)
 
127
  with st.sidebar:
128
  # إضافة اللوجو بتنسيق مخصص
129
  st.markdown('<div class="logo-container">', unsafe_allow_html=True)
130
+ st.image("static/images/logo.png", width=180)
 
 
 
131
  st.markdown('</div>', unsafe_allow_html=True)
132
 
133
+ # إضافة عنوان التطبيق
134
+ st.markdown(f'<div class="app-title">{APP_TITLE.split("-")[0].strip()}</div>', unsafe_allow_html=True)
135
+
136
  # إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu
137
  selected_module = option_menu(
138
  "", # إزالة العنوان لأننا أضفناه بشكل منفصل أعلاه
 
160
  default_index=0,
161
  styles={
162
  "container": {"padding": "0px", "background-color": "transparent"},
163
+ "icon": {"color": primary_color, "font-size": "18px"},
164
+ "nav-link": {"font-size": "14px", "text-align": "right", "margin": "5px 0px", "padding": "10px 15px"},
165
+ "nav-link-selected": {"background-color": secondary_color, "color": "white", "font-weight": "bold"},
166
  }
167
  )
168
 
169
+ # إضافة فاصل
170
+ st.markdown("<hr>", unsafe_allow_html=True)
171
 
172
+ # إضافة معلومات المشروع الحالي
173
+ if 'current_project' in st.session_state and st.session_state.current_project:
174
+ project = st.session_state.current_project
175
+
176
+ st.markdown('<div class="project-info">', unsafe_allow_html=True)
177
+ st.markdown("### المشروع الحالي")
178
+ st.markdown(f"**{project['name']}**")
179
+ st.markdown(f"رقم المناقصة: {project['number']}")
180
+ st.markdown(f"الجهة المالكة: {project['client']}")
181
+ st.markdown('</div>', unsafe_allow_html=True)
182
+
183
+ # إضافة زر للتبديل بين المشاريع
184
+ if st.button("تبديل المشروع"):
185
+ # لتنفيذ في مرحلة لاحقة
186
+ pass
187
 
188
  # إضافة معلومات المستخدم
189
  if 'user_info' in st.session_state and st.session_state.user_info:
190
  user = st.session_state.user_info
191
 
192
+ st.markdown("<hr>", unsafe_allow_html=True)
193
  st.markdown('<div class="user-info">', unsafe_allow_html=True)
194
+ st.markdown("### معلومات المستخدم")
195
  st.markdown(f"**{user['full_name']}**")
196
  st.markdown(f"الدور: {user['role']}")
197
  st.markdown('</div>', unsafe_allow_html=True)
 
204
 
205
  # إضافة معلومات النسخة
206
  st.markdown("<hr>", unsafe_allow_html=True)
 
207
  st.markdown(f"الإصدار: 1.0.0")
208
+ st.markdown(f"تاريخ الإصدار: 2025-03-15")
209
  st.markdown(f"© 2025 شركة شبه الجزيرة للمقاولات")
 
210
 
211
+ return selected_module