Initial commit

This commit is contained in:
aditya.chandel
2024-12-13 12:58:23 -07:00
commit baff376b9c
414 changed files with 552987 additions and 0 deletions
@@ -0,0 +1,11 @@
<div class="dashboard">
<h1 *ngIf="isLibrariesEmpty" class="no-library-header">
Looks like you haven't added a library yet. Let's add one!
</h1>
<p-button *ngIf="isLibrariesEmpty"
label="Add a Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary($event)">
</p-button>
</div>
@@ -0,0 +1,27 @@
.dashboard {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 5rem;
text-align: center;
.no-library-header {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--text-color)
}
.p-dialog {
max-width: 90%; /* Ensure the dialog doesn't overflow the viewport */
}
}
::ng-deep .p-dialog-mask {
background-color: rgba(0, 0, 0, 0.5); /* Darken the background with 50% opacity */
}
/* You can also adjust the blur if you want */
::ng-deep .p-dialog-mask {
backdrop-filter: blur(3px); /* Optional: Apply blur to the background */
}
@@ -0,0 +1,51 @@
import { Component, WritableSignal } from '@angular/core';
import { LibraryService } from '../../service/library.service';
import { Library } from '../../model/library.model';
import { Button } from 'primeng/button';
import { NgIf } from '@angular/common';
import { LibraryCreatorComponent } from '../library-creator/library-creator.component';
import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
@Component({
selector: 'app-home-page',
templateUrl: './dashboard.component.html',
imports: [
Button,
NgIf
],
styleUrls: ['./dashboard.component.scss'],
providers: [DialogService], // Ensure the DialogService is available
})
export class DashboardComponent {
private libraries: WritableSignal<Library[]>;
ref: DynamicDialogRef | undefined;
constructor(private libraryService: LibraryService, public dialogService: DialogService) {
this.libraries = this.libraryService.libraries;
}
get isLibrariesEmpty(): boolean {
return this.libraries()?.length === 1;
}
createNewLibrary(event: MouseEvent) {
const buttonRect = (event.target as HTMLElement).getBoundingClientRect();
const dialogWidthPercentage = 50; // Use percentage-based width
const viewportWidth = window.innerWidth;
const dialogWidth = (dialogWidthPercentage / 100) * viewportWidth;
const leftPosition = buttonRect.left + (buttonRect.width / 2) - (dialogWidth / 2);
this.ref = this.dialogService.open(LibraryCreatorComponent, {
modal: true,
width: `${dialogWidthPercentage}%`, // Dynamic width
height: 'auto', // Let height adapt to content
style: {
position: 'absolute',
top: `${buttonRect.bottom + 10}px`, // Position below the button
left: `${Math.max(leftPosition, 0)}px`, // Ensure it stays within the viewport
},
});
}
}