Skip to content
Snippets Groups Projects
Commit 773d4a8f authored by Ekaterina Kondareva's avatar Ekaterina Kondareva
Browse files

Merge branch 'NXSTAGE-1578-Group_header_and_nav_fixes' into 'development'

NXSTAGE-1578: Group header fixes

See merge request julkiset-sivut/design-system-lib!178
parents b02a3404 bfb9dd33
No related branches found
No related tags found
No related merge requests found
...@@ -73,8 +73,13 @@ ...@@ -73,8 +73,13 @@
.toggle__close { .toggle__close {
@include breakpoint($wide) { @include breakpoint($wide) {
height: 12px; height: 15px;
width: 12px; width: 15px;
svg {
height: 15px;
width: 15px;
}
} }
} }
...@@ -110,6 +115,7 @@ ...@@ -110,6 +115,7 @@
display: flex; display: flex;
flex-flow: column; flex-flow: column;
justify-items: center; justify-items: center;
padding-top: 14px;
position: relative; position: relative;
} }
...@@ -158,6 +164,10 @@ ...@@ -158,6 +164,10 @@
margin-bottom: 20px; margin-bottom: 20px;
text-decoration: none; text-decoration: none;
@include breakpoint($extrawide) {
@include font-size(14px, 18px);
}
&:hover { &:hover {
span { span {
color: var(--grayscale-medium); color: var(--grayscale-medium);
......
...@@ -47,10 +47,11 @@ export class HyMenuMainGroup { ...@@ -47,10 +47,11 @@ export class HyMenuMainGroup {
handleComponentClick(event) { handleComponentClick(event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
this.emitEvent();
this.isMenuOpen = !this.isMenuOpen; this.isMenuOpen = !this.isMenuOpen;
if (this.isMenuOpen) { if (this.isMenuOpen) {
this.emitEvent();
this.adjustMainMenuPosition(event.target); this.adjustMainMenuPosition(event.target);
} }
} }
...@@ -92,29 +93,48 @@ export class HyMenuMainGroup { ...@@ -92,29 +93,48 @@ export class HyMenuMainGroup {
mainMenuList.style.left = `${rectMenuToggle.left}px`; mainMenuList.style.left = `${rectMenuToggle.left}px`;
} }
let headerHeight = hyTopHeader.offsetHeight + 270;
this.showBackdropShadow('open', headerHeight);
} }
} }
componentWillRender() { showBackdropShadow(state = 'close', top = 0) {
this.dataMainMenuWatcher(this.dataMainMenu); 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');
}
}
} }
handleMainMenuClose(event) { componentWillRender() {
this.isMenuOpen = false; this.dataMainMenuWatcher(this.dataMainMenu);
event.stopPropagation();
} }
handleTopMenuClose(event) { handleTopMenuClose(event) {
this.isMenuOpen = false; this.isMenuOpen = false;
this.mobileMenuTopToggle.emit(); this.mobileMenuTopToggle.emit();
event.stopPropagation(); event.stopPropagation();
} }
// Close the University main menu if user clicks anywhere outside the component. // Close the University main menu if user clicks anywhere outside the component.
@Listen('click', {target: 'window'}) @Listen('click', {target: 'window'})
handleOutsideMenuClick(event) { handleOutsideMenuClick(event) {
this.isMenuOpen = false; if (this.isMenuOpen) {
this.handleTopMenuClose(event); this.isMenuOpen = false;
this.handleTopMenuClose(event);
}
event.stopPropagation(); event.stopPropagation();
} }
...@@ -245,7 +265,7 @@ export class HyMenuMainGroup { ...@@ -245,7 +265,7 @@ export class HyMenuMainGroup {
})} })}
</div> </div>
<button <button
onClick={(e) => this.handleMainMenuClose(e)} onClick={(e) => this.handleComponentClick(e)}
class={{ class={{
'panel-toggle': true, 'panel-toggle': true,
}} }}
......
...@@ -143,3 +143,10 @@ ...@@ -143,3 +143,10 @@
} }
} }
} }
// Bit hacky, but easy way to hide hy-logo on group menu in mobile
.hy-menu-wrapper--mobile[data-is-group] {
.hy-menu__logo-container .hy-site-logo .hy-site-logo__icon {
width: 0 !important;
}
}
...@@ -124,6 +124,7 @@ export class Menu { ...@@ -124,6 +124,7 @@ export class Menu {
case MenuType.mobile: case MenuType.mobile:
return ( return (
<nav <nav
data-is-group={this.isGroup}
role={'navigation'} role={'navigation'}
class={{ class={{
'hy-menu-wrapper--mobile': true, 'hy-menu-wrapper--mobile': true,
......
...@@ -70,7 +70,6 @@ export class HyDesktopMenuLinks { ...@@ -70,7 +70,6 @@ export class HyDesktopMenuLinks {
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;
if (!hyHeader) return; if (!hyHeader) return;
let hyBackdropDiv = hyHeader.children[0] as HTMLElement; let hyBackdropDiv = hyHeader.children[0] as HTMLElement;
...@@ -410,7 +409,6 @@ export class HyDesktopMenuLinks { ...@@ -410,7 +409,6 @@ export class HyDesktopMenuLinks {
let target = isExternal ? '_blank' : '_self'; let target = isExternal ? '_blank' : '_self';
if (toggleOff == 'true') { if (toggleOff == 'true') {
//console.log('toggleOff if true: show as a link: ' + label);
menuLinkItems.push( menuLinkItems.push(
<li onMouseEnter={(e) => this.handleDesktopMenuClose(e)}> <li onMouseEnter={(e) => this.handleDesktopMenuClose(e)}>
<a aria-current={label} href={url} target={target} class="desktop-menu-link toggle" menu-link-id={id}> <a aria-current={label} href={url} target={target} class="desktop-menu-link toggle" menu-link-id={id}>
...@@ -419,7 +417,6 @@ export class HyDesktopMenuLinks { ...@@ -419,7 +417,6 @@ export class HyDesktopMenuLinks {
</li> </li>
); );
} else { } else {
//console.log('toggleOff is false: show as a dropdown: ' + label);
menuLinkItems.push( menuLinkItems.push(
<li> <li>
<button <button
......
...@@ -58,6 +58,14 @@ ...@@ -58,6 +58,14 @@
// Group menus on group pages // Group menus on group pages
&.group { &.group {
@include breakpoint($narrow) { @include breakpoint($narrow) {
min-height: 64px;
}
@include breakpoint($medium) {
min-height: 80px;
}
@include breakpoint($extrawide) {
justify-content: flex-start; justify-content: flex-start;
} }
} }
...@@ -71,11 +79,7 @@ ...@@ -71,11 +79,7 @@
flex-flow: row; flex-flow: row;
place-content: center space-between; place-content: center space-between;
position: relative; position: relative;
z-index: 99; max-height: 48px;
&.is-open {
z-index: 98;
}
@include breakpoint($narrow) { @include breakpoint($narrow) {
margin: 0 auto; margin: 0 auto;
...@@ -113,18 +117,7 @@ ...@@ -113,18 +117,7 @@
margin: 16px 24px; margin: 16px 24px;
} }
@include breakpoint($extrawide) { @include breakpoint($extrawide) {
margin: 16px; margin: 16px 32px;
}
&:hover {
color: var(--brand-main);
a,
span {
color: var(--brand-main) !important;
}
svg {
fill: var(--brand-main);
}
} }
&.group { &.group {
...@@ -145,17 +138,6 @@ ...@@ -145,17 +138,6 @@
@include breakpoint($xlarge) { @include breakpoint($xlarge) {
margin: 8px 32px; margin: 8px 32px;
} }
&:hover {
color: var(--grayscale-medium);
a,
span {
color: var(--grayscale-medium) !important;
}
svg {
fill: var(--grayscale-medium);
}
}
} }
} }
......
...@@ -258,7 +258,7 @@ export class SiteHeader { ...@@ -258,7 +258,7 @@ export class SiteHeader {
// Larger than 1200px screens // Larger than 1200px screens
return [ return [
<header class={classAttributes.join(' ')}> <header class={classAttributes.join(' ')}>
<div class={{'hy-backdrop': true, 'is-active': this.isMenuOpen}} /> <div class={{'hy-backdrop': true, 'is-active': this.isMenuOpen || this.isTopMenuOpen}} />
{this.isGroup && ( {this.isGroup && (
<div class="hy-site-header__content-top"> <div class="hy-site-header__content-top">
<div class={'hy-site-header__logo-container group '} role="navigation"> <div class={'hy-site-header__logo-container group '} role="navigation">
...@@ -358,8 +358,8 @@ export class SiteHeader { ...@@ -358,8 +358,8 @@ export class SiteHeader {
<div class="hy-site-header__content-top"> <div class="hy-site-header__content-top">
<div class={'hy-site-header__logo-container group '} role="navigation"> <div class={'hy-site-header__logo-container group '} role="navigation">
<hy-site-logo <hy-site-logo
is-group={true} is-group={'true'}
size={logoSizeGroup} size={logoSize}
color={logoColorGroup} color={logoColorGroup}
url={this.siteUrl} url={this.siteUrl}
label={this.siteLabel} label={this.siteLabel}
...@@ -400,7 +400,7 @@ export class SiteHeader { ...@@ -400,7 +400,7 @@ export class SiteHeader {
</div> </div>
</div> </div>
)} )}
<div class="hy-site-header__content"> <div class={{'hy-site-header__content': true, group: this.isGroup}}>
<div class={'hy-site-header__logo-container'}> <div class={'hy-site-header__logo-container'}>
{this.isGroup ? ( {this.isGroup ? (
<a class={'group'} href={this.logoUrl}> <a class={'group'} href={this.logoUrl}>
...@@ -487,7 +487,13 @@ export class SiteHeader { ...@@ -487,7 +487,13 @@ export class SiteHeader {
{this.isGroup && ( {this.isGroup && (
<div class={{'hy-site-header__content-top': true, 'is-open': this.isTopMenuOpen}} is-mobile={true}> <div class={{'hy-site-header__content-top': true, 'is-open': this.isTopMenuOpen}} is-mobile={true}>
<div class={'hy-site-header__logo-container group '}> <div class={'hy-site-header__logo-container group '}>
<hy-site-logo size={logoSizeGroup} color={logoColorGroup} url={this.siteUrl} label={this.siteLabel} /> <hy-site-logo
is-group={true}
size={logoSizeGroup}
color={logoColorGroup}
url={this.siteUrl}
label={this.siteLabel}
/>
</div> </div>
<div class={'menu--secondary menu--secondary--group'}> <div class={'menu--secondary menu--secondary--group'}>
...@@ -513,7 +519,7 @@ export class SiteHeader { ...@@ -513,7 +519,7 @@ export class SiteHeader {
</div> </div>
</div> </div>
)} )}
<div class="hy-site-header__content"> <div class={{'hy-site-header__content': true, group: this.isGroup}}>
<div class={'hy-site-header__logo-container'}> <div class={'hy-site-header__logo-container'}>
{this.isGroup ? ( {this.isGroup ? (
<a class={'group'} href={this.logoUrl}> <a class={'group'} href={this.logoUrl}>
...@@ -536,6 +542,14 @@ export class SiteHeader { ...@@ -536,6 +542,14 @@ export class SiteHeader {
search-tools={this.dataSearchTools} search-tools={this.dataSearchTools}
/> />
)} )}
<span
class={{
'hy-site-header__menu-label': true,
'is-visible': this.isMenuOpen,
}}
>
{this.menuLabel}
</span>
<button <button
onClick={() => toggleMenuMobileAndRemoveListener()} onClick={() => toggleMenuMobileAndRemoveListener()}
class={{ class={{
......
...@@ -71,7 +71,14 @@ ...@@ -71,7 +71,14 @@
} }
&__icon { &__icon {
svg { &.group {
svg {
height: 32px !important;
width: 33.41px;
}
}
&:not(.group) svg {
height: 32px; height: 32px;
width: 33.41px; width: 33.41px;
...@@ -85,13 +92,6 @@ ...@@ -85,13 +92,6 @@
width: 64px; width: 64px;
} }
} }
&.group {
svg {
height: 32px;
width: 34px;
}
}
} }
&__header { &__header {
......
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