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

Accessibility on menu and page structure #187

Open
wants to merge 1 commit into
base: develop
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jQuery(document).ready(function($){
$(this).toggleClass('active');
$('#overlay').toggleClass('open');
$('body').toggleClass('mobile-nav-open');
// accessible toggle
var state = $('#toggle').attr('aria-expanded');
state == 'true' ? $('#toggle').attr('aria-expanded','false') : $('#toggle').attr('aria-expanded','true');
});

// Tree Menu
Expand Down
11 changes: 9 additions & 2 deletions scss/theme/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@
content: '';
}
}
&:focus + ul {
display: block;
visibility: visible;
opacity: 1;
transform: translateY(0);
}

}

&:hover {
&:hover, &:focus-within {
& > ul {
display: block;
visibility: visible;
Expand Down Expand Up @@ -91,4 +98,4 @@
transform: translateY(-10px);
}
}
}
}
10 changes: 7 additions & 3 deletions templates/macros/macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
{% for p in page.children.visible %}
{% set active_page = (p.active or p.activeChild) ? 'active' : '' %}
<li>
<a href="{{ p.url }}" class="{{ active_page }}">
{% if p.children.visible.count > 0 %}
<a tabindex="0" role="button" class="{{ active_page }}" {%if p.active %}aria-current="page"{% endif %}>
{{ p.menu }}
</a>
{% if p.children.visible.count > 0 %}
<ul>
{{ macros.nav_loop(p) }}
</ul>
{% else %}
<a href="{{ p.url }}" class="{{ active_page }}" {%if p.active %}aria-current="page"{% endif %}>
{{ p.menu }}
</a>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% endmacro %}
30 changes: 15 additions & 15 deletions templates/partials/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@
<body id="top" class="{% block body_classes %}{{ body_classes }}{% endblock %}">
<div id="page-wrapper">
{% block header %}
<section id="header" class="section">
<section class="container {{ grid_size }}">
<div id="header" class="section">
<div class="container {{ grid_size }}">
<nav class="navbar">
<section class="navbar-section logo">
<div class="navbar-section logo">
{% include 'partials/logo.html.twig' %}
</section>
<section class="navbar-section desktop-menu">
</div>
<div class="navbar-section desktop-menu">

<nav class="dropmenu animated">
<div class="dropmenu animated">
{% block header_navigation %}
{% include 'partials/navigation.html.twig' %}
{% endblock %}
</nav>
</div>

{% if config.plugins.login.enabled and grav.user.username %}
<span class="login-status-wrapper"><i class="fa fa-user"></i> {% include 'partials/login-status.html.twig' %}</span>
{% endif %}

</section>
</div>
</nav>
</section>
</section>
</div>
</div>
<div class="mobile-menu">
<div class="button_container" id="toggle">
<div class="button_container" id="toggle" aria-expanded="false" aria-controls="overlay">
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
Expand All @@ -73,18 +73,18 @@

{% block hero %}{% endblock %}

<section id="start">
<main id="start">
{% block body %}
<section id="body-wrapper" class="section">
<section class="container {{ grid_size }}">
<div class="container {{ grid_size }}">
{% block messages %}
{% include 'partials/messages.html.twig' ignore missing %}
{% endblock %}
{{ block('content_surround') }}
</section>
</div>
</section>
{% endblock %}
</section>
</main>

</div>

Expand Down