Skip to content

Commit

Permalink
remove un-necessary divs
Browse files Browse the repository at this point in the history
vertically centered share/save buttons
fix author breadcrumb inconsistent spacing
  • Loading branch information
devxpy committed Nov 15, 2024
1 parent 380a77c commit c95bf50
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
51 changes: 23 additions & 28 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,29 +367,24 @@ def _render_header(self):
can_save = self.can_user_save_run(sr, pr)
request_changed = self._has_request_changed()

with gui.div(className="d-flex justify-content-between align-items-start mt-4"):
left, right = gui.div(), gui.div()

with left:
if tbreadcrumbs.has_breadcrumbs():
with gui.div(
className="d-block d-lg-flex align-items-center pt-2 mb-2"
):
with gui.div(className="me-3 mb-1 mb-lg-0"):
render_breadcrumbs(
tbreadcrumbs,
is_api_call=(
sr.is_api_call and self.tab == RecipeTabs.run
),
)

self._render_author_as_breadcrumb(
is_example=is_example, is_root_example=is_root_example
with gui.div(className="d-flex justify-content-between align-items-start mt-3"):
if tbreadcrumbs.has_breadcrumbs():
with gui.div(
className="d-block d-lg-flex align-items-center pt-2 mb-2"
):
with gui.div(className="me-3 mb-1 mb-lg-0"):
render_breadcrumbs(
tbreadcrumbs,
is_api_call=(sr.is_api_call and self.tab == RecipeTabs.run),
)
else:
self._render_title(tbreadcrumbs.h1_title)

with right, gui.div(className="d-flex align-items-center"):
self._render_author_as_breadcrumb(
is_example=is_example, is_root_example=is_root_example
)
else:
self._render_title(tbreadcrumbs.h1_title)

with gui.div(className="d-flex align-items-center my-auto"):
if request_changed or (can_save and not is_example):
self._render_unpublished_changes_indicator()
self.render_social_buttons()
Expand All @@ -414,21 +409,21 @@ def _render_author_as_breadcrumb(self, *, is_example: bool, is_root_example: boo
if not workspace:
return

with gui.breadcrumbs(divider=""):
with gui.tag("li", className="breadcrumb-item"):
with gui.div(
className="d-flex gap-2 align-items-center", style=dict(listStyle="none")
):
with gui.tag("li"):
self.render_workspace_author(workspace)

# don't render the user's name for examples and personal workspaces
if is_example or workspace.is_personal:
return

gui.html(icons.chevron_right)

with gui.tag(
"li",
className="breadcrumb-item d-flex align-items-center container-margin-reset",
"li", className="d-flex align-items-center container-margin-reset"
):
with gui.tag("small", className="text-muted pe-2"):
gui.html(icons.chevron_right)

if user := self.current_sr_user:
full_name = user.full_name()
link = user.handle and user.handle.get_app_url()
Expand Down
13 changes: 3 additions & 10 deletions daras_ai_v2/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,10 @@ def render_breadcrumbs(breadcrumbs: TitleBreadCrumbs, *, is_api_call: bool = Fal
"""
<style>
@media (min-width: 1024px) {
.breadcrumb-item-large {
.fs-lg-5 {
font-size: 1.25rem !important;
}
}
@media (max-width: 1024px) {
.breadcrumb-item-large {
font-size: 0.85rem !important;
padding-top: 6px;
}
}
</style>
"""
)
Expand All @@ -60,13 +53,13 @@ def render_breadcrumbs(breadcrumbs: TitleBreadCrumbs, *, is_api_call: bool = Fal
gui.breadcrumb_item(
breadcrumbs.root_title.title,
link_to=breadcrumbs.root_title.url,
className="text-muted breadcrumb-item-large",
className="text-muted fs-lg-5",
)
if breadcrumbs.published_title:
gui.breadcrumb_item(
breadcrumbs.published_title.title,
link_to=breadcrumbs.published_title.url,
className="breadcrumb-item-large",
className="fs-lg-5",
)

if is_api_call:
Expand Down
2 changes: 1 addition & 1 deletion daras_ai_v2/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
notes = '<i class="fa-regular fa-money-check-pen"></i>'
lock = '<i class="fa-solid fa-lock"></i>'
globe = '<i class="fa-regular fa-globe"></i>'
chevron_right = '<i class="fa-solid fa-chevron-right"></i>'
chevron_right = '<i class="fa-sharp-duotone fa-solid fa-sm fa-chevron-right"></i>'

# brands
github = '<i class="fa-brands fa-github"></i>'
Expand Down

0 comments on commit c95bf50

Please sign in to comment.