Skip to content

Commit

Permalink
Merge pull request #285 from swisstopo/feature/assets-206-ui-sidebar-…
Browse files Browse the repository at this point in the history
…header-anpassen

Feature 206: UI Sidebar & Header anpassen
  • Loading branch information
daniel-va authored Oct 15, 2024
2 parents 2870beb + d3f2fc1 commit b79603d
Show file tree
Hide file tree
Showing 61 changed files with 620 additions and 572 deletions.
5 changes: 0 additions & 5 deletions apps/client-asset-sg/src/app/app-guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ export const roleGuard = (testUser: (u: User) => boolean) => {
return store.select(fromAppShared.selectUser).pipe(filter(isNotNull), map(testUser));
};

export const notAnonymousGuard: CanActivateFn = () => {
const store = inject(Store<AppState>);
return store.select(fromAppShared.selectIsAnonymousMode).pipe(map((isAnonymousMode) => !isAnonymousMode));
};

export const adminGuard: CanActivateFn = () => roleGuard((user) => user.isAdmin);
16 changes: 10 additions & 6 deletions apps/client-asset-sg/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { CommonModule, NgOptimizedImage, registerLocaleData } from '@angular/com
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import locale_deCH from '@angular/common/locales/de-CH';
import { inject, NgModule } from '@angular/core';
import { MatButton } from '@angular/material/button';
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { MatMenu, MatMenuTrigger } from '@angular/material/menu';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltip } from '@angular/material/tooltip';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
Expand Down Expand Up @@ -34,9 +37,10 @@ import { PushModule } from '@rx-angular/template/push';

import { environment } from '../environments/environment';

