<div class="row">
- <div class="sub-menu sub-menu-fixed">
+ <div class="sub-menu" [ngClass]="{ 'sub-menu-fixed': !isBroadcastMessageDisplayed }">
<div class="links">
<a i18n routerLink="instance" routerLinkActive="active" class="title-page title-page-about">Instance</a>
</div>
</div>
- <div class="margin-content">
+ <div class="margin-content" [ngClass]="{ 'offset-content': !isBroadcastMessageDisplayed }">
<router-outlet></router-outlet>
</div>
</div>
import { Component } from '@angular/core'
+import { ScreenService } from '@app/core'
@Component({
selector: 'my-about',
})
export class AboutComponent {
+ constructor (
+ private screenService: ScreenService
+ ) { }
+ get isBroadcastMessageDisplayed () {
+ return this.screenService.isBroadcastMessageDisplayed
+ }
}
<div>
<my-top-menu-dropdown [menuEntries]="menuEntries"></my-top-menu-dropdown>
- <div class="margin-content">
+ <div class="margin-content" [ngClass]="{ 'offset-content': !isBroadcastMessageDisplayed }">
<router-outlet></router-outlet>
</div>
</div>
}
@include sub-menu-h1;
-
-::ng-deep .anchor {
- top: #{-($header-height + $sub-menu-height + 20px)}; // offsetTop scrollToAnchor
-}
import { Component, OnInit } from '@angular/core'
-import { AuthService } from '@app/core'
+import { AuthService, ScreenService } from '@app/core'
import { ListOverflowItem } from '@app/shared/shared-main'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { UserRight } from '@shared/models'
constructor (
private auth: AuthService,
+ private screen: ScreenService,
private i18n: I18n
- ) {}
+ ) { }
+
+ get isBroadcastMessageDisplayed () {
+ return this.screen.isBroadcastMessageDisplayed
+ }
ngOnInit () {
const federationItems: TopMenuDropdownParam = {
<div class="row">
<my-top-menu-dropdown [menuEntries]="menuEntries"></my-top-menu-dropdown>
- <div class="margin-content pb-5">
+ <div class="margin-content pb-5" [ngClass]="{ 'offset-content': !isBroadcastMessageDisplayed }">
<router-outlet></router-outlet>
</div>
</div>
@include sub-menu-h1;
}
-
-::ng-deep .anchor {
- top: #{-($header-height + $sub-menu-height + 20px)}; // offsetTop scrollToAnchor
-}
import { Component, OnInit } from '@angular/core'
-import { AuthService, ServerService, AuthUser } from '@app/core'
+import { AuthService, ScreenService, ServerService, AuthUser } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { ServerConfig } from '@shared/models'
import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
constructor (
private serverService: ServerService,
private authService: AuthService,
+ private screenService: ScreenService,
private i18n: I18n
) { }
+ get isBroadcastMessageDisplayed () {
+ return this.screenService.isBroadcastMessageDisplayed
+ }
+
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
peertubeLocalStorage.setItem(AppComponent.BROADCAST_MESSAGE_KEY, this.serverConfig.broadcastMessage.message)
this.broadcastMessage = null
+ this.screenService.isBroadcastMessageDisplayed = false
}
private initRouteEvents () {
this.serverService.configReloaded
).subscribe(async config => {
this.broadcastMessage = null
+ this.screenService.isBroadcastMessageDisplayed = false
const messageConfig = config.broadcastMessage
dismissable: messageConfig.dismissable,
class: classes[messageConfig.level]
}
+
+ this.screenService.isBroadcastMessageDisplayed = true
}
})
}
@Injectable()
export class ScreenService {
+ isBroadcastMessageDisplayed = false
+
private windowInnerWidth: number
private lastFunctionCallTime: number
private cacheForMs = 500
-<div class="sub-menu sub-menu-fixed" [ngClass]="{ 'no-scroll': isModalOpened }">
+<div class="sub-menu" [ngClass]="{ 'sub-menu-fixed': !isBroadcastMessageDisplayed, 'no-scroll': isModalOpened }">
<ng-container *ngFor="let menuEntry of menuEntries; index as id">
<a *ngIf="menuEntry.routerLink && isDisplayed(menuEntry)" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page title-page-settings">{{ menuEntry.label }}</a>
return this.screen.isInSmallView(marginLeft)
}
+ get isBroadcastMessageDisplayed () {
+ return this.screen.isBroadcastMessageDisplayed
+ }
+
ngOnInit () {
this.updateChildLabels(window.location.pathname)
flex-grow: 1;
}
- my-top-menu-dropdown + .margin-content {
- padding-top: $sub-menu-height + $sub-menu-margin-bottom;
- }
-
.sub-menu {
background-color: pvar(--submenuColor);
width: 100%;
align-items: center;
padding-left: $not-expanded-horizontal-margins;
padding-right: $not-expanded-horizontal-margins;
-
- & + .margin-content {
- padding-top: $sub-menu-margin-bottom;
- }
+ height: $sub-menu-height;
+ margin-bottom: $sub-menu-margin-bottom;
&.sub-menu-fixed {
- height: $sub-menu-height;
position: fixed;
z-index: #{z('header') - 1};
-
- & + .margin-content {
- padding-top: $sub-menu-height + $sub-menu-margin-bottom;
- }
}
}
+ // Use an appropriate offset top when sub-menu fixed
+ .margin-content.offset-content {
+ padding-top: $sub-menu-height + $sub-menu-margin-bottom;
+ }
+
// Override some properties if the main content is expanded (no menu on the left)
&.expanded {
margin-left: 0;
}
}
+/* offsetTop for scrollToAnchor */
+
.anchor {
position: relative;
- top: #{-($header-height + 20px)}; // offsetTop scrollToAnchor
+ top: #{-($header-height + 20px)};
+}
+
+.offset-content { // if sub-menu fixed
+ .anchor {
+ top: #{-($header-height + $sub-menu-height + 20px)};
+ }
}
@media screen and (max-width: #{breakpoint(xxl)}) {
overflow-x: auto;
}
+ // Use an appropriate offset top when sub-menu fixed
+ .margin-content.offset-content {
+ padding-top: $sub-menu-height + $sub-menu-margin-bottom-small-view;
+ }
+
.admin-sub-header {
@include admin-sub-header-responsive(15px*2);
}