WIP: Rearrange code
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<div class="dashboard">
|
||||
|
||||
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
|
||||
<h1 class="no-library-header">
|
||||
Looks like you haven't added a library yet. Let's add one!
|
||||
</h1>
|
||||
<p-button
|
||||
label="Add a Library"
|
||||
icon="pi pi-plus"
|
||||
styleClass="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<ng-template #dashboardScroller>
|
||||
<app-dashboard-scroller [bookListType]="'lastRead'" title="Last Read Books"></app-dashboard-scroller>
|
||||
<app-dashboard-scroller [bookListType]="'latestAdded'" title="Latest Added Books"></app-dashboard-scroller>
|
||||
</ng-template>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,29 @@
|
||||
.dashboard {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dashboard .no-library-header {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.dashboard-no-library {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.dashboard .p-dialog {
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
::ng-deep .p-dialog-mask {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
::ng-deep .p-dialog-mask {
|
||||
backdrop-filter: blur(3px);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {LibraryCreatorComponent} from '../../../book/components/library-creator/library-creator.component';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryService} from '../../../book/service/library.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-dashboard',
|
||||
templateUrl: './main-dashboard.component.html',
|
||||
styleUrls: ['./main-dashboard.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
NgIf,
|
||||
DashboardScrollerComponent,
|
||||
AsyncPipe
|
||||
],
|
||||
providers: [DialogService],
|
||||
})
|
||||
export class MainDashboardComponent {
|
||||
isLibrariesEmpty$: Observable<boolean>;
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
constructor(private libraryService: LibraryService, public dialogService: DialogService) {
|
||||
this.isLibrariesEmpty$ = this.libraryService.libraryState$.pipe(
|
||||
map(state => !state.libraries || state.libraries.length === 0)
|
||||
);
|
||||
}
|
||||
|
||||
createNewLibrary() {
|
||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||
header: 'Create New Library',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '675px',
|
||||
height: '480px',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user