Skip to content
Snippets Groups Projects
Commit 482e22d8 authored by druid's avatar druid
Browse files

Merge branch 'development'

parents 3f1591f4 d7476f69
No related branches found
No related tags found
No related merge requests found
...@@ -2039,6 +2039,7 @@ declare namespace LocalJSX { ...@@ -2039,6 +2039,7 @@ declare namespace LocalJSX {
menuLabelClose?: string; menuLabelClose?: string;
menuLabelOpen?: string; menuLabelOpen?: string;
menuType?: MenuType; menuType?: MenuType;
onHeaderScrollUp?: (event: CustomEvent<any>) => void;
} }
interface HySiteLogo { interface HySiteLogo {
color?: ColorVariant; color?: ColorVariant;
......
...@@ -67,14 +67,10 @@ export class MenuLanguage { ...@@ -67,14 +67,10 @@ export class MenuLanguage {
this.menuLanguageToggled.emit(); this.menuLanguageToggled.emit();
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement; let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
const headerHeight = `${ let rectHeader = hyHeader.getBoundingClientRect();
languageMenuSelector.offsetHeight + let rectLangMenu = languageMenuSelector.getBoundingClientRect();
hyHeader.offsetTop +
hyHeader.offsetHeight + const headerHeight = `${languageMenuSelector.offsetHeight + rectHeader.bottom + 8 - rectLangMenu.bottom}px`;
8 -
languageMenuSelector.offsetTop -
languageMenuSelector.offsetHeight
}px`;
const languagePanel = languageMenuSelector.shadowRoot.querySelectorAll( const languagePanel = languageMenuSelector.shadowRoot.querySelectorAll(
`.menu--language__dropdown` `.menu--language__dropdown`
)[0] as HTMLElement; )[0] as HTMLElement;
......
...@@ -79,10 +79,16 @@ ...@@ -79,10 +79,16 @@
} }
hy-icon { hy-icon {
display: inline-block !important; //display: inline-block !important;
padding-left: 3px; display: flex;
height: 8px;
margin-left: 3px;
width: 10px;
@include breakpoint($xlarge) { @include breakpoint($xlarge) {
padding-left: 4px; height: 8.44px;
margin-left: 4px;
width: 12px;
} }
svg { svg {
...@@ -98,7 +104,7 @@ ...@@ -98,7 +104,7 @@
// On hover: heading icon is turned 180deg and grows bigger. // On hover: heading icon is turned 180deg and grows bigger.
&--is-active { &--is-active {
position: relative; //position: relative;
&:hover, &:hover,
&:focus { &:focus {
color: var(--link-blue); color: var(--link-blue);
...@@ -157,7 +163,14 @@ ...@@ -157,7 +163,14 @@
border: none; border: none;
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 10px; top: 0;
@include breakpoint($extrawide) {
padding: 22px 32px 17px 32px;
}
@include breakpoint($xlarge) {
padding: 30px 32px 30px 32px;
}
&__label { &__label {
@include font-size(18px, 22px); @include font-size(18px, 22px);
...@@ -197,11 +210,6 @@ ...@@ -197,11 +210,6 @@
&:focus { &:focus {
box-shadow: 0 0 16px 0 rgba(0, 83, 121, 0.2); box-shadow: 0 0 16px 0 rgba(0, 83, 121, 0.2);
color: var(--link-blue); color: var(--link-blue);
svg {
//height: 42px;
//width: 42px;
}
} }
@include breakpoint($extrawide) { @include breakpoint($extrawide) {
......
...@@ -21,6 +21,7 @@ export interface DesktopLinks { ...@@ -21,6 +21,7 @@ export interface DesktopLinks {
import {ColorVariant} from '../../../utils/utils'; import {ColorVariant} from '../../../utils/utils';
import {Component, h, Element, Prop, State, Watch, EventEmitter, Event, Listen} from '@stencil/core'; import {Component, h, Element, Prop, State, Watch, EventEmitter, Event, Listen} from '@stencil/core';
import ResizeObserver from 'resize-observer-polyfill';
@Component({ @Component({
tag: 'hy-desktop-menu-links', tag: 'hy-desktop-menu-links',
...@@ -48,6 +49,8 @@ export class HyDesktopMenuLinks { ...@@ -48,6 +49,8 @@ export class HyDesktopMenuLinks {
private _hoverTimer = null; private _hoverTimer = null;
private _fadeOutTimer = null; private _fadeOutTimer = null;
private ro: ResizeObserver;
@Watch('dataDesktopLinks') @Watch('dataDesktopLinks')
dataDesktopLinksWatcher(data: DesktopLinks[] | string) { dataDesktopLinksWatcher(data: DesktopLinks[] | string) {
this._dataDesktopLinks = typeof data === 'string' ? JSON.parse(data) : data; this._dataDesktopLinks = typeof data === 'string' ? JSON.parse(data) : data;
...@@ -57,16 +60,27 @@ export class HyDesktopMenuLinks { ...@@ -57,16 +60,27 @@ export class HyDesktopMenuLinks {
this.dataDesktopLinksWatcher(this.dataDesktopLinks); this.dataDesktopLinksWatcher(this.dataDesktopLinks);
} }
removeBackdropShadow(size: number) {
// Close backdrop shadow if the screen is < 1200px
if (size < 1200) {
this.showBackdropShadow();
}
}
showBackdropShadow(state = 'close', top = 0) { showBackdropShadow(state = 'close', top = 0) {
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement; let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
let hyBackdropDiv = hyHeader.children[0] as HTMLElement; let hyBackdropDiv = hyHeader.children[0] as HTMLElement;
if (hyBackdropDiv) { if (hyBackdropDiv) {
if (state === 'open') { if (state === 'open') {
hyBackdropDiv.classList.add('is-active'); let me = window.outerHeight - top;
hyBackdropDiv.style.height = `${me}px`;
hyBackdropDiv.style.top = `${top}px`; hyBackdropDiv.style.top = `${top}px`;
hyBackdropDiv.style.position = 'absolute';
hyBackdropDiv.classList.add('is-active');
//console.log(document.body.clientHeight + ' ' + window.outerHeight + ' ' + top);
} else { } else {
hyBackdropDiv.style.top = '0'; hyBackdropDiv.removeAttribute('style');
hyBackdropDiv.classList.remove('is-active'); hyBackdropDiv.classList.remove('is-active');
} }
} }
...@@ -125,11 +139,14 @@ export class HyDesktopMenuLinks { ...@@ -125,11 +139,14 @@ export class HyDesktopMenuLinks {
// Add shadow backdrop // Add shadow backdrop
let rect = activeMenuItemSibling.getBoundingClientRect(); let rect = activeMenuItemSibling.getBoundingClientRect();
this.showBackdropShadow('open', rect.bottom); //this.showBackdropShadow('open', rect.bottom);
let shadowTop = this.el.parentElement.classList.contains('hy-site-header--sticky-active')
? this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height
: this.el.parentElement.offsetTop + this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height;
this.showBackdropShadow('open', shadowTop);
// Position submenu block under the activated top menu item. // Position submenu block under the activated top menu item.
let activeButtonRect = activeMenuItem.getBoundingClientRect(); const menuPanelLeftPosition = activeMenuItem.offsetLeft - this._submenuLeftMargin;
const menuPanelLeftPosition = activeButtonRect.left - this._submenuLeftMargin;
activeMenuItemSibling.style.paddingLeft = `${menuPanelLeftPosition}px`; activeMenuItemSibling.style.paddingLeft = `${menuPanelLeftPosition}px`;
// Position shortcuts block. // Position shortcuts block.
...@@ -214,6 +231,13 @@ export class HyDesktopMenuLinks { ...@@ -214,6 +231,13 @@ export class HyDesktopMenuLinks {
this.closePanel(fadeOut); this.closePanel(fadeOut);
} }
// CLose the desktop menu panel if user scrolls Sticky Header till the very top.
@Listen('headerScrollUp', {target: 'document'})
headerScrollUp() {
let fadeOut = false;
this.closePanel(fadeOut);
}
handleDesktopMenuEnter(event, id) { handleDesktopMenuEnter(event, id) {
clearTimeout(this._fadeOutTimer); clearTimeout(this._fadeOutTimer);
...@@ -236,7 +260,6 @@ export class HyDesktopMenuLinks { ...@@ -236,7 +260,6 @@ export class HyDesktopMenuLinks {
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement; let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
const headerHeight = hyHeader.offsetTop + hyHeader.offsetHeight; const headerHeight = hyHeader.offsetTop + hyHeader.offsetHeight;
console.log('leave ' + leaveEvent.clientY + ' ' + headerHeight);
if (leaveEvent.clientY < headerHeight - 4) { if (leaveEvent.clientY < headerHeight - 4) {
this.closePanel(); this.closePanel();
} }
...@@ -258,8 +281,7 @@ export class HyDesktopMenuLinks { ...@@ -258,8 +281,7 @@ export class HyDesktopMenuLinks {
if (this.currenOpenMenuId == id) { if (this.currenOpenMenuId == id) {
// Mouse moving around the same menu link // Mouse moving around the same menu link
if (moveEvent.clientY < topBorder - 8) { if (moveEvent.clientY < topBorder - 4) {
console.log(topBorder + ' ' + moveEvent.clientY);
this.closePanel(); this.closePanel();
} }
} }
...@@ -289,6 +311,14 @@ export class HyDesktopMenuLinks { ...@@ -289,6 +311,14 @@ export class HyDesktopMenuLinks {
} }
componentDidLoad() { componentDidLoad() {
// Set the browser resize observer to gather information about browser width.
this.ro = new ResizeObserver((entries) => {
for (const entry of entries) {
this.removeBackdropShadow(entry.contentRect.width);
}
});
this.ro.observe(document.body);
let hyToolbar = document.querySelectorAll('#toolbar-administration')[0]; let hyToolbar = document.querySelectorAll('#toolbar-administration')[0];
if (hyToolbar) { if (hyToolbar) {
this.hasToolbar = true; this.hasToolbar = true;
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
| `menuLabelOpen` | `menu-label-open` | | `string` | `undefined` | | `menuLabelOpen` | `menu-label-open` | | `string` | `undefined` |
| `menuType` | `menu-type` | | `MenuType.desktop \| MenuType.mobile \| MenuType.sidenav \| MenuType.sidepanel \| MenuType.tablet` | `MenuType.default` | | `menuType` | `menu-type` | | `MenuType.desktop \| MenuType.mobile \| MenuType.sidenav \| MenuType.sidepanel \| MenuType.tablet` | `MenuType.default` |
## Events
| Event | Description | Type |
| ---------------- | ----------- | ------------------ |
| `headerScrollUp` | | `CustomEvent<any>` |
## Dependencies ## Dependencies
### Depends on ### Depends on
......
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
&--sticky-visible { &--sticky-visible {
left: 0; left: 0;
position: fixed; position: fixed;
right: 0;
transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0);
width: 100%; //width: 100%;
width: inherit; //??
} }
&--sticky-hidden { &--sticky-hidden {
top: 0; top: 0;
...@@ -165,6 +167,7 @@ ...@@ -165,6 +167,7 @@
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
transition: background-color 300ms; transition: background-color 300ms;
visibility: visible; visibility: visible;
width: inherit; //??
z-index: 99; z-index: 99;
} }
} }
......
...@@ -14,7 +14,7 @@ export interface ComponentLabels { ...@@ -14,7 +14,7 @@ export interface ComponentLabels {
label?: string; label?: string;
} }
import {Component, Element, h, Listen, Prop, State} from '@stencil/core'; import {Component, Element, Event, EventEmitter, h, Listen, Prop, State} from '@stencil/core';
import ResizeObserver from 'resize-observer-polyfill'; import ResizeObserver from 'resize-observer-polyfill';
import {MenuType, ColorVariant, SiteLogoSize} from '../../utils/utils'; import {MenuType, ColorVariant, SiteLogoSize} from '../../utils/utils';
...@@ -41,6 +41,8 @@ export class SiteHeader { ...@@ -41,6 +41,8 @@ export class SiteHeader {
@State() isMobile: boolean; @State() isMobile: boolean;
@State() isMenuOpen: boolean = false; @State() isMenuOpen: boolean = false;
@State() isDesktopMenuOpen: boolean = false; @State() isDesktopMenuOpen: boolean = false;
@Event() headerScrollUp: EventEmitter;
private ro: ResizeObserver; private ro: ResizeObserver;
private donateLink: DonateLink[]; private donateLink: DonateLink[];
private menuLabels: ComponentLabels[]; private menuLabels: ComponentLabels[];
...@@ -131,7 +133,6 @@ export class SiteHeader { ...@@ -131,7 +133,6 @@ export class SiteHeader {
// If current position > last position AND scrolled past navbar... // If current position > last position AND scrolled past navbar...
if (st > this.lastScrollTop && st > this.navbarHeight) { if (st > this.lastScrollTop && st > this.navbarHeight) {
// Scroll Down // Scroll Down
hySiteHeader.classList.add('hy-site-header--sticky-active'); hySiteHeader.classList.add('hy-site-header--sticky-active');
hySiteHeader.classList.add('hy-site-header--sticky-hidden'); hySiteHeader.classList.add('hy-site-header--sticky-hidden');
hySiteHeader.classList.remove('hy-site-header--sticky-visible'); hySiteHeader.classList.remove('hy-site-header--sticky-visible');
...@@ -141,10 +142,13 @@ export class SiteHeader { ...@@ -141,10 +142,13 @@ export class SiteHeader {
hySiteHeader.classList.remove('hy-site-header--sticky-active'); hySiteHeader.classList.remove('hy-site-header--sticky-active');
hySiteHeader.classList.remove('hy-site-header--sticky-visible'); hySiteHeader.classList.remove('hy-site-header--sticky-visible');
hySiteHeader.classList.remove('hy-site-header--sticky-hidden'); hySiteHeader.classList.remove('hy-site-header--sticky-hidden');
// Close desktop menu panel if it's open.
this.headerScrollUp.emit();
} else { } else {
hySiteHeader.classList.add('hy-site-header--sticky-active'); hySiteHeader.classList.add('hy-site-header--sticky-active');
hySiteHeader.classList.add('hy-site-header--sticky-visible');
hySiteHeader.classList.remove('hy-site-header--sticky-hidden'); hySiteHeader.classList.remove('hy-site-header--sticky-hidden');
hySiteHeader.classList.add('hy-site-header--sticky-visible');
} }
} }
this.lastScrollTop = st; this.lastScrollTop = st;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment