diff --git a/addon/components/es-header.js b/addon/components/es-header.js index 6945b096..30bddef4 100644 --- a/addon/components/es-header.js +++ b/addon/components/es-header.js @@ -1,43 +1,24 @@ -import { set, action } from '@ember/object'; import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; import defaultLinks from '../constants/links'; +const defautHomePage = 'https://www.emberjs.com'; + export default class EsHeaderComponent extends Component { - expanded = false; + @tracked expanded = false; get navHome() { - if (this.args.home) { - return this.args.home; - } - - return 'https://www.emberjs.com'; + return this.args.home ?? defautHomePage; } get navLinks() { - if (this.args.links) { - return this.args.links; - } - - return defaultLinks; + return this.args.links ?? defaultLinks; } @action - toggleMenu() { - set(this, 'expanded', !this.expanded); - } - - trackExpanded() { - // Ensure menu is marked as expanded if there is enough screen estate - // TODO: Dynamically calculate necessary horizontal space and collapse based on that - if (typeof FastBoot === 'undefined') { - const mq = matchMedia('(min-width: 992px)'); - - mq.addListener(event => { - if (event.matches) { - set(this, 'expanded', false); - } - }); - } + onTogglerClick() { + this.expanded = !this.expanded; } } diff --git a/addon/styles/components/es-header.css b/addon/styles/components/es-header.css index f668e350..dd18bbfe 100644 --- a/addon/styles/components/es-header.css +++ b/addon/styles/components/es-header.css @@ -59,11 +59,6 @@ color: var(--color-white); } -[aria-expanded="true"] ~ .navbar-list, -[aria-expanded="true"] ~ .navbar-end { - display: block; -} - .navbar-toggler { display: block; width: 3rem; @@ -79,6 +74,11 @@ border-radius: var(--radius-lg); } +.navbar-expanded .navbar-list, +.navbar-expanded .navbar-end { + display: block; +} + .navbar-list-item { position: relative; } @@ -186,7 +186,8 @@ margin-right: var(--spacing-4); } - .navbar-list { + .navbar-list, + .navbar-expanded .navbar-list { display: flex; margin-top: 0; } @@ -232,9 +233,6 @@ z-index: 100; } - .navbar-dropdown-list-item-link { - } - .navbar-end { display: block; align-self: center; diff --git a/addon/templates/components/es-header.hbs b/addon/templates/components/es-header.hbs index 9ac08ba6..3bed3ee5 100644 --- a/addon/templates/components/es-header.hbs +++ b/addon/templates/components/es-header.hbs @@ -1,5 +1,9 @@ -