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

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

6.15 hits per line

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

21.74
/src/button/button-group.component.ts
1
import { coerceBooleanProperty } from '@angular/cdk/coercion';
2
import { useHostRenderer } from '@tethys/cdk/dom';
3
import { Component, effect, HostBinding, input, Input, OnInit, ViewEncapsulation } from '@angular/core';
4

5
export type ButtonGroupSize = 'sm' | 'lg' | 'xs' | 'md';
6

1✔
7
export type ButtonGroupType = 'outline-primary' | 'outline-default';
8

9
const buttonGroupSizeMap = {
10
    sm: ['btn-group-sm'],
11
    md: ['btn-group-md'],
12
    lg: ['btn-group-lg'],
13
    xs: ['btn-group-xs']
14
};
15

16
/**
17
 * 按钮分组组件
1✔
18
 * @name thy-button-group
19
 * @order 30
×
20
 */
×
21
@Component({
×
22
    selector: 'thy-button-group',
×
23
    template: '<ng-content></ng-content>',
×
24
    host: {
×
25
        class: 'btn-group',
26
        '[class.btn-group-clear-min-width]': 'thyClearMinWidth()'
27
    },
28
    encapsulation: ViewEncapsulation.None
×
29
})
×
30
export class ThyButtonGroup {
×
31
    private hostRenderer = useHostRenderer();
×
32

×
33
    /**
34
     * 大小
×
35
     * @type xs | sm | md | lg
×
36
     * @default md
37
     */
×
38
    readonly thySize = input<ButtonGroupSize>();
39

1✔
40
    /**
1✔
41
     * 类型
42
     * @type outline-default | outline-primary
43
     * @default outline-default
44
     */
45
    readonly thyType = input<ButtonGroupType>();
46

1✔
47
    /**
48
     * 是否需要最小宽度,默认按钮最小宽度为80px
49
     * @default false
50
     */
51
    readonly thyClearMinWidth = input(false, { transform: coerceBooleanProperty });
52

53
    constructor() {
54
        effect(() => {
55
            this.setClasses();
56
        });
57
    }
58

59
    private setClasses() {
60
        const type = this.thyType();
61
        const size = this.thySize();
62
        let classNames: string[] = [];
63
        if (type) {
64
            classNames.push(`btn-group-${type}`);
65
        }
66
        if (buttonGroupSizeMap[size]) {
67
            classNames = classNames.concat(...buttonGroupSizeMap[size]);
68
        }
69
        this.hostRenderer.updateClass(classNames);
70
    }
71
}
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