Improve login and initial user setup screen appearance (#1336)

This commit is contained in:
Aditya Chandel
2025-10-13 13:02:27 -06:00
committed by GitHub
parent 165d7ef7ad
commit 34d195bbbe
26 changed files with 1136 additions and 219 deletions
@@ -94,7 +94,7 @@
top: 50%;
left: 10px;
transform: translateY(-50%);
color: var(--text-color-secondary);
color: var(--text-secondary-color);
font-size: 1.0rem;
pointer-events: none;
}
@@ -82,7 +82,7 @@
flex-direction: column;
overflow: hidden;
position: relative;
border: 1px solid rgba(255, 255, 255, 0.1);
border: 1px solid var(--p-content-border-color);
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
@@ -124,7 +124,7 @@
flex-direction: column;
overflow: hidden;
position: relative;
border: 1px solid rgba(255, 255, 255, 0.1);
border: 1px solid var(--p-content-border-color);
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
@media (max-width: 768px) {
@@ -1,14 +1,15 @@
<div class="ml-2 md:ml-5 relative w-full max-w-[500px]">
<!-- Desktop view -->
<p-iconfield class="w-full sm:flex">
<p-inputicon styleClass="pi pi-search"/>
<div class="book-searcher-container">
<p-iconfield class="search-iconfield" [class.focused]="isSearchFocused" [class.has-results]="isDropdownOpen">
<p-inputicon class="pi pi-search"/>
<input
type="text"
pInputText
[(ngModel)]="searchQuery"
(input)="onSearchInputChange()"
(focus)="isSearchFocused = true"
(blur)="onSearchBlur()"
placeholder="Title, Author, Series, Genre, or ISBN..."
class="w-full pr-10"
class="search-input"
/>
@if (searchQuery) {
<p-button
@@ -16,35 +17,45 @@
(click)="clearSearch()"
[text]="true"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2 hidden lg:inline-flex"
class="clear-search-btn"
aria-label="Clear Search">
</p-button>
}
</p-iconfield>
<!-- Search results below small screen search input -->
@if (books.length > 0 || searchQuery) {
<div
class="search-dropdown layout-menu w-[300px] sm:w-[600px]"
class="search-dropdown layout-menu"
[class.show]="(books.length > 0)"
>
@if (books.length > 0) {
@for (book of books; track book) {
<div class="search-dropdown-item flex flex-col" (click)="onBookClick(book)">
<div class="flex flex-row w-full p-2">
<div class="search-dropdown-item" (click)="onBookClick(book)">
<div class="search-item-content">
<img
[attr.src]="urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn)"
alt="Book Cover"
class="search-book-cover"
/>
<div class="search-book-details">
<div class="flex items-center">
<p class="search-book-name text font-medium truncate">
<div class="search-book-title-container">
<p class="search-book-name">
{{ book.metadata?.title | slice: 0:70 }}
</p>
</div>
@if (book.metadata?.authors?.length ?? 0 > 0) {
<p class="italic text-gray-300">by: {{ getAuthorNames(book.metadata?.authors) }}</p>
<div class="search-book-meta-line">
@if (book.metadata?.authors?.length ?? 0 > 0) {
<p class="search-book-authors">by {{ getAuthorNames(book.metadata?.authors) }}</p>
}
@if (getPublishedYear(book.metadata?.publishedDate)) {
<span class="metadata-badge year-badge">{{ getPublishedYear(book.metadata?.publishedDate) }}</span>
}
</div>
@if (getSeriesInfo(book.metadata?.seriesName, book.metadata?.seriesNumber)) {
<div class="search-book-series metadata-badge series-badge">
<i class="pi pi-book"></i>
<span>{{ getSeriesInfo(book.metadata?.seriesName, book.metadata?.seriesNumber) }}</span>
</div>
}
</div>
</div>
@@ -52,7 +63,7 @@
</div>
}
} @else {
<div class="search-dropdown-item px-4 py-2">
<div class="search-dropdown-item no-results">
<span>No results found</span>
</div>
}
@@ -1,65 +1,265 @@
.search-icon {
position: absolute;
top: 50%;
left: 10px;
transform: translateY(-50%);
color: var(--text-color-secondary);
font-size: 1.0rem;
pointer-events: none;
.book-searcher-container {
margin-left: 0.5rem;
position: relative;
width: 100%;
@media (min-width: 768px) {
margin-left: 1.25rem;
max-width: 315px;
transition: max-width 0.3s ease;
}
&:has(.search-iconfield.focused),
&:has(.search-iconfield.has-results) {
@media (min-width: 768px) {
max-width: 100%;
}
}
}
.search-iconfield {
width: 100%;
@media (min-width: 640px) {
display: flex;
}
@media (min-width: 768px) {
transition: all 0.3s ease;
}
}
.search-input {
width: 100%;
padding-left: 30px;
padding-right: 2.5rem;
height: 2.5rem;
line-height: 2.5rem;
font-size: 1rem;
}
.clear-btn {
color: var(--text-color-secondary);
.clear-search-btn {
position: absolute;
right: 10px;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
display: none;
@media (min-width: 1024px) {
display: inline-flex;
}
}
.search-dropdown {
position: absolute;
top: calc(100% + 0.5rem);
left: 0;
background-color: var(--code-background);
width: 300px;
background-color: var(--card-background);
border: 1px solid var(--border-color);
border-radius: var(--card-border);
border-radius: 8px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06),
0 10px 15px -3px rgba(0, 0, 0, 0.1);
z-index: 1000;
max-height: 500px;
max-height: 70vh;
overflow-y: auto;
opacity: 0;
height: 0;
transition: opacity 0.3s ease, height 0.3s ease;
transform: translateY(-10px);
transition: opacity 0.2s ease, transform 0.2s ease, height 0.2s ease;
@media (min-width: 640px) {
width: 100%;
max-width: 600px;
}
&::-webkit-scrollbar {
width: 8px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 4px;
}
&::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary-color);
}
}
.search-dropdown.show {
opacity: 1;
height: auto;
transform: translateY(0);
}
.search-dropdown-item {
display: flex;
align-items: center;
flex-direction: column;
cursor: pointer;
transition: background-color 0.3s;
transition: background-color 0.2s ease;
&:first-child {
border-radius: 8px 8px 0 0;
}
&:last-child {
border-radius: 0 0 8px 8px;
::ng-deep .p-divider {
display: none;
}
}
&:hover {
background-color: var(--surface-hover);
}
&.no-results {
padding: 2rem 1rem;
text-align: center;
color: var(--text-secondary-color);
font-style: italic;
}
::ng-deep .p-divider {
margin: 0;
&::before {
border-top-color: var(--border-color);
opacity: 0.5;
}
}
}
.search-item-content {
display: flex;
flex-direction: row;
align-items: flex-start;
gap: 1rem;
width: 100%;
padding: 0.75rem 1rem;
}
.search-book-cover {
width: 35px;
height: 47px;
width: 50px;
height: 67px;
min-width: 50px;
object-fit: cover;
max-width: 100px;
max-height: 150px;
border-radius: 4px;
margin-right: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
background-color: var(--surface-ground);
}
.search-book-details {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.search-book-title-container {
display: flex;
align-items: flex-start;
}
.search-book-name {
font-weight: 600;
font-size: 0.95rem;
line-height: 1.4;
color: var(--text-color);
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-word;
margin: 0;
}
.search-book-meta-line {
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
}
.search-book-authors {
font-size: 0.9rem;
font-style: italic;
color: var(--text-secondary-color);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin: 0;
flex: 1;
min-width: 0;
}
.search-book-year {
font-size: 0.8rem;
color: var(--text-secondary-color);
background-color: var(--surface-ground);
padding: 0.125rem 0.5rem;
border-radius: 4px;
white-space: nowrap;
font-weight: 500;
}
.search-book-series {
display: flex;
align-items: center;
gap: 0.375rem;
font-size: 0.8rem;
color: var(--primary-color);
background-color: rgba(var(--primary-color-rgb, 59, 130, 246), 0.1);
padding: 0.075rem 0.125rem;
border-radius: 4px;
width: fit-content;
i {
font-size: 0.75rem;
}
span {
font-weight: 500;
}
}
.search-book-metadata {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
.metadata-badge {
display: inline-flex;
align-items: center;
gap: 0.25rem;
font-size: 0.8rem;
padding: 0.1rem 0.25rem;
border-radius: 4px;
background-color: var(--surface-hover);
color: var(--text-secondary-color);
white-space: nowrap;
i {
font-size: 0.7rem;
}
&.series-badge {
background-color: rgba(59, 130, 246, 0.1);
color: rgb(59, 130, 246);
}
&.year-badge {
background-color: rgba(34, 197, 94, 0.1);
color: rgb(34, 197, 94);
}
}
@@ -1,5 +1,5 @@
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {BehaviorSubject, of, Subject, Subscription} from 'rxjs';
import {BehaviorSubject, of, Subscription} from 'rxjs';
import {catchError, switchMap} from 'rxjs/operators';
import {Book} from '../../model/book.model';
import {FormsModule} from '@angular/forms';
@@ -34,6 +34,7 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
books: Book[] = [];
#searchSubject = new BehaviorSubject<string>('');
#subscription!: Subscription;
isSearchFocused = false;
private bookService = inject(BookService);
private router = inject(Router);
@@ -41,24 +42,16 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
private headerFilter = new HeaderFilter(this.#searchSubject.asObservable());
ngOnInit(): void {
this.initializeSearch();
}
initializeSearch(): void {
this.#subscription = this.bookService.bookState$.pipe(
switchMap(bookState => this.headerFilter.filter(bookState)),
catchError((error) => {
console.error('Error while searching books:', error);
return of({books: [], loaded: true, error: null});
})
catchError(() => of({books: [], loaded: true, error: null}))
).subscribe({
next: (filteredState) => {
const term = this.searchQuery.trim();
this.books = term.length >= 2
? (filteredState.books || []).slice(0, 50)
: [];
},
error: (error) => console.error('Subscription error:', error)
}
});
}
@@ -66,6 +59,20 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
return authors?.join(', ') || 'Unknown Author';
}
getPublishedYear(publishedDate: string | undefined): string | null {
if (!publishedDate) return null;
const year = publishedDate.split('-')[0];
return year && year.length === 4 ? year : null;
}
getSeriesInfo(seriesName: string | undefined, seriesNumber: number | null | undefined): string | null {
if (!seriesName) return null;
if (seriesNumber) {
return `${seriesName} #${seriesNumber}`;
}
return seriesName;
}
onSearchInputChange(): void {
this.#searchSubject.next(this.searchQuery.trim());
}
@@ -82,6 +89,18 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
this.books = [];
}
get isDropdownOpen(): boolean {
return this.books.length > 0;
}
onSearchBlur(): void {
setTimeout(() => {
if (!this.isDropdownOpen) {
this.isSearchFocused = false;
}
}, 200);
}
ngOnDestroy(): void {
if (this.#subscription) {
this.#subscription.unsubscribe();
@@ -1,5 +1,5 @@
@if (filteredBooks$ | async; as books) {
<div class="rounded-xl overflow-hidden">
<div class="rounded-xl overflow-hidden border-[1px] border-solid border-[var(--p-content-border-color)]">
<p-tabs [value]="tab" lazy="true" scrollable>
<p-tablist>
<p-tab value="view">
@@ -102,7 +102,6 @@ export interface BookMetadata {
providerBookId?: string;
thumbnailUrl?: string | null;
reviews?: BookReview[];
titleLocked?: boolean;
subtitleLocked?: boolean;
publisherLocked?: boolean;
@@ -134,7 +133,6 @@ export interface BookMetadata {
tagsLocked?: boolean;
coverLocked?: boolean;
reviewsLocked?: boolean;
[key: string]: any;
}
@@ -203,7 +201,6 @@ export interface BookSetting {
epubSettings?: EpubViewerSetting;
cbxSettings?: CbxViewerSetting;
newPdfSettings?: NewPdfReaderSetting;
[key: string]: any;
}