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

add NavDivider for non-selectable menu entries #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lona_picocss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
get_django_auth_navigation,
get_debug_navigation,
NavItem,
NavDivider,
)

from lona_picocss.views.error_views import (
Expand Down
5 changes: 5 additions & 0 deletions lona_picocss/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class NavItem:
icon: str = ''
nav_items: list[NavItem] = field(default_factory=list)

@dataclass
class NavDivider:
title: str = ''
icon: str = ''
divider: bool = True

def get_debug_navigation(server, request):
return [
Expand Down
4 changes: 4 additions & 0 deletions lona_picocss/static/lona-picocss/lona-picocss.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ header#lona-header summary svg {
}
}

li[role=divider] {
background-color: var(--form-element-disabled-background-color);
}

/* auth -------------------------------------------------------------------- */
.auth-form dialog article {
min-width: 30em;
Expand Down
8 changes: 6 additions & 2 deletions lona_picocss/templates/picocss/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
<summary aria-haspopup="listbox" role="link">{% if nav_item.icon %}<i data-feather="{{ nav_item.icon }}"></i>{% endif %}{{ nav_item.title }}</summary>
<ul role="listbox">
{% for sub_nav_item in nav_item.nav_items %}
<li>
<a href="{{ sub_nav_item.url }}">{% if sub_nav_item.icon %}<i data-feather="{{ sub_nav_item.icon }}"></i>{% endif %}{{ sub_nav_item.title }}</a>
<li{% if sub_nav_item.divider %} role="divider"{% endif %}>
{% if sub_nav_item.divider %}
{% if sub_nav_item.icon %}<i data-feather="{{ sub_nav_item.icon }}"></i>{% endif %}{{ sub_nav_item.title }}
{% else %}
<a href="{{ sub_nav_item.url }}">{% if sub_nav_item.icon %}<i data-feather="{{ sub_nav_item.icon }}"></i>{% endif %}{{ sub_nav_item.title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
Expand Down