From 10ed78cd32efc4ae2b70767edb9724207d750ff9 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Mon, 3 Jun 2024 16:52:38 +0200 Subject: [PATCH] [editor] Refactor MessageService as standalone and fix snackbar style --- .../app/components/element-list.component.ts | 3 +- .../components/reference-list.component.ts | 1 - .../src/app/services/message.service.ts | 37 +++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/projects/editor/src/app/components/element-list.component.ts b/projects/editor/src/app/components/element-list.component.ts index 9f07b471a..685646ab8 100644 --- a/projects/editor/src/app/components/element-list.component.ts +++ b/projects/editor/src/app/components/element-list.component.ts @@ -26,7 +26,8 @@ import { NgForOf } from '@angular/common'; </mat-list> `, styles: [ - + 'mat-icon {color: inherit !important;}', + '.mat-mdc-list-item-title {color: inherit !important;}' ] }) export class ElementListComponent { diff --git a/projects/editor/src/app/components/reference-list.component.ts b/projects/editor/src/app/components/reference-list.component.ts index 9f8bd1cf7..cba294cd2 100644 --- a/projects/editor/src/app/components/reference-list.component.ts +++ b/projects/editor/src/app/components/reference-list.component.ts @@ -26,7 +26,6 @@ import { ElementListComponent } from 'editor/src/app/components/element-list.com </ng-container> `, styles: [ - 'mat-icon {color: inherit !important;}', '.mat-mdc-list-item-title {color: inherit !important;}' ] }) diff --git a/projects/editor/src/app/services/message.service.ts b/projects/editor/src/app/services/message.service.ts index c843602c6..1ed3d9f0a 100644 --- a/projects/editor/src/app/services/message.service.ts +++ b/projects/editor/src/app/services/message.service.ts @@ -2,9 +2,14 @@ import { Component, Inject, Injectable, Input, Optional } from '@angular/core'; -import { MAT_SNACK_BAR_DATA, MatSnackBar, MatSnackBarRef } from '@angular/material/snack-bar'; +import { MAT_SNACK_BAR_DATA, MatSnackBar, MatSnackBarModule, MatSnackBarRef } from '@angular/material/snack-bar'; import { ReferenceList } from 'editor/src/app/services/reference-manager'; import { UIElement } from 'common/models/elements/element'; +import { ReferenceListComponent } from 'editor/src/app/components/reference-list.component'; +import { MatButtonModule } from '@angular/material/button'; +import { MatListModule } from '@angular/material/list'; +import { MatIconModule } from '@angular/material/icon'; +import { NgForOf, NgIf } from '@angular/common'; @Injectable({ providedIn: 'root' @@ -49,19 +54,28 @@ export class MessageService { @Component({ selector: 'aspect-reference-list-snackbar', + standalone: true, + imports: [ + ReferenceListComponent, + MatSnackBarModule, + MatButtonModule + ], template: ` - <aspect-reference-list matSnackBarLabel [refs]="refs || data"></aspect-reference-list> - <span matSnackBarActions> - <button mat-stroked-button matSnackBarAction (click)="snackBarRef.dismiss()"> - Schließen - </button> - </span> + <div [style.padding.px]="16"> + <aspect-reference-list matSnackBarLabel [refs]="refs || data"></aspect-reference-list> + <span matSnackBarActions> + <button mat-stroked-button matSnackBarAction (click)="snackBarRef.dismiss()"> + Schließen + </button> + </span> + </div> `, styles: [` button { color: var(--mat-snack-bar-button-color) !important; --mat-mdc-button-persistent-ripple-color: currentColor !important; } + aspect-reference-list {color: var(--mdc-snackbar-supporting-text-color);} ` ] }) @@ -74,6 +88,15 @@ export class ReferenceListSnackbarComponent { @Component({ selector: 'aspect-invalid-reference-elements-list-snackbar', + standalone: true, + imports: [ + NgIf, + NgForOf, + MatListModule, + MatIconModule, + MatSnackBarModule, + MatButtonModule + ], template: ` Invalide Referenzen bei folgenden <br> Elementen wurden entfernt: <mat-list> -- GitLab