Polish main dashboard UI and improve aesthetics

This commit is contained in:
aditya.chandel
2025-08-13 17:41:49 -06:00
committed by Aditya Chandel
parent 800cc4054f
commit b3af1723df
7 changed files with 272 additions and 71 deletions
@@ -22,20 +22,20 @@ public class BookReviewController {
}
@PostMapping("/book/{bookId}/refresh")
@PreAuthorize("@securityUtil.canManipulateLibrary() or @securityUtil.isAdmin()")
@PreAuthorize("@securityUtil.canEditMetadata() or @securityUtil.isAdmin()")
public List<BookReview> refreshReviews(@PathVariable Long bookId) {
return bookReviewService.refreshReviews(bookId);
}
@DeleteMapping("/{id}")
@PreAuthorize("@securityUtil.canManipulateLibrary() or @securityUtil.isAdmin()")
@PreAuthorize("@securityUtil.canEditMetadata() or @securityUtil.isAdmin()")
public ResponseEntity<Void> delete(@PathVariable Long id) {
bookReviewService.delete(id);
return ResponseEntity.noContent().build();
}
@DeleteMapping("/book/{bookId}")
@PreAuthorize("@securityUtil.canManipulateLibrary() or @securityUtil.isAdmin()")
@PreAuthorize("@securityUtil.canEditMetadata() or @securityUtil.isAdmin()")
public ResponseEntity<Void> deleteAllByBookId(@PathVariable Long bookId) {
bookReviewService.deleteAllByBookId(bookId);
return ResponseEntity.noContent().build();
@@ -1,30 +1,38 @@
<p class="dashboard-scroller-title">{{ title }}</p>
<div class="dashboard-scroller-container">
<h2 class="dashboard-scroller-title">{{ title }}</h2>
@if (!books || books.length === 0) {
<div class="dashboard-scroller-no-books">
<p class="text-sm">
{{ bookListType === 'lastRead' ? "You haven't read any books yet!" : "No books have been added to BookLore!" }}
</p>
</div>
}
@if (books) {
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
#scrollContainer
[horizontal]="true">
@for (book of books; track book) {
<div class="dashboard-scroller-card">
<app-book-card [book]="book" [isCheckboxEnabled]="false"></app-book-card>
@if (!books || books.length === 0) {
<div class="dashboard-scroller-no-books">
<div class="empty-state-icon">
<i class="pi pi-book"></i>
</div>
}
</div>
}
<p>
{{ bookListType === 'lastRead' ? "You haven't read any books yet! Start your reading journey." : "No books have been added to BookLore yet! Add your first book to get started." }}
</p>
</div>
}
@if ( books === null) {
<div>
<p class="text-sm">Failed to load books! :(</p>
</div>
}
@if (books) {
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
#scrollContainer
[horizontal]="true">
@for (book of books; track book) {
<div class="dashboard-scroller-card">
<app-book-card [book]="book" [isCheckboxEnabled]="false"></app-book-card>
</div>
}
</div>
}
@if (books === null) {
<div class="dashboard-scroller-error">
<div class="error-icon">
<i class="pi pi-exclamation-triangle"></i>
</div>
<p>Failed to load books! Please try refreshing the page.</p>
</div>
}
</div>
@@ -1,16 +1,74 @@
.dashboard-scroller-container {
border-radius: 20px;
padding: 1rem 2rem 0rem 2rem;
margin-bottom: 2rem;
position: relative;
overflow: hidden;
backdrop-filter: blur(20px);
border: color-mix(in srgb, var(--p-surface-500), transparent 50%) 1px solid;
}
.dashboard-scroller-title {
text-align: left;
font-size: 1.5rem;
margin-bottom: 0.625rem;
padding: 0.3125rem;
font-weight: 800;
margin-bottom: 1rem;
padding: 0;
background: linear-gradient(135deg, #ffffff, #e2e8f0, #3b82f6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
position: relative;
z-index: 2;
letter-spacing: -0.02em;
&::after {
content: '';
position: absolute;
bottom: -6px;
left: 0;
width: 80px;
height: 4px;
background: linear-gradient(90deg, var(--primary-color), var(--primary-color));
border-radius: 2px;
}
}
.dashboard-scroller-no-books {
padding-top: 5rem;
padding-bottom: 5rem;
padding: 3rem 2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
position: relative;
z-index: 2;
.empty-state-icon {
width: 25px;
height: 25px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 2rem;
position: relative;
i {
font-size: 2rem;
color: white;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
}
p {
color: #e2e8f0;
font-size: 1rem;
font-weight: 500;
max-width: 400px;
line-height: 1.7;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
}
.dashboard-scroller-infinite {
@@ -18,35 +76,122 @@
overflow-x: auto;
overflow-y: hidden;
scroll-snap-type: x mandatory;
padding: 0.25rem;
gap: 1.25rem;
padding: 1rem 0.5rem 1rem 0.5rem;
gap: 2rem;
height: 100%;
width: 100%;
position: relative;
z-index: 2;
scrollbar-color: var(--primary-color) rgba(20, 20, 30, 0.5);
}
.dashboard-scroller-card {
height: 220px;
width: 135px;
height: 200px;
width: 116px;
flex-basis: 124px;
flex-shrink: 0;
flex-grow: 0;
flex-basis: 135px;
scroll-snap-align: start;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
&:hover {
transform: translateY(-4px) scale(1.04);
filter: drop-shadow(0 25px 50px rgba(0, 0, 0, 0.4));
&::after {
opacity: 1;
transform: scale(1.2);
}
&::before {
opacity: 0.8;
}
}
&::before {
content: '';
position: absolute;
inset: -2px;
background: linear-gradient(
135deg,
color-mix(in srgb, var(--p-primary-400), transparent 70%),
color-mix(in srgb, var(--p-primary-800), transparent 70%)
);
border-radius: 12px;
z-index: -1;
opacity: 0;
transition: opacity 0.4s ease;
filter: blur(8px);
}
&::after {
content: '';
position: absolute;
bottom: -12px;
left: 15%;
right: 15%;
height: 5px;
background: linear-gradient(
90deg,
transparent,
var(--p-primary-500),
transparent
);
border-radius: 50%;
opacity: 0;
transition: all 0.4s ease;
filter: blur(6px);
}
}
@media (max-width: 767px) {
.dashboard-scroller-container {
padding: 1.5rem;
margin-bottom: 2rem;
border-radius: 16px;
}
.dashboard-scroller-title {
font-size: 1.25rem;
padding: 0.25rem;
font-size: 1.75rem;
margin-bottom: 1rem;
&::after {
width: 50px;
height: 3px;
}
}
.dashboard-scroller-card {
height: 200px;
width: 120px;
flex-basis: 110px;
height: 230px;
width: 135px;
flex-basis: 135px;
}
.dashboard-scroller-infinite {
gap: 1rem;
padding: 0.25rem 0.5rem;
gap: 1.5rem;
padding: 0.75rem 0.25rem 1.5rem 0.25rem;
&::-webkit-scrollbar {
height: 8px;
}
}
.dashboard-scroller-no-books {
padding: 4rem 1rem;
.empty-state-icon {
width: 80px;
height: 80px;
i {
font-size: 2rem;
}
}
p {
font-size: 1.1rem;
}
}
}
@@ -13,7 +13,7 @@ import {Book} from '../../../book/model/book.model';
InfiniteScrollDirective,
BookCardComponent,
ProgressSpinnerModule
],
],
standalone: true
})
export class DashboardScrollerComponent {
@@ -23,5 +23,4 @@ export class DashboardScrollerComponent {
@Input() books!: Book[] | null;
@ViewChild('scrollContainer') scrollContainer!: ElementRef;
}
@@ -1,19 +1,33 @@
<div class="dashboard-container">
@if ((bookState$ | async)?.loaded === false) {
<p-progressSpinner styleClass="spinner center-spinner"></p-progressSpinner>
<div class="flex items-center justify-center h-full">
<p-progressSpinner
styleClass="spinner center-spinner"
[style]="{'width': '60px', 'height': '60px'}"
strokeWidth="3"
fill="transparent"
animationDuration="1.5s">
</p-progressSpinner>
</div>
}
@if ((bookState$ | async)?.loaded === true) {
<div class="dashboard">
<div>
<div class="w-full">
@if (isLibrariesEmpty$ | async) {
<div class="dashboard-no-library">
@if ((userService.userState$ | async)?.user?.permissions; as permissions) {
<div>
@if (permissions.admin || permissions.canManipulateLibrary) {
<div>
<h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1>
<h1 class="no-library-header">
Welcome to BookLore! 📚<br>
Let's create your first library
</h1>
<p class="text-gray-300 text-lg mb-8 max-w-md mx-auto leading-relaxed">
A library is where all your books live. Start building your digital collection today!
</p>
<p-button
label="Add a Library"
label="Create Your Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
@@ -27,21 +41,17 @@
<app-dashboard-scroller
[books]="lastReadBooks$ | async"
[bookListType]="'lastRead'"
[title]="'Last Read Books'">
[title]="'Continue Reading'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="latestAddedBooks$ | async"
[title]="'Latest Added Books'">
[title]="'Recently Added'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="randomBooks$ | async"
[title]="'Discover Random Reads'">
[title]="'Discover Something New'">
</app-dashboard-scroller>
}
</div>
@@ -1,11 +1,39 @@
.dashboard-container {
height: calc(100dvh - 6.7rem);
overflow-y: auto;
position: relative;
&::before {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
z-index: 0;
}
&::-webkit-scrollbar {
width: 12px;
}
&::-webkit-scrollbar-track {
background: rgba(20, 20, 30, 0.5);
border-radius: 10px;
}
scrollbar-width: thin;
scrollbar-color: var(--primary-color) rgba(20, 20, 30, 0.5);
}
@media (max-width: 768px) {
.dashboard-container {
height: calc(100dvh - 5rem);
&::-webkit-scrollbar {
width: 8px;
}
}
}
@@ -14,17 +42,30 @@
align-items: center;
justify-content: center;
text-align: center;
position: relative;
z-index: 1;
}
.dashboard .no-library-header {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--text-color);
font-size: 2rem;
font-weight: 700;
margin-bottom: 2rem;
background: linear-gradient(135deg, #ffffff, #e2e8f0, var(--p-primary-500));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
letter-spacing: -0.02em;
}
.dashboard-no-library {
margin-top: 3rem;
padding: 3rem;
background: var(--p-surface-900);
border-radius: 24px;
border: 1px solid rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
position: relative;
overflow: hidden;
}
.dashboard .p-dialog {
@@ -2,15 +2,14 @@ import {Component, inject, OnInit} 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 {filter, Observable, take} from 'rxjs';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {Button} from 'primeng/button';
import { AsyncPipe } from '@angular/common';
import {AsyncPipe} from '@angular/common';
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
import {BookService} from '../../../book/service/book.service';
import {BookState} from '../../../book/model/state/book-state.model';
import {Book} from '../../../book/model/book.model';
import {Divider} from 'primeng/divider';
import {UserService} from '../../../settings/user-management/user.service';
import {ProgressSpinner} from 'primeng/progressspinner';
@@ -22,9 +21,8 @@ import {ProgressSpinner} from 'primeng/progressspinner';
Button,
DashboardScrollerComponent,
AsyncPipe,
Divider,
ProgressSpinner
],
],
providers: [DialogService],
standalone: true
})