Skip to content

Commit 79e776a

Browse files
committed
change circular button for bot builder
1 parent ead2b18 commit 79e776a

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

daras_ai_v2/base.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def render_sidebar(self):
419419
return
420420

421421
sidebar_ref = use_sidebar("builder-sidebar", self.request.session)
422-
if sidebar_ref.is_open:
422+
if sidebar_ref.is_open or sidebar_ref.is_mobile_open:
423423
gui.tag(
424424
"button",
425425
type="submit",
@@ -436,14 +436,35 @@ def render_sidebar(self):
436436
with gui.div(className="w-100 h-100"):
437437
self._render_gooey_builder()
438438
else:
439-
with gui.div(
440-
className="w-100 position-absolute",
441-
style={"bottom": "10px", "left": "10px"},
442-
):
443-
gooey_builder_open_button = gui.button(
444-
label="<i class='fa-regular fa-message-smile'></i> Chat Assistant",
445-
className="btn btn-secondary rounded-pill",
446-
)
439+
with gui.styled("& .gooey-builder-open-button:hover { scale: 1.2; }"):
440+
with gui.div(
441+
className="w-100 position-absolute",
442+
style={"bottom": "10px", "left": "10px", "z-index": "1000"},
443+
):
444+
gooey_builder_open_button = gui.button(
445+
label="<img src='https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/63bdb560-b891-11f0-b9bc-02420a00014a/generate-ai-abstract-symbol-artificial-intelligence-colorful-stars-icon-vector%201.jpg' style='width: 48px; height: 48px; border-radius: 50%;' />",
446+
className="btn btn-secondary border-0 d-none d-lg-block p-0 gooey-builder-open-button",
447+
style={
448+
"width": "48px",
449+
"height": "48px",
450+
"borderRadius": "50%",
451+
"boxShadow": "#0000001a 0 1px 4px, #0003 0 2px 12px",
452+
},
453+
)
454+
gooey_builder_mobile_open_button = gui.button(
455+
label="<img src='https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/63bdb560-b891-11f0-b9bc-02420a00014a/generate-ai-abstract-symbol-artificial-intelligence-colorful-stars-icon-vector%201.jpg' style='width: 48px; height: 48px; border-radius: 50%;' />",
456+
className="border-0 btn btn-secondary rounded-pill d-lg-none gooey-builder-open-button p-0",
457+
style={
458+
"width": "48px",
459+
"height": "48px",
460+
"borderRadius": "50%",
461+
"boxShadow": "#0000001a 0 1px 4px, #0003 0 2px 12px",
462+
},
463+
)
464+
if gooey_builder_mobile_open_button:
465+
sidebar_ref.set_mobile_open(True)
466+
raise gui.RerunException()
467+
447468
if gooey_builder_open_button:
448469
sidebar_ref.set_open(True)
449470
raise gui.RerunException()
@@ -1252,6 +1273,7 @@ def _render_gooey_builder(self):
12521273
if not self.is_current_user_admin():
12531274
return
12541275
render_gooey_builder_inline(self.slug_versions[-1], gui.session_state)
1276+
12551277
# render_gooey_builder(
12561278
# page_slug=self.slug_versions[-1],
12571279
# builder_state=dict(

widgets/sidebar.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def set_open(self, value: bool):
2323

2424
def set_mobile_open(self, value: bool):
2525
self.is_mobile_open = self.session[self.mobile_key] = value
26-
self.set_open(value)
26+
# self.set_open(value)
2727

2828
@property
2929
def mobile_key(self):
@@ -204,13 +204,15 @@ def sidebar_mobile_header(request: Request):
204204
# Sidebar width variables
205205
sidebar_open_width = "340px"
206206
sidebar_closed_width = "0px"
207-
sidebar_mobile_width = "80vw"
207+
sidebar_mobile_width = "100vw"
208208

209209

210210
def sidebar_layout(sidebar_ref: SidebarRef):
211211
is_mobile_open = sidebar_ref.is_mobile_open
212212
sidebar_funtion_classes = (
213-
"gooey-sidebar-open" if sidebar_ref.is_open else "gooey-sidebar-closed"
213+
"gooey-sidebar-open"
214+
if sidebar_ref.is_open or sidebar_ref.is_mobile_open
215+
else "gooey-sidebar-closed"
214216
)
215217

216218
side_bar_styles = dedent(
@@ -227,7 +229,6 @@ def sidebar_layout(sidebar_ref: SidebarRef):
227229
}}
228230
229231
& .gooey-sidebar {{
230-
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);
231232
background-color: #f9f9f9;
232233
position: sticky;
233234
top: 0;
@@ -255,8 +256,7 @@ def sidebar_layout(sidebar_ref: SidebarRef):
255256
@media (max-width: 767px) {{
256257
& .gooey-sidebar-open {{
257258
position: fixed;
258-
right: 0;
259-
left: auto;
259+
left: 0;
260260
min-width: {sidebar_mobile_width};
261261
width: {sidebar_mobile_width};
262262
max-width: {sidebar_mobile_width};
@@ -265,13 +265,13 @@ def sidebar_layout(sidebar_ref: SidebarRef):
265265
border-right: none;
266266
}}
267267
& .gooey-sidebar-closed {{
268-
position: fixed;
268+
position: sticky;
269269
right: 0;
270270
left: auto;
271271
min-width: 0px;
272272
width: 0px;
273273
max-width: 0px;
274-
overflow: hidden;
274+
overflow: visible;
275275
}}
276276
}}
277277
"""

0 commit comments

Comments
 (0)