import { adminGuard, notAnonymousGuard } from './app-guards';
import { adminGuard } from './app-guards';
import { AppComponent } from './app.component';
import { AppBarComponent, MenuBarComponent, NotFoundComponent, RedirectToLangComponent } from './components';
import { MenuBarItemComponent } from './components/menu-bar-item/menu-bar-item.component';
import { SplashScreenComponent } from './components/splash-screen/splash-screen.component';
import { appTranslations } from './i18n';
import { AppSharedStateEffects } from './state';
Expand All @@ -51,6 +55,7 @@ registerLocaleData(locale_deCH, 'de-CH');
NotFoundComponent,
AppBarComponent,
MenuBarComponent,
MenuBarItemComponent,
SplashScreenComponent,
],
imports: [
Expand All @@ -59,11 +64,6 @@ registerLocaleData(locale_deCH, 'de-CH');
BrowserAnimationsModule,
HttpClientModule,
RouterModule.forRoot([
{
path: ':lang/profile',
loadChildren: () => import('@asset-sg/profile').then((m) => m.ProfileModule),
canActivate: [notAnonymousGuard],
},
{
path: ':lang/admin',
loadChildren: () => import('@asset-sg/admin').then((m) => m.AdminModule),
Expand Down Expand Up @@ -116,6 +116,10 @@ registerLocaleData(locale_deCH, 'de-CH');
MatProgressSpinnerModule,
AdminOnlyDirective,
CanCreateDirective,
MatTooltip,
MatButton,
MatMenuTrigger,
MatMenu,
],
providers: [
provideSvgIcons(icons),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
<a routerLink="/">
<img class="logo" src="../../../assets/swissgeol_assets.svg" alt="{{ 'logoSwissGeol' | translate }}" />
<a routerLink="/" class="logo">
<img src="../../../assets/swissgeol_assets.svg" alt="{{ 'logoSwissGeol' | translate }}" width="130" height="36" />
</a>
<ng-content />
<div class="spacer"></div>
<span class="version">{{ version }}</span>
<div class="language-links" *rxLet="links$ | push; let l">
<a
asset-sg-reset
*rxFor="let link of l.links"
[routerLink]="link.params"
[queryParams]="link.queryParams"
[disabled]="link.disabled"
>{{ link.lang }}</a
>
</div>

<button mat-button type="button" class="language" [matMenuTriggerFor]="languageMenu" *rxLet="currentLang$; let lang">
{{ lang.lang }}

<svg-icon key="arrow-down" class="open" />
<svg-icon key="arrow-up" class="close" />
</button>
<mat-menu #languageMenu="matMenu" backdropClass="languages">
<ng-container *rxLet="languages$; let languages">
@for (language of languages; track language.lang) {
<a
asset-sg-reset
[routerLink]="language.params"
[queryParams]="language.queryParams"
[class.is-active]="language.isActive"
>
<span class="icon">
<svg-icon key="checkmark" />
</span>
<span class="name">
{{ language.lang }}
</span>
</a>
}
</ng-container>
</mat-menu>

<ng-container *ngIf="(isAnonymous$ | async) === false">
<button mat-button type="button" class="profile" [matMenuTriggerFor]="profileMenu">
<svg-icon key="profile" />
</button>

<mat-menu #profileMenu="matMenu" backdropClass="profile">
<ng-container *rxLet="user$; let user">
<div>
{{ user.email }}
</div>
<div>
<button asset-sg-primary translate (click)="logout()">logout</button>
</div>
</ng-container>
</mat-menu>
</ng-container>
154 changes: 125 additions & 29 deletions apps/client-asset-sg/src/app/components/app-bar/app-bar.component.scss
Original file line number Diff line number Diff line change
@@ -1,52 +1,148 @@
@use "../../styles/variables";

:host {
box-shadow: 0px 4px 4px #00000029;
box-shadow: 0 4px 4px #00000029;
z-index: 10;
display: flex;
align-items: center;
gap: 8px;
padding-inline: 16px;
}

.logo {
margin-left: 24px;
height: 56px;
a.logo {
width: 130px;
height: 36px;
}

.search-input {
margin-left: 6rem;
line-height: 3.5rem;
padding: 0 1rem;
border: none;
outline: none;
background-color: variables.$cyan-01;
width: 33rem;
font-weight: variables.$font-medium;
.spacer {
flex: 10;
}

.version {
color: #828e9a;
}

button.language {
text-transform: uppercase;
width: 69px;
height: 36px;
padding: 8px 12px;
border-radius: 4px;
color: #337083;
transition: 150ms ease-in;
transition-property: color, background-color;

& > ::ng-deep .mdc-button__label {
width: 100%;
height: 100%;

display: flex;
justify-content: space-between;
align-items: center;
padding: 0;
}

&:focus {
background-color: variables.$focused;
&:hover,
&[aria-expanded="true"] {
background-color: #adc6cd;
color: #2f4356;
}

&::placeholder {
color: variables.$grey-09;
svg-icon {
display: flex;
align-items: center;
width: 20px;
height: 20px;
}

svg-icon.close {
display: none;
}

&[aria-expanded="true"] svg-icon {
&.open {
display: none;
}
&.close {
display: flex;
}
}
}

.spacer {
flex: 10;
::ng-deep .languages + * .mat-mdc-menu-panel {
text-transform: uppercase;
min-width: 85px;
max-width: 85px;

& > .mat-mdc-menu-content {
display: flex;
flex-direction: column;
padding: 0;
}

a {
color: #1c2834;
text-decoration: none;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
transition: color 150ms ease-in;
}
a:hover {
background-color: #dfe4e9;
}

a > span.name {
flex-basis: 30%;
}

a > span.icon {
flex-grow: 1;
display: flex;
justify-content: flex-start;
}
a:not(.is-active) > span.icon {
visibility: hidden;
}
}

.version {
color: #828e9a;
button.profile {
background-color: #295969;
color: white;
min-width: 36px;
max-width: 36px;
min-height: 36px;
max-height: 36px;
border-radius: 50%;

& > ::ng-deep .mdc-button__label {
width: 100%;
height: 100%;

display: flex;
justify-content: space-between;
align-items: center;
padding: 0;
}
}

.language-links {
margin-right: 24px;
a {
margin-left: 0.5rem;
color: variables.$grey-09;
&[aria-disabled="true"] {
color: variables.$grey-06;
cursor: default;
::ng-deep .profile + * .mat-mdc-menu-panel > .mat-mdc-menu-content {
display: flex;
flex-direction: column;

& > div {
padding: 8px 12px;
}

::ng-deep button {
width: 100%;
color: #337083;
border: 1px solid #337083;
background-color: transparent;

&:hover {
background-color: #adc6cd;
}
}
}
Loading

0 comments on commit b79603d

Please sign in to comment.