@@ -41,7 +41,7 @@ def use_sidebar(key: str, session: dict, default_open: bool = True) -> SidebarRe
41
41
return ref
42
42
43
43
44
- def sidebar_list_item (icon , title , is_sidebar_open , url = None ):
44
+ def sidebar_list_item (icon , title , is_sidebar_open , url = None , hover_icon = None ):
45
45
with (
46
46
gui .styled (
47
47
"""
@@ -50,46 +50,60 @@ def sidebar_list_item(icon, title, is_sidebar_open, url=None):
50
50
text-decoration: none;
51
51
}
52
52
& .sidebar-list-item {
53
- min-height: 24px;
53
+ border-radius: 8px;
54
+ height: 36px;
55
+ width: min-content;
56
+ padding: 6px 10px;
54
57
}
55
- & .sidebar-list-item-icon {
56
- max-width: 18px;
57
- min-width: 18px;
58
+ & .sidebar-list-item-hover-icon {
59
+ display: none;
58
60
}
59
- & a:hover {
60
- .sidebar-list-item-title {
61
- text-decoration: underline !important;
62
- text-decoration-color: #000 !important;
63
- text-decoration-thickness: 2px !important;
64
- text-underline-offset: 2px !important;
61
+ & .sidebar-list-item:hover {
62
+ background-color: #f0f0f0;
63
+ .sidebar-list-item-hover-icon {
64
+ display: block;
65
65
}
66
66
}
67
+ & .sidebar-list-item-title {
68
+ font-size: 0.875rem;
69
+ }
67
70
"""
68
71
),
69
- gui .div (className = "d-flex align-items-center" ),
72
+ gui .div (),
70
73
):
71
- with gui .div (className = "d-flex align-items-center w-100" ):
72
- with gui .tag (
73
- "a" ,
74
- href = url ,
75
- className = "d-flex align-items-center sidebar-list-item w-100" ,
76
- ):
74
+ link_classes = "d-block sidebar-list-item ms-2"
75
+ if is_sidebar_open :
76
+ link_classes += " d-flex align-items-baseline justify-content-between w-100"
77
+ with gui .tag (
78
+ "a" ,
79
+ href = url ,
80
+ className = link_classes ,
81
+ ):
82
+ with gui .div (className = "d-flex align-items-baseline" ):
83
+ icon_classes = "d-block sidebar-list-item-icon"
84
+ if is_sidebar_open :
85
+ icon_classes += " me-2"
86
+
77
87
if icon :
78
88
gui .html (
79
89
icon ,
80
- className = "sidebar-list-item-icon me-2 d-flex justify-content-center" ,
90
+ className = icon_classes ,
81
91
)
82
92
if is_sidebar_open :
83
93
gui .html (title , className = "sidebar-list-item-title d-block" )
84
94
95
+ if hover_icon :
96
+ with gui .div (className = "sidebar-list-item-hover-icon" ):
97
+ gui .html (hover_icon , className = "text-secondary" )
98
+
85
99
86
100
def sidebar_item_list (is_sidebar_open ):
87
101
for i , (url , label , icon ) in enumerate (settings .SIDEBAR_LINKS ):
88
- if not is_sidebar_open and i >= 1 :
89
- break
90
102
if icon :
91
103
with gui .div ():
92
- sidebar_list_item (icon , label , is_sidebar_open , url )
104
+ sidebar_list_item (
105
+ icon , label , is_sidebar_open , url , icons .arrow_up_right
106
+ )
93
107
else :
94
108
with gui .div (
95
109
className = "d-inline-block me-2 small" ,
@@ -99,28 +113,34 @@ def sidebar_item_list(is_sidebar_open):
99
113
100
114
101
115
def render_default_sidebar (session : dict ):
102
- is_sidebar_open = session . get ("main-sidebar" , True )
116
+ is_sidebar_open = use_sidebar ("main-sidebar" , session , default_open = True ). is_open
103
117
with gui .div (
104
- className = "d-flex flex-column flex-grow-1 gap-3 px-3 my-3 text-nowrap" ,
105
- style = {"marginLeft" : "4px" },
118
+ className = f"d-flex flex-column flex-grow-1 { 'pe-3' if is_sidebar_open else '' } my-3 text-nowrap" ,
106
119
):
107
- with gui .div (className = "pe-2 " ):
120
+ with gui .div (className = "mb-4 " ):
108
121
sidebar_list_item (
109
122
"<i class='fa-regular fa-floppy-disk'></i>" ,
110
123
"Saved" ,
111
124
is_sidebar_open ,
112
- "/saved/" ,
125
+ "/account/saved/" ,
126
+ )
127
+ sidebar_list_item (
128
+ icons .search ,
129
+ "Explore" ,
130
+ is_sidebar_open ,
131
+ "/explore/" ,
113
132
)
114
133
115
- sidebar_item_list (is_sidebar_open )
134
+ if is_sidebar_open :
135
+ sidebar_item_list (is_sidebar_open )
116
136
117
137
118
138
def sidebar_logo_header (session : dict ):
119
139
with gui .div (
120
140
className = "d-flex align-items-center justify-content-between d-md-none me-2 w-100 py-2" ,
121
- style = {"height" : "64px " },
141
+ style = {"height" : "54px " },
122
142
):
123
- sidebar_ref = use_sidebar ("main-sidebar" , session , default_open = True )
143
+ sidebar_ref = use_sidebar ("main-sidebar" , session )
124
144
gui .tag (
125
145
"img" ,
126
146
src = settings .GOOEY_LOGO_FACE ,
@@ -133,64 +153,80 @@ def sidebar_logo_header(session: dict):
133
153
className = "m-0" ,
134
154
unsafe_allow_html = True ,
135
155
type = "tertiary" ,
156
+ style = {"padding" : "6px 10px" },
136
157
)
137
158
if open_mobile_sidebar :
138
159
sidebar_ref .set_mobile_open (True )
139
160
raise gui .RerunException ()
140
161
141
162
163
+ # Sidebar width variables
164
+ sidebar_open_width = "245px"
165
+ sidebar_closed_width = "53px"
166
+ sidebar_mobile_width = "80vw"
167
+
168
+
142
169
def sidebar_layout (sidebar_ref : SidebarRef ):
143
170
is_mobile_open = sidebar_ref .is_mobile_open
144
171
sidebar_funtion_classes = (
145
172
"gooey-sidebar-open" if sidebar_ref .is_open else "gooey-sidebar-closed"
146
173
)
174
+
147
175
side_bar_styles = dedent (
148
- """
149
- html {
176
+ f """
177
+ html {{
150
178
/* override margin-left from app.css */
151
179
margin-left: 0 !important;
152
- }
180
+ }}
181
+ & .gooey-btn {{
182
+ padding: 6px 10px !important;
183
+ }}
184
+ & .gooey-btn:hover {{
185
+ background-color: #f0f0f0 !important;
186
+ }}
153
187
154
- & .gooey-sidebar {
188
+ & .gooey-sidebar {{
155
189
transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
156
190
background-color: #f9f9f9;
157
191
position: sticky;
158
192
top: 0;
159
193
left: 0;
160
194
bottom: 0;
161
195
z-index: 999;
162
- }
163
- & .gooey-sidebar-open {
164
- min-width: 250px;
165
- width: 250px;
166
- max-width: 250px;
167
- }
168
- & .gooey-sidebar-closed {
169
- min-width: 60px;
170
- width: 60px;
171
- max-width: 60px;
172
- }
196
+ border-right: 1px solid #e0e0e0;
197
+ }}
198
+
199
+ & .gooey-sidebar-open {{
200
+ min-width: { sidebar_open_width } ;
201
+ width: { sidebar_open_width } ;
202
+ max-width: { sidebar_open_width } ;
203
+ }}
204
+ & .gooey-sidebar-closed {{
205
+ min-width: { sidebar_closed_width } ;
206
+ width: { sidebar_closed_width } ;
207
+ max-width: { sidebar_closed_width } ;
208
+ }}
173
209
174
- & .gooey-sidebar-closed:hover {
210
+ & .gooey-sidebar-closed:hover {{
175
211
cursor: e-resize;
176
- }
212
+ }}
177
213
178
- @media (max-width: 767px) {
179
- & .gooey-sidebar-open {
214
+ @media (max-width: 767px) {{
215
+ & .gooey-sidebar-open {{
180
216
position: fixed;
181
- min-width: 100vw ;
182
- width: 100vw ;
183
- max-width: 100vw ;
217
+ min-width: { sidebar_mobile_width } ;
218
+ width: { sidebar_mobile_width } ;
219
+ max-width: { sidebar_mobile_width } ;
184
220
z-index: 2000;
185
- }
186
- & .gooey-sidebar-closed {
221
+ }}
222
+ & .gooey-sidebar-closed {{
187
223
position: fixed;
188
224
min-width: 0px;
189
225
width: 0px;
190
226
max-width: 0px;
191
227
overflow: hidden;
192
- }
193
- }
228
+ }}
229
+ }}
194
230
"""
195
231
)
196
232
if not is_mobile_open :
0 commit comments