Skip to content
Snippets Groups Projects
Commit 4a7e21c1 authored by Tuukka Turu's avatar Tuukka Turu
Browse files

Merge branch 'development'

parents caae5e8d ad51d9cd
No related branches found
No related tags found
No related merge requests found
...@@ -2058,6 +2058,7 @@ declare namespace LocalJSX { ...@@ -2058,6 +2058,7 @@ declare namespace LocalJSX {
menuLabelOpen?: string; menuLabelOpen?: string;
menuType?: MenuType; menuType?: MenuType;
onHeaderScrollUp?: (event: CustomEvent<any>) => void; onHeaderScrollUp?: (event: CustomEvent<any>) => void;
onMenuMobileToggled?: (event: CustomEvent<any>) => void;
} }
interface HySiteLogo { interface HySiteLogo {
color?: ColorVariant; color?: ColorVariant;
......
...@@ -139,7 +139,7 @@ export class HyDesktopMenuLinks { ...@@ -139,7 +139,7 @@ export class HyDesktopMenuLinks {
// Add shadow backdrop // Add shadow backdrop
let rect = activeMenuItemSibling.getBoundingClientRect(); let rect = activeMenuItemSibling.getBoundingClientRect();
//this.showBackdropShadow('open', rect.bottom);
let shadowTop = this.el.parentElement.classList.contains('hy-site-header--sticky-active') let shadowTop = this.el.parentElement.classList.contains('hy-site-header--sticky-active')
? this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height ? this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height
: this.el.parentElement.offsetTop + this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height; : this.el.parentElement.offsetTop + this.el.parentElement.offsetHeight + this._headerBorderOffset + rect.height;
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
## Events ## Events
| Event | Description | Type | | Event | Description | Type |
| ---------------- | ----------- | ------------------ | | ------------------- | ----------- | ------------------ |
| `headerScrollUp` | | `CustomEvent<any>` | | `headerScrollUp` | | `CustomEvent<any>` |
| `menuMobileToggled` | | `CustomEvent<any>` |
## Dependencies ## Dependencies
......
...@@ -46,6 +46,8 @@ export class SiteHeader { ...@@ -46,6 +46,8 @@ export class SiteHeader {
@State() isDesktopMenuOpen: boolean = false; @State() isDesktopMenuOpen: boolean = false;
@Event() headerScrollUp: EventEmitter; @Event() headerScrollUp: EventEmitter;
@Event() menuMobileToggled: EventEmitter;
private ro: ResizeObserver; private ro: ResizeObserver;
private donateLink: DonateLink[]; private donateLink: DonateLink[];
private menuLabels: ComponentLabels[]; private menuLabels: ComponentLabels[];
...@@ -61,6 +63,7 @@ export class SiteHeader { ...@@ -61,6 +63,7 @@ export class SiteHeader {
// Listener for toggling mobile menu panel on or off. // Listener for toggling mobile menu panel on or off.
@Listen('mobileMenuToggle') mobileMenuToggle() { @Listen('mobileMenuToggle') mobileMenuToggle() {
this.isMenuOpen = !this.isMenuOpen; this.isMenuOpen = !this.isMenuOpen;
this.menuMobileToggled.emit();
} }
@Listen('scroll', {target: 'window'}) @Listen('scroll', {target: 'window'})
......
...@@ -161,16 +161,13 @@ ...@@ -161,16 +161,13 @@
max-width: 100%; max-width: 100%;
padding: 0 1rem 2rem; padding: 0 1rem 2rem;
width: 100%; width: 100%;
@include breakpoint($narrow) { @include breakpoint($narrow) {
padding: 0 2rem 2rem;
}
@include breakpoint($extrawide) {
max-width: 1216px; max-width: 1216px;
padding: 0 2rem 2rem; padding: 0 0 2rem;
} }
@include breakpoint($xlarge) { @include breakpoint($xlarge) {
max-width: 1216px; padding: 0 0 4rem;
padding: 0 2rem 4rem;
} }
} }
...@@ -178,10 +175,11 @@ ...@@ -178,10 +175,11 @@
background-color: transparent; background-color: transparent;
border: none; border: none;
position: absolute; position: absolute;
right: 0; right: 1rem;
top: 25px; top: 25px;
@include breakpoint($narrow) { @include breakpoint($narrow) {
right: 2rem;
top: 36px; top: 36px;
} }
@include breakpoint($xlarge) { @include breakpoint($xlarge) {
...@@ -206,6 +204,17 @@ ...@@ -206,6 +204,17 @@
letter-spacing: -0.56px; letter-spacing: -0.56px;
} }
} }
&:focus,
&:hover {
cursor: pointer;
span {
color: var(--brand-main);
}
svg {
fill: var(--brand-main);
}
}
} }
&__tools { &__tools {
......
...@@ -72,12 +72,21 @@ export class SiteSearch { ...@@ -72,12 +72,21 @@ export class SiteSearch {
@Listen('menuDesktopToggled', {target: 'document'}) @Listen('menuDesktopToggled', {target: 'document'})
desktopMenuToggled() { desktopMenuToggled() {
this.isSearchPanelOpen = false; this.isSearchPanelOpen = false;
this.showBackdropShadow();
}
// CLose the search panel if user opens the mobile menu panel.
@Listen('menuMobileToggled', {target: 'document'})
mobileMenuToggled() {
this.isSearchPanelOpen = false;
this.showBackdropShadow();
} }
// CLose the search panel if user opens the language menu. // CLose the search panel if user opens the language menu.
@Listen('menuLanguageToggled', {target: 'document'}) @Listen('menuLanguageToggled', {target: 'document'})
menuLanguageToggled() { menuLanguageToggled() {
this.isSearchPanelOpen = false; this.isSearchPanelOpen = false;
this.showBackdropShadow();
} }
handleSearchPanelToggle(event) { handleSearchPanelToggle(event) {
...@@ -90,23 +99,52 @@ export class SiteSearch { ...@@ -90,23 +99,52 @@ export class SiteSearch {
this.searchPanelToggled.emit(); this.searchPanelToggled.emit();
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement; let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
let rectHeader = hyHeader.getBoundingClientRect(); const headerHeight = hyHeader.classList.contains('hy-site-header--sticky-active')
? `${hyHeader.offsetHeight}px`
const headerHeight = `${rectHeader.bottom}px`; : `${hyHeader.offsetTop + hyHeader.offsetHeight}px`;
const searchPanel = this.el.shadowRoot.querySelectorAll(`.site-search__panel`)[0] as HTMLElement; const searchPanel = this.el.shadowRoot.querySelectorAll(`.site-search__panel`)[0] as HTMLElement;
searchPanel.style.top = headerHeight; searchPanel.style.top = headerHeight;
// Add shadow backdrop
let rect = searchPanel.getBoundingClientRect();
let shadowTop = hyHeader.classList.contains('hy-site-header--sticky-active')
? hyHeader.offsetHeight + rect.height
: hyHeader.offsetTop + hyHeader.offsetHeight + rect.height;
this.showBackdropShadow('open', shadowTop);
// Without setTimeout it will not focus the input because it hasn't rendered yet. // Without setTimeout it will not focus the input because it hasn't rendered yet.
setTimeout(() => { setTimeout(() => {
const searchInput = this.el.shadowRoot.querySelector('input#search') as HTMLElement; const searchInput = this.el.shadowRoot.querySelector('input#search') as HTMLElement;
searchInput.focus(); searchInput.focus();
}); });
} else {
this.showBackdropShadow();
} }
event.stopPropagation(); event.stopPropagation();
} }
showBackdropShadow(state = 'close', top = 0) {
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
let hyBackdropDiv = hyHeader.children[0] as HTMLElement;
if (hyBackdropDiv) {
if (state === 'open') {
let me = window.outerHeight - top;
hyBackdropDiv.style.height = `${me}px`;
hyBackdropDiv.style.top = `${top}px`;
hyBackdropDiv.style.position = 'absolute';
hyBackdropDiv.classList.add('is-active');
} else {
hyBackdropDiv.removeAttribute('style');
hyBackdropDiv.classList.remove('is-active');
}
}
}
handleSearchPanelClose() { handleSearchPanelClose() {
this.isSearchPanelOpen = false; this.isSearchPanelOpen = false;
this.showBackdropShadow();
} }
render() { render() {
......
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