Skip to content

Commit

Permalink
feat: show short menu
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Jan 11, 2024
1 parent ebc16d5 commit f7522c1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@

<div class="short-menu">
<ul>
<li><a href="/">{{ 'COMPONENTS.HEADER.SUB_MENU.EVENTS' | translate }}</a></li>
<li><a href="#">{{ 'COMPONENTS.HEADER.SUB_MENU.NOTICE_BOARD' | translate }}</a></li>
<li>
<a [routerLink]="'/'" [class.active]="isLinkActive('/')">
{{ 'COMPONENTS.HEADER.SUB_MENU.EVENTS' | translate }}
</a>
</li>
<li>
<a [routerLink]="'/notices'" [class.active]="isLinkActive('/notices')">
{{ 'COMPONENTS.HEADER.SUB_MENU.NOTICE_BOARD' | translate }}
</a>
</li>
</ul>
</div>
<div class="menu">
Expand Down
12 changes: 12 additions & 0 deletions src/app/components/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
display: none;
flex: none;

@include media-breakpoint-up(md) {
display: flex;
}

@include media-breakpoint-up(lg) {
font-size: 22px;
}

ul {
list-style: none;
margin: 0;
Expand All @@ -44,6 +52,10 @@

li {
padding: 0.5rem;

a.active {
text-decoration: underline;
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NgbOffcanvas } from '@ng-bootstrap/ng-bootstrap';
import { AuthenticationService } from '../../shared/services/authentication.service';
import { IframeService } from '../../services/iframe.service';
import { Subscription } from 'rxjs';
import { Router } from '@angular/router';

@Component({
selector: 'app-header',
Expand All @@ -19,6 +20,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
private offcanvasService: NgbOffcanvas,
public authService: AuthenticationService,
private iframeService: IframeService,
private router: Router
) {
}

Expand Down Expand Up @@ -49,4 +51,24 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.offcanvasService.dismiss();
}
}

isLinkActive(url: string): boolean {
// hack needed, as native routerLinkActive
const queryParamsIndex = this.router.url.indexOf('?');
let baseUrl = queryParamsIndex === -1 ? this.router.url : this.router.url.slice(0, queryParamsIndex);
if (baseUrl === url) {
return true;
}

const lastIndex = baseUrl.lastIndexOf('/');
const base = baseUrl.substring(0, lastIndex);
const ending = baseUrl.substring(lastIndex + 1);

// empty string is removed
if (url === "/" && base === "" && ending.length === 24) {
return true;
}

return (base === url && ending.length === 24);
}
}
2 changes: 1 addition & 1 deletion src/assets/i18n/rm.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"HEADER": {
"SUB_MENU": {
"EVENTS": "occurrenzas",
"EVENTS": "chalender",
"NOTICE_BOARD": "tavla naira"
},
"MAIN_MENU": {
Expand Down

0 comments on commit f7522c1

Please sign in to comment.