Skip to content

Commit 10ab30b

Browse files
committed
Final edits to drop
1 parent 4028d4d commit 10ab30b

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

_includes/masthead.html

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<div class="masthead">
44
<div class="masthead__inner-wrap">
55
<div class="masthead__menu">
6-
<nav id="site-nav" class="nav__topbar" aria-label="Main Navigation">
6+
<nav id="site-nav" class="nav__topbar" aria-label="Top Bar">
77
<!-- More accessible as a screen reader will group the title and image in the same link -->
88
{% unless logo_path == empty %}
99
<a class="site-logo" href="{{ '/' | relative_url }}">
10-
<img src="{{ logo_path | relative_url }}" alt="{{ site.masthead_title | default: site.title }}">
10+
<img src="{{ logo_path | relative_url }}" alt="Welcome to the pyOpenSci website. This is the pyOpenSci logo.">
1111
<span class="site-title">pyOpenSci</span>
1212
</a>
1313
{% endunless %}
@@ -17,7 +17,7 @@
1717
{% if alink.sub-nav %}
1818
<!-- If there is sub nav to display -->
1919
<li class="dropdown">
20-
<button class="dropbtn" tabindex="0">{{ alink.title }} <i class="fas fa-caret-down"></i>
20+
<button class="dropbtn" tabindex="0" aria-expanded="false">{{ alink.title }} <i class="fas fa-caret-down"></i>
2121
</button>
2222
<ul class="dropdown-content">
2323
{% for subnav in alink.sub-nav %}
@@ -37,18 +37,20 @@
3737

3838
</li>
3939
</ul>
40+
<!--
4041
{% if site.search == true %}
4142
<button class="search__toggle" type="button">
4243
<span class="visually-hidden">{{ site.data.ui-text[site.locale].search_label | default: "Toggle search" }}</span>
4344
<i class="fas fa-search"></i>
4445
</button>
4546
{% endif %}
47+
-->
4648

4749

4850
<ul class="hidden-links hidden"></ul>
4951
<!-- Burger button - span class for screen readers-->
50-
<button class="hamburger__btn-toggle" type="button" count="1">
51-
<span class="visually-hidden">Toggle menu</span> <!--screen readers-->
52+
<button class="hamburger__btn-toggle" type="button" count="1" aria-expanded="false">
53+
<span class="visually-hidden">Toggle top navigation menu</span> <!--screen readers-->
5254
<div class="burger__icon"></div>
5355
</button>
5456
</nav>
@@ -58,27 +60,42 @@
5860

5961

6062
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
63+
64+
<!-- This works now but when you open the menu its not saying aria expanded or
65+
prompting the screen reader-->
6166
<script>
6267
$(document).ready(function () {
6368
$(".hamburger__btn-toggle").click(function (e) {
6469
$(this).toggleClass("close");
70+
// toggle expanded to try on click
71+
$(this).attr('aria-expanded', function (i, attr) {
72+
return attr == 'true' ? 'false' : 'true'});
73+
6574
e.preventDefault();
6675
$(".nav__links").toggleClass("vertical");
6776
});
6877

6978
$(".dropdown").click(function (e) {
70-
//e.stopPropagation();
71-
//e.preventDefault();
72-
// close when click outside
79+
// close when user clicks nav
7380
$(this).find(".dropdown-content").toggleClass("open");
81+
// Handle making sure other drop menus are "closed" when another is open
7482
$(this).siblings(".dropdown").find(".dropdown-content").removeClass("open");
83+
$(this).siblings(".dropdown").find(".dropbtn").attr("aria-expanded", "false");
84+
85+
// this works but if user clicks on another drop down it should also return to closed
86+
// with this code it just toggles the next thing that the user clicks so both
87+
// dropdowns are set to expanded:true
88+
$(this).find(".dropbtn").attr('aria-expanded', function (i, attr) {
89+
return attr == 'true' ? 'false' : 'true' });
7590
});
7691

7792
// Close dropdown when u click outside of the nav ul
7893
$(document).click(function (e) {
7994
if (!e.target.closest("ul") && $(".dropdown-content").hasClass("open")) {
8095
$(".dropdown-content").removeClass("open");
8196
}
97+
98+
8299
});
83100
});
84101

assets/css/main.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ parent text width */
223223
align-items: flex-start;
224224
padding-top: 2em;
225225
top: 70%;
226-
left: 60%;
227-
width: 40%;
226+
left: 40%;
227+
width: 60%;
228+
font-size: 1.2em;
228229
background-color: #fff;
229230
z-index: 1;
230231
border: 1px solid #f2f3f3;

0 commit comments

Comments
 (0)