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

initial mobile menu commit #508

Merged
merged 3 commits into from
Oct 18, 2023
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
10 changes: 9 additions & 1 deletion boulder_base.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,19 @@ ucb-people-list-block:
theme:
css/block/ucb-people-list-block.css: {}

ucb-menu:
version: 1.x
js:
js/ucb-menu.js: {}
js/ucb-access-menu.min.js: {}
css:
theme:
css/ucb-menu.css: {}
ucb-user-page:
version: 1.x
js:
js/ucb-status-page-block.js: {}
css:
theme:
css/ucb-status-page-block.css: {}
css/ucb-user-page.css: {}
css/ucb-user-page.css: {}
6 changes: 6 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@
align-items: center;
}

@media only screen and (max-width: 600px) {
.ucb-main-nav-continer {
flex-direction: column;
}
}

/*********** Main Menu **************/
ul.ucb-main-menu.nav {
flex-grow: 1;
Expand Down
9 changes: 9 additions & 0 deletions css/ucb-footer-menu-region.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@
color: var(--ucb-gold);
background-color: transparent;
}


@media only screen and (max-width: 600px) {
.ucb-footer-menu-region {
display: none;
}

}

100 changes: 100 additions & 0 deletions css/ucb-menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#example-toggle {
display: none;
}

.ucb-mobile-footer-menu {
display: none;
}

@media only screen and (max-width: 600px) {
.ucb-mobile-menu-button-div {
line-height: 2em;
}
.ucb-primary-menu-region .ucb-primary-menu-region-container,
.ucb-secondary-menu-region .ucb-secondary-menu-region-container {
padding-left: 0;
padding-right: 0;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-above {
flex-direction: column;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region .menu-item a {
color: black;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 16px;
line-height: 2rem;
margin-left: 2px;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region ≈, .ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region .ucb-menu {
gap: 0;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region {
background-color: white;
}
.ucb-secondary-menu-region {
width: 100%;
}
#example-toggle {
display: block;
max-width: 100px;
font-size: 2em;
margin-left: auto;
}
.ucb-menu,
.ucb-primary-menu-region {
width: 100%;
}
.ucb-menu.hide,
.ucb-main-menu.hide {
display: none;
}
.ucb-menu.open,
.ucb-main-menu.open {
display: flex;
flex-direction: column;
}
.ucb-menu .menu-item,
.main-menu-item {
border-bottom: 1px solid lightgrey;
}
.ucb-menu.open .menu-item a,
.ucb-main-menu.open .main-menu-item a {
font-weight: 300;
font-size: 16px;
padding-left: 16px;
border-bottom: 2px solid transparent;
}
.ucb-menu .menu-item.active,
.main-menu-item.active {
font-weight: 600;
color: #000;
background-color: #cfb87c;
border-bottom: 1px solid #cfb87c;
}
.ucb-menu.open .menu-item.active a,
.ucb-main-menu.open li.main-menu-item.active a {
border-bottom: 2px solid transparent;
}

.ucb-mobile-footer-menu {
display: flex;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-inline .ucb-secondary-menu-region .ucb-menu {
gap: 0;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region .menu-item a:hover,
.ucb-main-nav-continer.ucb-secondary-menu-position-inline .ucb-secondary-menu-region .menu-item a:hover {
border-bottom: 2px solid black;
color: black;
}

.ucb-main-nav-continer.ucb-secondary-menu-position-above .ucb-secondary-menu-region .menu-item:not(:active) a:hover,
.ucb-main-nav-continer.ucb-secondary-menu-position-inline .ucb-secondary-menu-region .menu-item:not(:active) a:hover {
background-color: white;
}
.ucb-main-nav-continer.ucb-secondary-menu-position-inline .ucb-secondary-menu-region .menu-item a {
margin: 0;
line-height: 2rem;
}
}
2 changes: 1 addition & 1 deletion css/ucb-secondary-menu-region.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.ucb-secondary-menu-region {
display: flex;
flex-direction: row;
flex-direction: column;
}

.ucb-secondary-menu-region .ucb-menu {
Expand Down
2 changes: 2 additions & 0 deletions js/ucb-access-menu.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions js/ucb-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

document.addEventListener("DOMContentLoaded", () => {
const mainMenu = new AccessibleMenu.DisclosureMenu({
menuElement: document.querySelector("#ucb-main-menu"),
controllerElement: document.querySelector("#example-toggle"),
containerElement: document.querySelector("#ucb-main-menu-nav"),
openClass: "open",
});
const secondaryWrapper = document.querySelector(".ucb-secondary-menu-region-container")
const secondaryMenu = new AccessibleMenu.DisclosureMenu({
menuElement: document.getElementById("ucb-secondary-menu-region-container").getElementsByClassName("ucb-menu")[0],
controllerElement: document.querySelector("#example-toggle"),
containerElement: secondaryWrapper,
openClass: "open",
});

const footerMenu = new AccessibleMenu.DisclosureMenu({
menuElement: document.getElementById("ucb-mobile-footer-menu").getElementsByClassName("ucb-menu")[0],
controllerElement: document.querySelector("#example-toggle"),
containerElement: secondaryWrapper,
openClass: "open",
});
});
11 changes: 9 additions & 2 deletions templates/navigation/menu--main.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/accessible-menu.min.js" type="module"></script>
{{ attach_library('boulder_base/ucb-menu') }}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
<ul{{ attributes.addClass('ucb-main-menu nav') }}>
{% if items %}
<nav id = "ucb-main-menu-nav">
<div class = "ucb-mobile-menu-button-div">
<button id="example-toggle" aria-label="Toggle example menu">☰</button>
</div>
<ul id= "ucb-main-menu" {{ attributes.addClass('ucb-main-menu nav') }}>
{% for item in items %}
{%
set classes = [
Expand All @@ -63,5 +69,6 @@
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
{% endmacro %}
7 changes: 5 additions & 2 deletions templates/regions/region--secondary-menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
*/
#}
{{ attach_library('boulder_base/ucb-secondary-menu-region') }}
<div class="ucb-secondary-menu-region{{ ucb_secondary_menu_button_display ? ' ucb-secondary-menu-button-display' : ''}}">
<div class="ucb-secondary-menu-region-container{{ ucb_secondary_menu_position == 'above' ? ' container' : ''}}">
<div id = "ucb-secondary-menu-region" class="ucb-secondary-menu-region{{ ucb_secondary_menu_button_display ? ' ucb-secondary-menu-button-display' : ''}}">
<div id="ucb-secondary-menu-region-container" class="ucb-secondary-menu-region-container{{ ucb_secondary_menu_position == 'above' ? ' container' : ''}}">
{% if ucb_secondary_menu_default_links %}{% include "@boulder_base/includes/ucb-header-secondary-menu.html.twig" %}{% endif %}
{{ content }}
</div>
<div id = "ucb-mobile-footer-menu" class = "ucb-mobile-footer-menu">
{{ drupal_menu('footer') }}
</div>
</div>