• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/src/anchor/anchor-link.component.ts
1
import { Platform } from '@angular/cdk/platform';
2
import {
3
    ChangeDetectionStrategy,
4
    Component,
5
    ContentChild,
6
    ElementRef,
7
    Input,
8
    OnDestroy,
9
    OnInit,
10
    TemplateRef,
11
    ViewChild,
1✔
12
    ViewEncapsulation
13
} from '@angular/core';
×
14
import { useHostRenderer } from '@tethys/cdk/dom';
×
15

×
16
import { ThyAnchorComponent } from './anchor.component';
17
import { NgIf } from '@angular/common';
18

×
19
/**
20
 * 锚点链接组件,可供锚点跳转
21
 * @name thy-anchor-link,thyAnchorLink
22
 */
×
23
@Component({
×
24
    selector: 'thy-link,thy-anchor-link',
×
25
    exportAs: 'thyLink,thyAnchorLink',
×
26
    preserveWhitespaces: false,
×
27
    template: `
×
28
        <a #linkTitle (click)="goToClick($event)" href="{{ thyHref }}" class="thy-anchor-link-title" title="{{ title }}">
×
29
            <span *ngIf="title; else titleTemplate || thyTemplate">{{ title }}</span>
×
30
        </a>
×
31
        <ng-content></ng-content>
32
    `,
33
    encapsulation: ViewEncapsulation.None,
34
    changeDetection: ChangeDetectionStrategy.OnPush,
×
35
    standalone: true,
36
    imports: [NgIf]
37
})
×
38
export class ThyAnchorLinkComponent implements OnInit, OnDestroy {
39
    title: string | null = '';
40

×
41
    titleTemplate?: TemplateRef<any>;
42

43
    private hostRenderer = useHostRenderer();
×
44

45
    /**
46
     * 锚点链接
×
47
     */
×
48
    @Input() thyHref = '#';
×
49

×
50
    /**
51
     * 文字内容
52
     */
53
    @Input()
×
54
    set thyTitle(value: string | TemplateRef<void>) {
55
        if (value instanceof TemplateRef) {
1✔
56
            this.title = null;
57
            this.titleTemplate = value;
58
        } else {
59
            this.title = value;
60
        }
1✔
61
    }
62

63
    @ContentChild('thyTemplate') thyTemplate!: TemplateRef<void>;
64

65
    @ViewChild('linkTitle', { static: true }) linkTitle!: ElementRef<HTMLAnchorElement>;
66

67
    constructor(public elementRef: ElementRef, private anchorComponent: ThyAnchorComponent, private platform: Platform) {
1✔
68
        this.hostRenderer.addClass('thy-anchor-link');
69
        if (elementRef.nativeElement.tagName.toLowerCase() === 'thy-link') {
70
            console.warn(`'thy-link' and 'thyLink' are deprecated, please use 'thy-anchor-link' and 'thyAnchorLink' instead.`);
71
        }
72
    }
73

74
    ngOnInit(): void {
75
        this.anchorComponent.registerLink(this);
76
    }
77

78
    getLinkTitleElement(): HTMLAnchorElement {
79
        return this.linkTitle.nativeElement;
80
    }
81

82
    setActive(): void {
83
        this.hostRenderer.addClass('thy-anchor-link-active');
84
    }
85

86
    unsetActive(): void {
87
        this.hostRenderer.removeClass('thy-anchor-link-active');
88
    }
89

90
    goToClick(e: Event): void {
91
        e.preventDefault();
92
        e.stopPropagation();
93
        if (this.platform.isBrowser) {
94
            this.anchorComponent.handleScrollTo(this);
95
        }
96
    }
97

98
    ngOnDestroy(): void {
99
        this.anchorComponent.unregisterLink(this);
100
    }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc