Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Save space in Navbar by using dropdown menus #59

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/screenshots/pipelines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/streams.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions web/static/js/materialize.min.js

This file was deleted.

12,376 changes: 12,376 additions & 0 deletions web/static/js/materialize.patched.js

Large diffs are not rendered by default.

109 changes: 65 additions & 44 deletions web/templates/components/navbar.templ
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,57 @@ type NavbarProps struct {
}

templ Navbar(props NavbarProps) {
<ul id="nav-dropdown-user" class="dropdown-content">
@navbarItem(navbarItemProps{
Icon: "account_circle",
Label: "Account",
Link: "/web/account",
Active: props.CurrentNav == "account",
})
if props.Permissions.CanViewACLs {
@navbarItem(navbarItemProps{
Icon: "dashboard",
Label: "Admin",
Link: "/web/admin",
Active: props.CurrentNav == "admin",
})
}
<li class="divider"></li>
@navbarItem(navbarItemProps{
Icon: "exit_to_app",
Label: "Logout",
Link: "/auth/logout",
Active: false,
})
</ul>

<ul id="nav-dropdown-settings" class="dropdown-content">
if props.Permissions.CanViewTransformers {
@navbarItem(navbarItemProps{
Icon: "filter_alt",
Label: "Transformers",
Link: "/web/transformers",
Active: props.CurrentNav == "transformers",
})
}
if props.Permissions.CanViewPipelines {
@navbarItem(navbarItemProps{
Icon: "settings",
Label: "Pipelines",
Link: "/web/pipelines",
Active: props.CurrentNav == "pipelines",
})
}
if props.Permissions.CanViewStreams {
@navbarItem(navbarItemProps{
Icon: "sd_storage",
Label: "Storage",
Link: "/web/storage",
Active: props.CurrentNav == "storage",
})
}
</ul>

<nav class="blue darken-3" style="z-index: 900;">
<div class="nav-wrapper flex flex-row items-center">
<ul>
Expand Down Expand Up @@ -63,50 +114,20 @@ templ Navbar(props NavbarProps) {
Active: props.CurrentNav == "streams",
})
}
if props.Permissions.CanViewTransformers {
@navbarItem(navbarItemProps{
Icon: "filter_alt",
Label: "Transformers",
Link: "/web/transformers",
Active: props.CurrentNav == "transformers",
})
}
if props.Permissions.CanViewPipelines {
@navbarItem(navbarItemProps{
Icon: "settings",
Label: "Pipelines",
Link: "/web/pipelines",
Active: props.CurrentNav == "pipelines",
})
}
if props.Permissions.CanViewStreams {
@navbarItem(navbarItemProps{
Icon: "sd_storage",
Label: "Storage",
Link: "/web/storage",
Active: props.CurrentNav == "storage",
})
}
if props.Permissions.CanViewACLs {
@navbarItem(navbarItemProps{
Icon: "dashboard",
Label: "Admin",
Link: "/web/admin",
Active: props.CurrentNav == "admin",
})
}
@navbarItem(navbarItemProps{
Icon: "account_circle",
Label: "Account",
Link: "/web/account",
Active: props.CurrentNav == "account",
})
@navbarItem(navbarItemProps{
Icon: "exit_to_app",
Label: "Logout",
Link: "/auth/logout",
Active: false,
})
<li>
<a class="dropdown-trigger" href="#" data-target="nav-dropdown-settings">
<i class="left material-icons">settings</i>
Settings
<i class="right material-icons">arrow_drop_down</i>
</a>
</li>
<li>
<a class="dropdown-trigger" href="#" data-target="nav-dropdown-user">
<i class="left material-icons">account_circle</i>
{ auth.GetContextUser(ctx).Name }
<i class="right material-icons">arrow_drop_down</i>
</a>
</li>
</ul>
</div>
</nav>
Expand Down
73 changes: 49 additions & 24 deletions web/templates/components/navbar_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions web/templates/layouts/base.templ
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ templ Base(props BaseProps) {
<link rel="stylesheet" href="/static/css/materialize.min.css" />
<link rel="stylesheet" href="/static/css/utilities.css" />

<script type="application/javascript" src="/static/js/materialize.min.js"></script>
<script type="application/javascript" src="/static/js/materialize.patched.js"></script>
<script type="application/javascript" src="/static/js/htmx.min.js"></script>

<script type="application/javascript">
document.addEventListener('htmx:load', (event) => {
M.AutoInit(event.detail.elt)
M.AutoInit(event.detail.elt, {
Dropdown: {
constrainWidth: false,
}
})
})
</script>

Expand Down
4 changes: 2 additions & 2 deletions web/templates/layouts/base_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.