feat: auto-hide search
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<button
|
<button
|
||||||
(click)="goToReader(chapter.number, chapter.volume)"
|
(click)="goToReader(chapter.number, chapter.volume)"
|
||||||
[title]="chapter.name"
|
[title]="chapter.name"
|
||||||
class="p-3 text-white bg-slate-600 w-[400px] mt-3 rounded-lg"
|
class="p-3 text-white bg-slate-600 w-[300px] mt-3 rounded-lg"
|
||||||
>
|
>
|
||||||
<h3>
|
<h3>
|
||||||
<strong>{{ chapter.number }}.</strong> {{ chapter.name || "Нет названия" }}
|
<strong>{{ chapter.number }}.</strong> {{ chapter.name || "Нет названия" }}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<button class="p-3 text-white bg-slate-600 w-[400px] mt-5 rounded-lg" (click)="goToReader()">
|
<button class="p-3 text-white bg-slate-600 w-[300px] mt-5 rounded-lg" (click)="goToReader()">
|
||||||
Читать
|
Читать
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
||||||
(keydown.enter)="search()"
|
(keydown.enter)="search()"
|
||||||
/>
|
/>
|
||||||
<button class="align-middle w-[100px] text-center" type="submit" (click)="search()">
|
<button
|
||||||
|
class="align-middle w-[100px] text-center border-0 flex flex-col items-center justify-center"
|
||||||
|
type="submit"
|
||||||
|
(click)="search()"
|
||||||
|
>
|
||||||
<span class="text-sm text-black h-full">Поиск</span>
|
<span class="text-sm text-black h-full">Поиск</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
|
import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
||||||
|
import { filter } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-header",
|
selector: "app-header",
|
||||||
@@ -15,7 +16,16 @@ export class HeaderComponent implements AfterViewInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
) {}
|
) {
|
||||||
|
this.router.events
|
||||||
|
.pipe(filter((event) => event instanceof NavigationEnd))
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.subscribe((val: any) => {
|
||||||
|
if (val.url.startsWith("/detail") || val.url.startsWith("/reader")) {
|
||||||
|
this.menuOpened = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
changeMenu() {
|
changeMenu() {
|
||||||
this.menuOpened = !this.menuOpened;
|
this.menuOpened = !this.menuOpened;
|
||||||
}
|
}
|
||||||
@@ -25,7 +35,7 @@ export class HeaderComponent implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get searchBarClass(): string {
|
get searchBarClass(): string {
|
||||||
return `search-bar bg-slate-300 md:w-[50%] w-full md:m-0 ms-2 me-2 max-h-6 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
|
return `search-bar bg-slate-300 md:w-[50%] w-full md:m-0 ms-2 me-2 md:h-6 h-10 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<h1>It's home component</h1>
|
<h1>It's home component</h1>
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center w-full px-3">
|
||||||
@for (item of items; track $index) {
|
@for (item of items; track $index) {
|
||||||
<button (click)="getDetails(item.slug_url)" title="{{ item.name }}" class="mb-6">
|
<button (click)="getDetails(item.slug_url)" title="{{ item.name }}" class="mb-6 w-full">
|
||||||
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4">
|
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full">
|
||||||
<h1>{{ item.rus_name }}</h1>
|
<h1>{{ item.rus_name }}</h1>
|
||||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.route.queryParams.subscribe((params) => {
|
||||||
const search = params["search"];
|
const search = params["search"];
|
||||||
console.log(params);
|
|
||||||
if (search) {
|
if (search) {
|
||||||
this.searchService.search(search);
|
this.searchService.search(search);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user