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

new navigation #716

Merged
merged 18 commits into from
Feb 19, 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
6 changes: 6 additions & 0 deletions froide/account/templates/account/includes/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% load i18n %}
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'account-show' %}">{% translate "Account" %}</a>
</li>
Expand Down
6 changes: 6 additions & 0 deletions froide/foirequest/templates/foirequest/header/breadcrumb.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% load i18n %}
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
{% if object.user == request.user %}
<a href="{% url 'account-show' %}">{% trans "My requests" %}</a>
Expand Down
1 change: 0 additions & 1 deletion froide/helper/templates/helper/search/multi_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<button type="submit"
class="btn btn-outline-primary text-nowrap{% if small %} btn-sm{% endif %}">
<i class="fa fa-search"></i>
<span class="visually-hidden">{% trans "Search" %}</span>
<span class="d-md-none d-lg-inline" aria-hidden="true">{% trans "Search" %}</span>
</button>
</div>
Expand Down
31 changes: 31 additions & 0 deletions froide/helper/templatetags/breadcrumb_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django import template
from django.urls import NoReverseMatch, reverse

register = template.Library()


def normalize_breadcrumb(breadcrumb):
if type(breadcrumb) == tuple:
if type(breadcrumb[1]) == str:
try:
breadcrumb = (breadcrumb[0], reverse(breadcrumb[1]))
except NoReverseMatch:
pass

return breadcrumb
else:
return (breadcrumb, None)


@register.simple_tag(takes_context=True)
def get_breadcrumbs(context, view=None):
if hasattr(view, "get_breadcrumbs") and callable(view.get_breadcrumbs):
view.get_breadcrumbs(context)

if hasattr(view, "breadcrumbs"):
return map(normalize_breadcrumb, view.breadcrumbs)


@register.filter
def has_link(value):
return type(value) == tuple and len(value) == 2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'organization-list' %}">{% trans "Organizations" %}</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<div class="bg-body-tertiary">
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'organization-list' %}">{% trans "Organizations" %}</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<div class="bg-body-tertiary">
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'organization-list' %}">{% trans "Organizations" %}</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<div class="bg-body-tertiary">
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/">
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'organization-list' %}">{% trans "Organizations" %}</a>
</li>
Expand Down
64 changes: 37 additions & 27 deletions froide/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,44 @@
{% load i18n %}
{% load static %}
{% load frontendbuild %}

{% block body_tag %}
{% if request.user.is_authenticated and request.session.impostor %}
{% include "account/includes/impostor.html" %}
{% endif %}
{% block top_block %}{% endblock %}
{% block navbar %}
{% include "header.html" %}
{% endblock %}
{% block body_wrapper %}
<main class="main">
{% block index_banner %}{% endblock %}
{% block foisite_advice %}{% endblock %}
{% block messages %}
{% include "snippets/messages.html" %}
{% endblock messages %}
{% block body %}
<div class="container mb-5 mt-3">
{% block app_body %}{% endblock %}
</div>
{% endblock %}
</main>
{% endblock %}
{% block footer_container %}
{% include "footer.html" %}
{% endblock %}
{% if request.user.is_authenticated and request.session.impostor %}
{% include "account/includes/impostor.html" %}
{% endif %}

{% block top_block %}{% endblock %}

{% block navbar %}
{% include "header.html" %}
{% endblock %}

{% include "snippets/breadcrumbs.html" %}

{% block body_wrapper %}
<main class="main">
{% block index_banner %}{% endblock %}
{% block foisite_advice %}{% endblock %}

{% block messages %}
{% include "snippets/messages.html" %}
{% endblock messages %}

{% block body %}
<div class="container mb-5 mt-3">
{% block app_body %}{% endblock %}
</div>
{% endblock %}
</main>
{% endblock %}

{% block footer_container %}
{% include "footer.html" %}
{% endblock %}
{% endblock body_tag %}

