Update app.py
Browse files
app.py
CHANGED
@@ -1,88 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
# Set page config
|
4 |
-
st.set_page_config(page_title="Floating Navigation", layout="wide")
|
5 |
-
|
6 |
-
# Create a session state for the navigation panel visibility
|
7 |
-
if 'show_nav' not in st.session_state:
|
8 |
-
st.session_state.show_nav = False
|
9 |
-
|
10 |
-
# Function to toggle navigation panel
|
11 |
-
def toggle_nav():
|
12 |
-
st.session_state.show_nav = not st.session_state.show_nav
|
13 |
-
|
14 |
-
# Add a floating action button style
|
15 |
-
st.markdown("""
|
16 |
-
<style>
|
17 |
-
.floating-button {
|
18 |
-
position: fixed;
|
19 |
-
bottom: 20px;
|
20 |
-
right: 20px;
|
21 |
-
background-color: #4CAF50;
|
22 |
-
color: white;
|
23 |
-
border-radius: 50%;
|
24 |
-
width: 60px;
|
25 |
-
height: 60px;
|
26 |
-
display: flex;
|
27 |
-
justify-content: center;
|
28 |
-
align-items: center;
|
29 |
-
font-size: 24px;
|
30 |
-
cursor: pointer;
|
31 |
-
z-index: 999;
|
32 |
-
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
|
33 |
-
}
|
34 |
-
</style>
|
35 |
-
<div class="floating-button" onclick="document.getElementById('nav-toggle').click();">
|
36 |
-
≡
|
37 |
-
</div>
|
38 |
-
""", unsafe_allow_html=True)
|
39 |
-
|
40 |
-
# Hidden button to trigger the toggle function
|
41 |
-
st.markdown('<button id="nav-toggle" style="display:none"></button>', unsafe_allow_html=True)
|
42 |
-
if st.button("Toggle Navigation", key="toggle_button", on_click=toggle_nav):
|
43 |
-
pass # This is just to trigger the on_click function
|
44 |
-
|
45 |
-
# Main content
|
46 |
-
st.title("My Application")
|
47 |
-
|
48 |
-
# Conditional navigation panel
|
49 |
-
if st.session_state.show_nav:
|
50 |
-
with st.container():
|
51 |
-
st.markdown("### Quick Navigation")
|
52 |
-
if st.button("Go to Section 1"):
|
53 |
-
st.session_state.section = "section1"
|
54 |
-
st.session_state.show_nav = False
|
55 |
-
st.experimental_rerun()
|
56 |
-
if st.button("Go to Section 2"):
|
57 |
-
st.session_state.section = "section2"
|
58 |
-
st.session_state.show_nav = False
|
59 |
-
st.experimental_rerun()
|
60 |
-
if st.button("Go to Section 3"):
|
61 |
-
st.session_state.section = "section3"
|
62 |
-
st.session_state.show_nav = False
|
63 |
-
st.experimental_rerun()
|
64 |
-
|
65 |
-
# Content sections
|
66 |
-
if 'section' not in st.session_state:
|
67 |
-
st.session_state.section = "section1"
|
68 |
-
|
69 |
-
if st.session_state.section == "section1":
|
70 |
-
st.header("Section 1")
|
71 |
-
st.write("This is section 1 content")
|
72 |
-
for i in range(15):
|
73 |
-
st.write(f"Content line {i}")
|
74 |
-
|
75 |
-
elif st.session_state.section == "section2":
|
76 |
-
st.header("Section 2")
|
77 |
-
st.write("This is section 2 content")
|
78 |
-
for i in range(15):
|
79 |
-
st.write(f"Content line {i}")
|
80 |
-
|
81 |
-
elif st.session_state.section == "section3":
|
82 |
-
st.header("Section 3")
|
83 |
-
st.write("This is section 3 content")
|
84 |
-
for i in range(15):
|
85 |
-
st.write(f"Content line {i}")
|
86 |
|
87 |
|
88 |
|
|
|
1 |
import streamlit as st
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
|
5 |
|