1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import {Component, Inject} from '@angular/core'; 18import {MatSnackBarRef, MAT_SNACK_BAR_DATA} from '@angular/material/snack-bar'; 19 20@Component({ 21 selector: 'snack-bar', 22 template: ` 23 <div class="snack-bar-container"> 24 <p *ngFor="let message of messages" class="mat-body-1"> 25 {{ message }} 26 </p> 27 <button color="primary" mat-button class="snack-bar-action" (click)="snackBarRef.dismiss()"> 28 Close 29 </button> 30 </div> 31 `, 32 styles: [ 33 ` 34 .snack-bar-container { 35 display: flex; 36 flex-direction: column; 37 } 38 .snack-bar-action { 39 margin-left: 12px; 40 } 41 `, 42 ], 43}) 44export class SnackBarComponent { 45 constructor( 46 @Inject(MatSnackBarRef) 47 public snackBarRef: MatSnackBarRef<SnackBarComponent>, 48 @Inject(MAT_SNACK_BAR_DATA) public messages: string[], 49 ) {} 50} 51