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 active states to top-level nav menu items #909

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
2 changes: 1 addition & 1 deletion bookmarks/styles/theme-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
--btn-error-text-color: var(--contrast-text-color);

--btn-link-text-color: var(--link-color);
--btn-link-hover-text-color: var(--link-color);
--btn-link-hover-text-color: var(--secondary-link-color);
}

:root {
Expand Down
12 changes: 9 additions & 3 deletions bookmarks/styles/theme/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
--btn-error-text-color: var(--contrast-text-color);

--btn-link-text-color: var(--link-color);
--btn-link-hover-text-color: var(--link-color);
--btn-link-hover-text-color: var(--secondary-link-color);
}

.btn {
Expand Down Expand Up @@ -135,10 +135,16 @@

&:focus,
&:hover,
&:active,
&.active {
&:active {
text-decoration: none;
}

&.active {
text-decoration: underline;
text-decoration-color: var(--btn-link-text-color);
text-decoration-thickness: 2px;
text-underline-offset: 0.5em;
}
}

/* Button Sizes */
Expand Down
6 changes: 3 additions & 3 deletions bookmarks/templates/bookmarks/nav_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class="hide-md">
<a href="{% url 'bookmarks:new' %}" class="btn btn-primary mr-2">Add bookmark</a>
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" tabindex="0">
<button class="btn btn-link dropdown-toggle {% if request.path|starts_with:'/bookmarks' and not request.path|starts_with:'/bookmarks/new' %}active{% endif %}" tabindex="0">
Bookmarks
</button>
<ul class="menu">
<li class="menu-item">
<li class="menu-item ">
<a href="{% url 'bookmarks:index' %}" class="menu-link">Active</a>
</li>
<li class="menu-item">
Expand All @@ -27,7 +27,7 @@
</li>
</ul>
</div>
<a href="{% url 'bookmarks:settings.index' %}" class="btn btn-link">Settings</a>
<a href="{% url 'bookmarks:settings.index' %}" class="btn btn-link {% if request.path|starts_with:"/settings" %}active{% endif %}">Settings</a>
<form class="d-inline" action="{% url 'logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="btn btn-link">Logout</button>
Expand Down
5 changes: 5 additions & 0 deletions bookmarks/templatetags/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def hash_tag(tag_name):
return "#" + tag_name


@register.filter(name="starts_with")
def starts_with(text, prefix):
return text.startswith(prefix)


@register.filter(name="first_char")
def first_char(text):
return text[0]
Expand Down