Vela commited on
Commit
f50ce06
·
1 Parent(s): fee11be

modified navbar

Browse files
src/frontend/app.py CHANGED
@@ -1,4 +1,5 @@
1
  from utils import common_functions
2
 
3
  common_functions.set_up_page()
4
- common_functions.navbar_with_title()
 
 
1
  from utils import common_functions
2
 
3
  common_functions.set_up_page()
4
+ common_functions.navbar_with_title()
5
+ common_functions.set_bg_image('src/frontend/images/background.jpeg',opacity=0.1)
src/frontend/utils/__pycache__/common_functions.cpython-313.pyc CHANGED
Binary files a/src/frontend/utils/__pycache__/common_functions.cpython-313.pyc and b/src/frontend/utils/__pycache__/common_functions.cpython-313.pyc differ
 
src/frontend/utils/common_functions.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  PAGE_ICON = 'src/frontend/images/jb_events_logo.jpg'
4
  PAGE_LAYOUT = 'wide'
@@ -12,14 +13,18 @@ def navbar_with_title():
12
  st.markdown(f"""
13
  <style>
14
  .navbar {{
 
 
 
 
15
  display: flex;
16
  align-items: center;
17
  justify-content: space-between;
18
- width: 100%;
19
- padding: 1px 30px;
20
  background-color: #1F1F1F; /* Dark background */
21
- border-radius: 50px;
22
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
 
23
  }}
24
 
25
  .left-section {{
@@ -61,7 +66,7 @@ def navbar_with_title():
61
 
62
  <div class="navbar">
63
  <div class="left-section">
64
- <h1 class="title">JB Events & Management</h1>
65
  </div>
66
  <div class="menu">
67
  <a href="#">HOME</a>
@@ -74,4 +79,46 @@ def navbar_with_title():
74
  📞 +91-744-888-6668
75
  </div>
76
  </div>
77
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import base64
3
 
4
  PAGE_ICON = 'src/frontend/images/jb_events_logo.jpg'
5
  PAGE_LAYOUT = 'wide'
 
13
  st.markdown(f"""
14
  <style>
15
  .navbar {{
16
+ position: fixed; /* Fix the navbar at the top */
17
+ top: 1;
18
+ left: 0;
19
+ width: 100%;
20
  display: flex;
21
  align-items: center;
22
  justify-content: space-between;
23
+ padding: 1px 50px;
 
24
  background-color: #1F1F1F; /* Dark background */
25
+ border-radius: 0; /* Remove border-radius for full-width navbar */
26
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
27
+ z-index: 1000; /* Ensure it stays above other content */
28
  }}
29
 
30
  .left-section {{
 
66
 
67
  <div class="navbar">
68
  <div class="left-section">
69
+ <h1 class="title">JB Consultancy</h1>
70
  </div>
71
  <div class="menu">
72
  <a href="#">HOME</a>
 
79
  📞 +91-744-888-6668
80
  </div>
81
  </div>
82
+ """, unsafe_allow_html=True)
83
+
84
+ def img_to_base64(image_path):
85
+ """Convert image to base64."""
86
+ try:
87
+ with open(image_path, "rb") as img_file:
88
+ return base64.b64encode(img_file.read()).decode()
89
+ except Exception as e:
90
+ # logger.error(f"Error converting image to base64: {str(e)}")
91
+ return None
92
+
93
+ def set_bg_image(file_path, opacity=0.5):
94
+ """
95
+ Sets a background image for the Streamlit application with optional opacity control.
96
+ This function applies a background image to the entire Streamlit app (`.stApp` container)
97
+ using CSS with a linear gradient overlay. The overlay enhances text readability by adding
98
+ a semi-transparent dark layer over the image.
99
+ Args:
100
+ file_path (str): The file path of the background image (supports PNG, JPG, etc.).
101
+ opacity (float, optional): The opacity level of the dark overlay.
102
+ Values range from 0 (fully transparent) to 1 (fully opaque).
103
+ Default is 0.5, providing balanced readability and background visibility.
104
+ Example Usage:
105
+ ```python
106
+ set_bg_image("src/frontend/images/health_care_banner.png", opacity=0.6)
107
+ ```
108
+ Notes:
109
+ - Ensure the provided `file_path` is accessible and the image is properly encoded in base64 format.
110
+ - For optimal results, use high-resolution images with suitable contrast to enhance readability.
111
+ """
112
+ encoded_img = img_to_base64(file_path)
113
+ st.markdown(
114
+ f"""
115
+ <style>
116
+ .stApp {{
117
+ background: linear-gradient(rgba(0, 0, 0, {opacity}), rgba(0, 0, 0, {opacity})),
118
+ url("data:image/png;base64,{encoded_img}") center/cover fixed no-repeat;
119
+ min-height: 100vh;
120
+ }}
121
+ </style>
122
+ """,
123
+ unsafe_allow_html=True
124
+ )