import { Component, computed, inject, signal } from '@angular/core'; import { copyToClipboard } from '@africanies/africanies-core'; import { AfricaniesIconComponent, ICON_NAMES, type IconName } from '@africanies/africanies-icons'; import { ToastService } from '@africanies/africanies-ui'; import { DemoSectionComponent } from '../shared/demo-section.component'; import { PageHeaderComponent } from '../shared/page-header.component'; import { ICONS_USAGE } from '../snippets'; /** * Icon sprite catalog — click a tile to copy an `` usage snippet. */ @Component({ selector: 'app-icons-page', standalone: true, imports: [AfricaniesIconComponent, PageHeaderComponent, DemoSectionComponent], template: `

{{ filtered().length }} of {{ ICON_NAMES.length }} shown

@for (sample of samples; track sample) { } Prefer typed IconName — never free-string icon ids.
@if (copied()) {

Copied {{ copied() }}

}
@for (name of filtered(); track name) { }
@if (!filtered().length) {

No icons match “{{ query() }}”.

}
`, }) export class IconsPage { private readonly toast = inject(ToastService); protected readonly ICON_NAMES = ICON_NAMES; protected readonly query = signal(''); protected readonly copied = signal(null); protected readonly samples: IconName[] = ['airplane', 'warehouse', 'warning']; protected readonly usageCode = ICONS_USAGE; protected readonly filtered = computed(() => { const q = this.query().trim().toLowerCase(); if (!q) { return ICON_NAMES as readonly IconName[]; } return ICON_NAMES.filter((n) => n.includes(q)); }); /** * Build a paste-ready `` usage line for the given registry id. * @param name - Icon slug. * @returns HTML snippet string. */ protected iconSnippet(name: IconName): string { return ``; } /** * Copy the icon usage snippet to the clipboard and confirm via toast. * @param name - Registry id to embed in the snippet. */ protected async copySnippet(name: IconName): Promise { const snippet = this.iconSnippet(name); const ok = await copyToClipboard(snippet); if (!ok) { this.toast.error('Could not copy to the clipboard.'); this.copied.set(null); return; } this.copied.set(snippet); this.toast.success(`Copied ${snippet}`); window.setTimeout(() => { if (this.copied() === snippet) { this.copied.set(null); } }, 1600); } }