Skip to content

Commit

Permalink
Fix projector detail view, then fix scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom committed Sep 15, 2023
1 parent f6adbc7 commit bf352ca
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 268 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<div
*ngFor="let banner of activeBanners | async"
class="banner flex-center background-accent"
[ngClass]="[banner.class ? banner.class : '', banner.largerOnMobileView ? 'larger-on-mobile' : '']"
>
<ng-container *ngIf="banner.component">
<ng-template [cdkPortalOutlet]="createComponentPortal(banner.component)"></ng-template>
</ng-container>
<ng-container *ngIf="!banner.component">
<a class="banner-link" [routerLink]="banner.link" [style.cursor]="banner.link ? 'pointer' : 'default'">
<mat-icon>{{ banner.icon }}</mat-icon>
<span>{{ banner.text | translate }}</span>
<div *ngIf="banner.subText">
{{ banner.subText | translate }}
</div>
</a>
</ng-container>
<div osResized (osResizedHeight)="registerBannerHeight($event)">
<div
*ngFor="let banner of activeBanners | async"
class="banner flex-center background-accent"
[ngClass]="[banner.class ? banner.class : '', banner.largerOnMobileView ? 'larger-on-mobile' : '']"
>
<ng-container *ngIf="banner.component">
<ng-template [cdkPortalOutlet]="createComponentPortal(banner.component)"></ng-template>
</ng-container>
<ng-container *ngIf="!banner.component">
<a class="banner-link" [routerLink]="banner.link" [style.cursor]="banner.link ? 'pointer' : 'default'">
<mat-icon>{{ banner.icon }}</mat-icon>
<span>{{ banner.text | translate }}</span>
<div *ngIf="banner.subText">
{{ banner.subText | translate }}
</div>
</a>
</ng-container>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentPortal } from '@angular/cdk/portal';
import { Component } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
import { Constructable } from 'src/app/domain/interfaces/constructable';

Expand All @@ -10,14 +10,28 @@ import { BannerDefinition, BannerService } from '../../services/banner.service';
templateUrl: `./banner.component.html`,
styleUrls: [`./banner.component.scss`]
})
export class BannerComponent {
export class BannerComponent implements OnDestroy {
public readonly activeBanners: Observable<BannerDefinition[]>;

private ownHeight = 0;

public constructor(bannerService: BannerService) {
this.activeBanners = bannerService.getActiveBannersObservable();
}

public ngOnDestroy(): void {
this.registerBannerHeight(0);
}

public createComponentPortal(component: Constructable): ComponentPortal<any> {
return new ComponentPortal(component);
}

public registerBannerHeight(height: number): void {
const areaHeight =
Number(document.documentElement.style.getPropertyValue(`--banner-area-height`).replace(`px`, ``)) || 0;
const newHeight = areaHeight === this.ownHeight ? height : areaHeight - this.ownHeight + height;
document.documentElement.style.setProperty(`--banner-area-height`, `${newHeight}px`);
this.ownHeight = height;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { RouterModule } from '@angular/router';
import { OpenSlidesTranslationModule } from 'src/app/site/modules/translations';
import { DirectivesModule } from 'src/app/ui/directives';

import { BannerComponent } from './components/banner/banner.component';
import { SiteWrapperComponent } from './components/site-wrapper/site-wrapper.component';
Expand All @@ -14,6 +15,7 @@ import { SiteWrapperServiceModule } from './services/site-wrapper-service.module
declarations: [SiteWrapperComponent, BannerComponent],
imports: [
CommonModule,
DirectivesModule,
RouterModule,
PortalModule,
MatButtonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@
</mat-nav-list>
</ng-template>
<ng-template osSidenavMainContent>
<div class="content ensure-bottom-spacers-work-in-chrome">
<div class="content">
<os-global-headbar></os-global-headbar>
<router-outlet #o="outlet"></router-outlet>
<div class="scrollable-content">
<router-outlet #o="outlet"></router-outlet>
</div>
</div>
<div class="toolbars">
<os-action-bar></os-action-bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ mat-icon {
}

.scrollable-content {
height: calc(100% - var(--global-headbar-height));
height: calc(100vh - var(--global-headbar-height) - var(--view-headbar-height) - var(--banner-area-height));
width: 100%;
overflow: auto;
}

.ensure-bottom-spacers-work-in-chrome {
overflow: auto;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
height: calc(
100vh -
(
var(--global-headbar-height) + var(--view-headbar-height) // Offset for the headbars
var(--global-headbar-height) + var(--view-headbar-height) + var(--banner-area-height)
// Offset for the headbars
+ 96px // Offset for the stepper
+ 20px // Offset for the bottom spacer
)
Expand Down
Loading

0 comments on commit bf352ca

Please sign in to comment.