Add no-image placeholder

2022.01
Willem Dantuma 2021-03-01 17:25:40 +01:00
parent 01488ae2e0
commit 47f3238edd
3 changed files with 17 additions and 3 deletions

View File

@ -5,8 +5,12 @@
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="cropper"> <div class="cropper">
<div *ngIf="!isImageLoaded" class="no-image" (click)="fileInput.click()">
<i class="fal fa-image"></i>
<div i18n>No image selected</div>
</div>
<image-cropper #imageCropper <image-cropper #imageCropper
[imageChangedEvent]="imageChangedEvent" [imageChangedEvent]="imageChangedEvent"
[maintainAspectRatio]="true" [maintainAspectRatio]="true"
@ -23,7 +27,7 @@
<span class="btn btn-primary" (click)="fileInput.click()" i18n>Select image</span> <span class="btn btn-primary" (click)="fileInput.click()" i18n>Select image</span>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary" i18n>Apply</button> <button type="submit" class="btn btn-primary" i18n [disabled]="!isImageLoaded">Apply</button>
<button type="button" autofocus class="btn btn-secondary" (click)="modal.close('Save click')" i18n="@@buttonCancel">Cancel</button> <button type="button" autofocus class="btn btn-secondary" (click)="modal.close('Save click')" i18n="@@buttonCancel">Cancel</button>
</div> </div>
</ng-template> </ng-template>

View File

@ -1,4 +1,13 @@
.cropper { .cropper {
position: relative; position: relative;
height: calc(60vh); height: calc(60vh);
}
.no-image {
text-align: center;
}
.no-image i {
font-size: calc(50vh);
color: gray;
} }

View File

@ -21,8 +21,8 @@ export class EditImageModalComponent implements OnInit {
this.modalService.open(this.modal,{ size: 'lg' }); this.modalService.open(this.modal,{ size: 'lg' });
} }
isImageLoaded:boolean = false;
aspectRatio:number = 4/3; aspectRatio:number = 4/3;
imageChangedEvent: any = ''; imageChangedEvent: any = '';
croppedImage: any = ''; croppedImage: any = '';
@ -33,6 +33,7 @@ export class EditImageModalComponent implements OnInit {
this.croppedImage = event.base64; this.croppedImage = event.base64;
} }
imageLoaded(image: LoadedImage) { imageLoaded(image: LoadedImage) {
this.isImageLoaded=true;
} }
cropperReady() { cropperReady() {
// cropper ready // cropper ready