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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

10.81
/src/vote/vote.component.ts
1
import { useHostRenderer } from '@tethys/cdk/dom';
2
import { Component, contentChild, effect, input, TemplateRef } from '@angular/core';
3
import { ThyIcon } from 'ngx-tethys/icon';
4
import { NgTemplateOutlet } from '@angular/common';
5
import { coerceBooleanProperty } from 'ngx-tethys/util';
6

7
export type ThyVoteSizes = 'default' | 'sm';
8

9
export type ThyVoteType = 'primary' | 'success' | 'primary-weak' | 'success-weak';
10

11
export type ThyVoteLayout = 'vertical' | 'horizontal';
12

13
/**
14
 * 投票组件
1✔
15
 * @name thy-vote,[thyVote]
UNCOV
16
 * @order 10
×
UNCOV
17
 */
×
UNCOV
18
@Component({
×
19
    selector: 'thy-vote,[thyVote]',
UNCOV
20
    templateUrl: './vote.component.html',
×
UNCOV
21
    host: {
×
22
        class: 'thy-vote',
UNCOV
23
        '[class.has-voted]': 'thyHasVoted()',
×
UNCOV
24
        '[class.thy-vote-disabled]': `thyDisabled()`
×
UNCOV
25
    },
×
26
    imports: [ThyIcon, NgTemplateOutlet]
UNCOV
27
})
×
UNCOV
28
export class ThyVote {
×
29
    private hostRenderer = useHostRenderer();
×
30

UNCOV
31
    /**
×
UNCOV
32
     * 大小,thyLayout="vertical" 时,支持: sm | default
×
UNCOV
33
     */
×
UNCOV
34
    readonly thySize = input<ThyVoteSizes, ThyVoteSizes>('default', {
×
UNCOV
35
        transform: (value: ThyVoteSizes) => value || 'default'
×
36
    });
37

38
    /**
UNCOV
39
     * 标签类型: primary | success | primary-weak | success-weak
×
UNCOV
40
     */
×
UNCOV
41
    readonly thyVote = input<ThyVoteType, ThyVoteType>('primary', {
×
42
        transform: (value: ThyVoteType) => value || 'primary'
UNCOV
43
    });
×
UNCOV
44

×
UNCOV
45
    /**
×
UNCOV
46
     * 是否是偏圆型
×
47
     */
48
    readonly thyRound = input(false, { transform: coerceBooleanProperty });
1✔
49

1✔
50
    /**
51
     * 布局: horizontal | vertical
52
     */
53
    readonly thyLayout = input<ThyVoteLayout, ThyVoteLayout>('horizontal', {
54
        transform: (value: ThyVoteLayout) => value || 'horizontal'
55
    });
56

57
    /**
58
     * 赞同的数量
59
     */
60
    readonly thyVoteCount = input<number | string>();
61

1✔
62
    /**
63
     * 图标
64
     */
65
    readonly thyIcon = input<string, string>('thumb-up', {
66
        transform: (value: string) => value || 'thumb-up'
67
    });
68

69
    /**
70
     * 是否赞同
71
     */
72
    readonly thyHasVoted = input(false, { transform: coerceBooleanProperty });
73

74
    /**
75
     * 是否禁用
76
     */
77
    readonly thyDisabled = input(false, { transform: coerceBooleanProperty });
78

79
    /**
80
     * 自定义Icon模板
81
     */
82
    readonly voteIcon = contentChild<TemplateRef<any>>('voteIcon');
83

84
    constructor() {
85
        effect(() => {
86
            this.setClassesByType();
87
        });
88
    }
89

90
    private setClassesByType() {
91
        const classNames = [];
92

93
        if (this.thyRound()) {
94
            classNames.push('thy-vote-round');
95
        }
96
        classNames.push(`thy-vote-${this.thyVote()}`);
97
        classNames.push(`thy-vote-${this.thyLayout()}`);
98
        classNames.push(`thy-vote-${this.thyLayout()}-size-${this.thySize()}`);
99
        this.hostRenderer.updateClass(classNames);
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