Spaces:
Sleeping
Sleeping
Update utils/components/improved_sidebar.py
Browse files
utils/components/improved_sidebar.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
"""
|
2 |
-
مكون الشريط الجانبي المحسن
|
3 |
"""
|
4 |
|
5 |
import streamlit as st
|
@@ -22,12 +22,14 @@ def render_sidebar():
|
|
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,9 +43,19 @@ def render_sidebar():
|
|
41 |
/* تنسيق حاوية اللوجو */
|
42 |
.logo-container {{
|
43 |
display: flex;
|
|
|
|
|
44 |
justify-content: center;
|
45 |
-
margin
|
46 |
-
padding:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}}
|
48 |
|
49 |
/* تنسيق عنوان التطبيق */
|
@@ -51,10 +63,11 @@ def render_sidebar():
|
|
51 |
text-align: center;
|
52 |
color: {primary_color};
|
53 |
font-weight: bold;
|
54 |
-
font-size:
|
55 |
margin-bottom: 15px;
|
56 |
padding-bottom: 10px;
|
57 |
border-bottom: 1px solid #e0e0e0;
|
|
|
58 |
}}
|
59 |
|
60 |
/* تنسيق القوائم */
|
@@ -62,24 +75,35 @@ def render_sidebar():
|
|
62 |
padding-right: 0 !important;
|
63 |
}}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/* تنسيق عناصر القائمة */
|
66 |
.nav-link {{
|
67 |
text-align: right !important;
|
68 |
-
padding:
|
69 |
-
margin:
|
70 |
-
border-radius:
|
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: {
|
83 |
color: white !important;
|
84 |
font-weight: bold !important;
|
85 |
}}
|
@@ -87,23 +111,24 @@ def render_sidebar():
|
|
87 |
/* تنسيق معلومات المشروع */
|
88 |
.project-info {{
|
89 |
background-color: {sidebar_bg};
|
90 |
-
padding:
|
91 |
-
border-radius:
|
92 |
-
margin
|
93 |
-
|
94 |
}}
|
95 |
|
96 |
/* تنسيق معلومات المستخدم */
|
97 |
.user-info {{
|
98 |
background-color: {sidebar_bg};
|
99 |
-
padding:
|
100 |
-
border-radius:
|
101 |
-
margin
|
|
|
102 |
}}
|
103 |
|
104 |
/* تنسيق الفواصل */
|
105 |
hr {{
|
106 |
-
margin: 15px
|
107 |
border-color: #e0e0e0;
|
108 |
}}
|
109 |
|
@@ -116,10 +141,23 @@ def render_sidebar():
|
|
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,11 +165,9 @@ def render_sidebar():
|
|
127 |
with st.sidebar:
|
128 |
# إضافة اللوجو بتنسيق مخصص
|
129 |
st.markdown('<div class="logo-container">', unsafe_allow_html=True)
|
130 |
-
st.image("static/images/logo.png", width=
|
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(
|
@@ -161,14 +197,11 @@ def render_sidebar():
|
|
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": "
|
165 |
-
"nav-link-selected": {"background-color":
|
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
|
@@ -189,7 +222,6 @@ def render_sidebar():
|
|
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']}**")
|
@@ -204,8 +236,9 @@ def render_sidebar():
|
|
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
|
|
|
1 |
"""
|
2 |
+
مكون الشريط الجانبي المحسن - مع تحسين موضع الشعار وتحديث الأزرار والأيقونات
|
3 |
"""
|
4 |
|
5 |
import streamlit as st
|
|
|
22 |
bg_color = "#1e1e1e"
|
23 |
text_color = "#ffffff"
|
24 |
sidebar_bg = "#2d2d2d"
|
25 |
+
selected_bg = "#ff9a3c"
|
26 |
else:
|
27 |
primary_color = "#2c3e50"
|
28 |
secondary_color = "#ff9a3c"
|
29 |
bg_color = "#f8f9fa"
|
30 |
text_color = "#333333"
|
31 |
sidebar_bg = "#f0f2f6"
|
32 |
+
selected_bg = "#ff9a3c"
|
33 |
|
34 |
# تطبيق CSS مخصص لتحسين مظهر الشريط الجانبي
|
35 |
st.markdown(f"""
|
|
|
43 |
/* تنسيق حاوية اللوجو */
|
44 |
.logo-container {{
|
45 |
display: flex;
|
46 |
+
flex-direction: column;
|
47 |
+
align-items: center;
|
48 |
justify-content: center;
|
49 |
+
margin: 0 auto;
|
50 |
+
padding: 20px 0 10px 0;
|
51 |
+
text-align: center;
|
52 |
+
}}
|
53 |
+
|
54 |
+
/* تنسيق الشعار */
|
55 |
+
.logo-container img {{
|
56 |
+
border-radius: 50%;
|
57 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
58 |
+
margin-bottom: 15px;
|
59 |
}}
|
60 |
|
61 |
/* تنسيق عنوان التطبيق */
|
|
|
63 |
text-align: center;
|
64 |
color: {primary_color};
|
65 |
font-weight: bold;
|
66 |
+
font-size: 1rem;
|
67 |
margin-bottom: 15px;
|
68 |
padding-bottom: 10px;
|
69 |
border-bottom: 1px solid #e0e0e0;
|
70 |
+
width: 100%;
|
71 |
}}
|
72 |
|
73 |
/* تنسيق القوائم */
|
|
|
75 |
padding-right: 0 !important;
|
76 |
}}
|
77 |
|
78 |
+
/* تنسيق حاوية القائمة */
|
79 |
+
div[data-testid="stVerticalBlock"] > div:has(.nav-link) {{
|
80 |
+
background-color: {sidebar_bg};
|
81 |
+
border-radius: 8px;
|
82 |
+
margin: 0 5px;
|
83 |
+
overflow: hidden;
|
84 |
+
}}
|
85 |
+
|
86 |
/* تنسيق عناصر القائمة */
|
87 |
.nav-link {{
|
88 |
text-align: right !important;
|
89 |
+
padding: 12px 15px !important;
|
90 |
+
margin: 2px 0 !important;
|
91 |
+
border-radius: 0 !important;
|
92 |
transition: all 0.3s ease !important;
|
93 |
+
color: {primary_color} !important;
|
94 |
+
font-size: 14px !important;
|
95 |
}}
|
96 |
|
97 |
/* تنسيق الأيقونات */
|
98 |
.nav-link i {{
|
99 |
margin-left: 10px !important;
|
100 |
margin-right: 0 !important;
|
101 |
+
font-size: 16px !important;
|
102 |
}}
|
103 |
|
104 |
/* تنسيق القائمة المحددة */
|
105 |
.nav-link-selected {{
|
106 |
+
background-color: {selected_bg} !important;
|
107 |
color: white !important;
|
108 |
font-weight: bold !important;
|
109 |
}}
|
|
|
111 |
/* تنسيق معلومات المشروع */
|
112 |
.project-info {{
|
113 |
background-color: {sidebar_bg};
|
114 |
+
padding: 12px;
|
115 |
+
border-radius: 8px;
|
116 |
+
margin: 15px 5px;
|
117 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
118 |
}}
|
119 |
|
120 |
/* تنسيق معلومات المستخدم */
|
121 |
.user-info {{
|
122 |
background-color: {sidebar_bg};
|
123 |
+
padding: 12px;
|
124 |
+
border-radius: 8px;
|
125 |
+
margin: 15px 5px;
|
126 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
127 |
}}
|
128 |
|
129 |
/* تنسيق الفواصل */
|
130 |
hr {{
|
131 |
+
margin: 15px 5px;
|
132 |
border-color: #e0e0e0;
|
133 |
}}
|
134 |
|
|
|
141 |
padding: 8px 0;
|
142 |
border-radius: 5px;
|
143 |
transition: all 0.3s ease;
|
144 |
+
font-weight: bold;
|
145 |
+
margin-top: 5px;
|
146 |
}}
|
147 |
|
148 |
.stButton button:hover {{
|
149 |
background-color: {primary_color}dd;
|
150 |
+
transform: translateY(-2px);
|
151 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
152 |
+
}}
|
153 |
+
|
154 |
+
/* تنسيق معلومات الإصدار */
|
155 |
+
.version-info {{
|
156 |
+
text-align: center;
|
157 |
+
font-size: 0.8rem;
|
158 |
+
color: #888;
|
159 |
+
padding: 10px 0;
|
160 |
+
margin-top: 20px;
|
161 |
}}
|
162 |
</style>
|
163 |
""", unsafe_allow_html=True)
|
|
|
165 |
with st.sidebar:
|
166 |
# إضافة اللوجو بتنسيق مخصص
|
167 |
st.markdown('<div class="logo-container">', unsafe_allow_html=True)
|
168 |
+
st.image("static/images/logo.png", width=150)
|
|
|
|
|
|
|
169 |
st.markdown(f'<div class="app-title">{APP_TITLE.split("-")[0].strip()}</div>', unsafe_allow_html=True)
|
170 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
171 |
|
172 |
# إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu
|
173 |
selected_module = option_menu(
|
|
|
197 |
styles={
|
198 |
"container": {"padding": "0px", "background-color": "transparent"},
|
199 |
"icon": {"color": primary_color, "font-size": "18px"},
|
200 |
+
"nav-link": {"font-size": "14px", "text-align": "right", "margin": "0px", "padding": "12px 15px"},
|
201 |
+
"nav-link-selected": {"background-color": selected_bg, "color": "white", "font-weight": "bold"},
|
202 |
}
|
203 |
)
|
204 |
|
|
|
|
|
|
|
205 |
# إضافة معلومات المشروع الحالي
|
206 |
if 'current_project' in st.session_state and st.session_state.current_project:
|
207 |
project = st.session_state.current_project
|
|
|
222 |
if 'user_info' in st.session_state and st.session_state.user_info:
|
223 |
user = st.session_state.user_info
|
224 |
|
|
|
225 |
st.markdown('<div class="user-info">', unsafe_allow_html=True)
|
226 |
st.markdown("### معلومات المستخدم")
|
227 |
st.markdown(f"**{user['full_name']}**")
|
|
|
236 |
|
237 |
# إضافة معلومات النسخة
|
238 |
st.markdown("<hr>", unsafe_allow_html=True)
|
239 |
+
st.markdown('<div class="version-info">', unsafe_allow_html=True)
|
240 |
st.markdown(f"الإصدار: 1.0.0")
|
|
|
241 |
st.markdown(f"© 2025 شركة شبه الجزيرة للمقاولات")
|
242 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
243 |
|
244 |
return selected_module
|