• 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.07
/src/vote/vote.component.ts
1
import { InputBoolean } from 'ngx-tethys/core';
2
import { coerceBooleanProperty } from 'ngx-tethys/util';
3
import { useHostRenderer } from '@tethys/cdk/dom';
4

5
import { Component, ContentChild, HostBinding, Input, OnInit, TemplateRef } from '@angular/core';
6
import { ThyIconComponent } from 'ngx-tethys/icon';
7
import { NgIf, NgTemplateOutlet } from '@angular/common';
8

9
export type ThyVoteSizes = 'default' | 'sm';
10

11
export type ThyVoteType = 'primary' | 'success' | 'primary-weak' | 'success-weak';
12

13
export type ThyVoteLayout = 'vertical' | 'horizontal';
14

1✔
15
/**
16
 * 投票组件
×
17
 * @name thy-vote,[thyVote]
×
18
 * @order 10
×
19
 */
20
@Component({
21
    selector: 'thy-vote,[thyVote]',
22
    templateUrl: './vote.component.html',
×
23
    host: {
×
24
        '[class.thy-vote-disabled]': `thyDisabled`
×
25
    },
26
    standalone: true,
27
    imports: [NgIf, ThyIconComponent, NgTemplateOutlet]
28
})
×
29
export class ThyVoteComponent implements OnInit {
30
    _size: ThyVoteSizes;
31

×
32
    _type: ThyVoteType;
×
33

×
34
    _layout: ThyVoteLayout;
35

36
    _initialized = false;
37

×
38
    _isRound = false;
×
39

×
40
    private hostRenderer = useHostRenderer();
41

42
    @HostBinding(`class.thy-vote`) class = true;
43

×
44
    @HostBinding(`class.has-voted`) _hasVoted = true;
×
45

×
46
    /**
×
47
     * 大小,thyLayout="vertical" 时,支持: sm | default
×
48
     * @default default
×
49
     */
×
50
    @Input()
51
    set thySize(value: ThyVoteSizes) {
52
        this._size = value;
×
53
        if (this._initialized) {
×
54
            this._setClassesByType();
55
        }
56
    }
×
57

×
58
    /**
×
59
     * 标签类型: primary | success | primary-weak | success-weak
60
     * @default primary
×
61
     */
×
62
    @Input()
63
    set thyVote(value: ThyVoteType) {
×
64
        this._type = value;
×
65
        if (this._initialized) {
66
            this._setClassesByType();
×
67
        }
×
68
    }
69

×
70
    /**
×
71
     * 是否是偏圆型
×
72
     * @default false
×
73
     */
74
    @Input()
1✔
75
    @InputBoolean()
1✔
76
    set thyRound(value: boolean) {
77
        this._isRound = coerceBooleanProperty(value);
78
    }
79

80
    /**
81
     * 布局: horizontal | vertical
82
     * @default horizontal
83
     */
84
    @Input()
85
    set thyLayout(value: ThyVoteLayout) {
86
        this._layout = value;
87
        if (this._initialized) {
88
            this._setClassesByType();
89
        }
1✔
90
    }
91

92
    /**
93
     * 赞同的数量
94
     */
1✔
95
    @Input() thyVoteCount: number | string;
96

97
    /**
98
     * 图标
99
     * @type string
1✔
100
     */
101
    @Input() thyIcon = 'thumb-up';
102

103
    /**
1✔
104
     * 是否赞同
105
     * @type boolean
106
     * @default false
107
     */
108
    @Input()
109
    @InputBoolean()
110
    set thyHasVoted(value: boolean) {
111
        this._hasVoted = coerceBooleanProperty(value);
112
        if (this._initialized) {
113
            this._setClassesByType();
114
        }
115
    }
116

117
    /**
118
     * 是否禁用
119
     * @type boolean
120
     */
121
    @Input() @InputBoolean() thyDisabled = false;
122

123
    /**
124
     * 自定义Icon模板
125
     * @type TemplateRef
126
     */
127
    @ContentChild('voteIcon') voteIcon: TemplateRef<any>;
128

129
    constructor() {}
130

131
    ngOnInit() {
132
        this._setClassesByType();
133
        this._initialized = true;
134
    }
135

136
    _setClassesByType() {
137
        const classNames = [];
138
        if (!this._type) {
139
            this._type = 'primary';
140
        }
141
        if (!this._layout) {
142
            this._layout = 'horizontal';
143
        }
144
        if (!this._size) {
145
            this._size = 'default';
146
        }
147
        if (this._isRound) {
148
            classNames.push('thy-vote-round');
149
        }
150
        classNames.push(`thy-vote-${this._type}`);
151
        classNames.push(`thy-vote-${this._layout}`);
152
        classNames.push(`thy-vote-${this._layout}-size-${this._size}`);
153
        this.hostRenderer.updateClass(classNames);
154
    }
155
}
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