Skip to content

Commit

Permalink
Merge pull request #34 from SADiLaR/feature/aria_current_page
Browse files Browse the repository at this point in the history
Aria-current page for active pages
  • Loading branch information
OnaMosimege authored Apr 25, 2024
2 parents 13a9297 + 487deb1 commit 23e354e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def health(request):

def home(request):
template = "app/home.html"
context = {"home_page": "active"}
context = {"current_page": "home"}

return render(request, template_name=template, context=context)

Expand All @@ -22,14 +22,14 @@ def institutions(request):
template = "app/institutions.html"

institutions = Institution.objects.all().order_by("name").values()
context = {"institutions_page": "active", "institutions": institutions}
context = {"current_page": "institutions", "institutions": institutions}

return render(request, template_name=template, context=context)


def search(request):
template = "app/search.html"
context = {"search_page": "active"}
context = {"current_page": "search"}

return render(request, template_name=template, context=context)

Expand Down
2 changes: 1 addition & 1 deletion app/general/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Meta:

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# If the instance has a mime_type, the field should be disabled
if not self.instance.mime_type:
self.fields["mime_type"].widget = HiddenInput()
Expand Down
15 changes: 12 additions & 3 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@
<div class="nav-menu">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link {{ home_page }}" aria-current="page" href="{% url 'home' %}">Home</a>
<a
{% if current_page == 'home' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'home' %}">Home
</a>
</li>
<li class="nav-item">
<a class="nav-link {{ search_page }}" aria-current="page" href="{% url 'search' %}">Search</a>
<a
{% if current_page == 'search' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'search' %}">Search
</a>
</li>
<li class="nav-item">
<a class="nav-link {{ institutions_page }}" href="{% url 'institutions' %}">Institutions</a>
<a
{% if current_page == 'institutions' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'institutions' %}">Institutions
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'admin:index' %}">Admin</a>
Expand Down

0 comments on commit 23e354e

Please sign in to comment.