Add keyboard handlers and focus support to clickable UI affordances across reader dialogs, metadata views, cards, and layout controls. Keep the existing click behavior intact while making non-button elements operable from the keyboard and clearing the remaining template interaction accessibility backlog. Validation: just ui lint
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
|
import {Tooltip} from 'primeng/tooltip';
|
|
|
|
export type DocType = 'kobo' | 'opds' | 'metadataManager' | 'koReader' | 'email'
|
|
| 'amazonCookie' | 'fetchConfig' | 'hardcover' | 'taskManagement' | 'fileNamePatterns'
|
|
| 'authentication';
|
|
|
|
@Component({
|
|
selector: 'app-external-doc-link',
|
|
standalone: true,
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
imports: [Tooltip],
|
|
template: `
|
|
<i class="pi pi-external-link external-link-icon"
|
|
[pTooltip]="tooltip"
|
|
[tooltipPosition]="tooltipPosition"
|
|
[style.font-size]="size"
|
|
(click)="openLink()"
|
|
(keydown.enter)="openLink()"
|
|
role="button"
|
|
tabindex="0"
|
|
style="cursor: pointer;">
|
|
</i>
|
|
`,
|
|
styles: [`
|
|
.external-link-icon {
|
|
color: #0ea5e9 !important;
|
|
}
|
|
`]
|
|
})
|
|
export class ExternalDocLinkComponent {
|
|
private readonly BASE_URL = 'https://grimmory.org/docs';
|
|
|
|
private readonly DOC_URLS: Record<DocType, string> = {
|
|
kobo: `${this.BASE_URL}/integration/kobo`,
|
|
opds: `${this.BASE_URL}/integration/opds`,
|
|
metadataManager: `${this.BASE_URL}/metadata/metadata-manager`,
|
|
koReader: `${this.BASE_URL}/integration/koreader`,
|
|
email: `${this.BASE_URL}/email-setup`,
|
|
amazonCookie: `${this.BASE_URL}/metadata/amazon-cookie`,
|
|
hardcover: `${this.BASE_URL}/metadata/hardcover-token`,
|
|
fetchConfig: `${this.BASE_URL}/metadata/metadata-fetch-configuration`,
|
|
taskManagement: `${this.BASE_URL}/tools/task-manager`,
|
|
fileNamePatterns: `${this.BASE_URL}/metadata/file-naming-patterns`,
|
|
authentication: `${this.BASE_URL}/authentication/overview#setting-up-oidc`
|
|
};
|
|
|
|
@Input() docType!: DocType;
|
|
@Input() tooltip: string = 'View documentation';
|
|
@Input() tooltipPosition: 'top' | 'bottom' | 'left' | 'right' = 'right';
|
|
@Input() size: string = '1rem';
|
|
|
|
openLink(): void {
|
|
const url = this.DOC_URLS[this.docType];
|
|
if (url) {
|
|
window.open(url, '_blank');
|
|
}
|
|
}
|
|
}
|