{% block scripts %}
{% renderfrontendhmr %}
{% addfrontendbuild "main.js" %}
{{ block.super }}
{% renderfrontendhmr %}
{% addfrontendbuild "main.js" %}
{{ block.super }}
{% endblock %}
1 change: 1 addition & 0 deletions froide/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{% get_menu_items as menu_items %}
{% endif %}
<header id="header">
<a href="#main" class="visually-hidden-focusable skippy">{% trans "Skip to main content" %}</a>
<nav class="navbar navbar-secondary navbar-expand-md navbar-light justify-content-between {% block navbar-class %}{% endblock %}">
<div class="container">
{% block nav_brand %}
Expand Down
6 changes: 5 additions & 1 deletion froide/templates/simple_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
{% load i18n %}
{% load static %}
{% load frontendbuild %}

{% block body_tag %}
<main class="main">
<main class="main" id="main">
{% include "snippets/messages.html" %}

{% block body %}
<div class="container">
{% block app_body %}{% endblock %}
</div>
{% endblock %}
</main>

{% block extra_footer %}{% endblock %}
{% endblock body_tag %}

{% block scripts %}
{% addfrontendbuild "main.js" %}
{{ block.super }}
Expand Down
31 changes: 31 additions & 0 deletions froide/templates/snippets/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% load i18n %}
{% load breadcrumb_helper %}
{# Renders breadcrumbs that are defined in view #}
{% get_breadcrumbs view as breadcrumbs %}
{% if breadcrumbs != None %}
{% if breadcrumbs_background %}
<div class="text-bg-{{ breadcrumbs_background }}{% if overlay %} breadcrumb-overlay{% endif %}">
{% endif %}
<nav class="container-md" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
{# djlint:off D018 #}
<a href="/"> {# djlint:on #}
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
</li>
{% for breadcrumb in breadcrumbs %}
<li class="breadcrumb-item{% if forloop.last %} active{% endif %}">
{% if breadcrumb|has_link %}
<a href="{{ breadcrumb.1 }}"
{% if forloop.last %}aria-current="page"{% endif %}>{{ breadcrumb.0 }}</a>
{% else %}
{{ breadcrumb }}
{% endif %}
</li>
{% endfor %}
</ol>
</nav>
{% if breadcrumbs_background %}</div>{% endif %}
{% endif %}
1 change: 0 additions & 1 deletion frontend/javascript/snippets/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ document
])
const currentBase = firstPathSegment(window.location.pathname)
const bestMatch = searchBases.find((s) => s[0] === currentBase)?.[1]
console.log(bestMatch)

if (bestMatch !== undefined) {
form.action = bestMatch
Expand Down
30 changes: 21 additions & 9 deletions frontend/styles/components/breadcrumb.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
.breadcrumb {
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: $spacer * 0.5 0;
background-color: inherit;
overflow: hidden;
overflow: auto;
margin: 0;
gap: $spacer * 0.5;
scroll-snap-type: x;

&-item {
margin-right: $spacer * 0.5;
text-overflow: ellipsis;
overflow: hidden;
float: none;
white-space: nowrap;
scroll-snap-align: end;

& + .breadcrumb-item::before {
float: none;
color: inherit;
}

&,
> * {
color: var(--#{$prefix}tertiary-color);
font-size: small;
color: inherit;
font-size: $font-size-sm;
white-space: nowrap;
opacity: 0.9;

@include media-breakpoint-up(lg) {
font-size: $font-size-sm;
}
}

&:last-child {
margin-right: none;

&,
> * {
color: var(--#{$prefix}body-color);
color: inherit;
opacity: 1;
}
}
}

&-item + &-item {
padding-left: 0;
}
}

.breadcrumb-overlay {
margin-bottom: -2.3rem;
z-index: 40;
--#{$prefix}bg-opacity: 0.9;
}
3 changes: 3 additions & 0 deletions frontend/styles/components/dropdown.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dropdown-menu {
overflow: hidden; // for crisp edges
}
4 changes: 4 additions & 0 deletions frontend/styles/components/misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,7 @@ input.copy-text {
z-index: -1;
}
}

.skippy {
z-index: 1070;
}
Loading
Loading