angular/adev/shared-docs/components/search-history/search-history.component.html
hawkgs e678050794 docs(docs-infra): implement search history (#61866)
Add history of searches to the search dialog of A.dev.

PR Close #61866
2025-06-06 12:36:23 -07:00

66 lines
2.1 KiB
HTML

@let items = history.items();
@if (items.recent.length) {
<p class="title">Recent</p>
<ul class="history-results recent">
@for (item of items.recent; track item.id; let idx = $index) {
<li docsSearchItem [item]="item" (mouseenter)="onMouseEnter($event, idx)">
<a
[routerLink]="'/' + item.url | relativeLink: 'pathname'"
[fragment]="item.url | relativeLink: 'hash'"
(click)="history.addItem(item)"
>
<i role="presentation" class="material-symbols-outlined" aria-hidden="true"> history </i>
<span [innerHTML]="item.labelHtml"></span>
</a>
<button
type="button"
class="fav-btn"
(click)="history.makeFavorite(item)"
title="Make favorite"
>
<i role="presentation" class="material-symbols-outlined" aria-hidden="true"> star </i>
</button>
<button
type="button"
class="remove-btn"
(click)="history.removeItem(item)"
title="Remove item"
>
<i role="presentation" class="material-symbols-outlined" aria-hidden="true"> close </i>
</button>
</li>
}
</ul>
}
@if (items.favorite.length) {
<p class="title">Favorite</p>
<ul class="history-results favorite">
@for (item of items.favorite; track item.id; let idx = $index) {
<li
docsSearchItem
[item]="item"
(mouseenter)="onMouseEnter($event, items.recent.length + idx)"
>
<a
[routerLink]="'/' + item.url | relativeLink: 'pathname'"
[fragment]="item.url | relativeLink: 'hash'"
>
<i role="presentation" class="material-symbols-outlined" aria-hidden="true"> star </i>
<span [innerHTML]="item.labelHtml"></span>
</a>
<button
type="button"
class="remove-btn"
(click)="history.removeItem(item)"
title="Remove item"
>
<i role="presentation" class="material-symbols-outlined" aria-hidden="true"> close </i>
</button>
</li>
}
</ul>
}