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

atinc / ngx-tethys / c0ef8457-a839-451f-8b72-80fd73106231

02 Apr 2024 02:27PM UTC coverage: 90.524% (-0.06%) from 90.585%
c0ef8457-a839-451f-8b72-80fd73106231

Pull #3062

circleci

minlovehua
refactor(all): use the transform attribute of @Input() instead of @InputBoolean() and @InputNumber()
Pull Request #3062: refactor(all): use the transform attribute of @input() instead of @InputBoolean() and @InputNumber()

4987 of 6108 branches covered (81.65%)

Branch coverage included in aggregate %.

217 of 223 new or added lines in 82 files covered. (97.31%)

202 existing lines in 53 files now uncovered.

12246 of 12929 relevant lines covered (94.72%)

1055.59 hits per line

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

86.36
/src/layout/header.component.ts
1
import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
2
import { ChangeDetectionStrategy, Component, ContentChild, Directive, Input, TemplateRef, booleanAttribute } from '@angular/core';
3
import { ThyIcon } from 'ngx-tethys/icon';
4

5
/**
6
 * 头部布局指令
7
 * @name thyHeader
8
 * @order 10
9
 */
10
@Directive({
11
    selector: '[thyHeader]',
1✔
12
    host: {
13
        class: `thy-layout-header`,
11✔
14
        '[class.thy-layout-header-sm]': `thySize === 'sm'`,
11✔
15
        '[class.thy-layout-header-lg]': `thySize === 'lg'`,
11✔
16
        '[class.thy-layout-header-xlg]': `thySize === 'xlg'`,
17
        '[class.thy-layout-header-shadow]': `thyShadow`,
18
        '[class.thy-layout-header-divided]': `divided`
11✔
19
    },
20
    standalone: true
21
})
×
22
export class ThyHeaderDirective {
23
    /**
1✔
24
     * 头部大小
25
     * @type sm | md  | lg | xlg
26
     */
27
    @Input('thySize') thySize: 'sm' | 'md' | 'lg' | 'xlg' = 'md';
28

29
    /**
30
     * 底部是否有阴影
1✔
31
     * @default false
32
     */
33
    @Input({ transform: booleanAttribute }) thyShadow = false;
34

35
    divided = false;
36

37
    /**
38
     * 底部是否有分割线
39
     */
40
    @Input({ transform: booleanAttribute })
41
    set thyDivided(value: boolean) {
42
        this.divided = value;
43
    }
44

45
    /**
46
     * 底部是否有分割线,已废弃,请使用 thyDivided
47
     * @deprecated please use thyDivided
48
     */
49
    @Input({ transform: booleanAttribute })
50
    set thyHasBorder(value: boolean) {
1✔
51
        this.divided = value;
52
    }
7✔
53
}
54

55
/**
6✔
56
 * 头部布局组件
1!
UNCOV
57
 * @name thy-header
×
58
 * @order 11
59
 */
60
@Component({
1✔
61
    selector: 'thy-header',
62
    preserveWhitespaces: false,
63
    templateUrl: './header.component.html',
64
    changeDetection: ChangeDetectionStrategy.OnPush,
5✔
65
    hostDirectives: [
5✔
66
        {
67
            directive: ThyHeaderDirective,
68
            inputs: ['thySize', 'thyShadow', 'thyHasBorder', 'thyDivided']
1✔
69
        }
70
    ],
71
    standalone: true,
72
    imports: [NgTemplateOutlet, NgIf, ThyIcon, NgClass, ThyHeaderDirective]
73
})
74
export class ThyHeader {
75
    public iconClass: string;
76

77
    public svgIconName: string;
1✔
78

79
    /**
80
     * 头部标题
81
     */
82
    @Input() thyTitle: string;
83

84
    /**
85
     * 图标前缀,被弃用,图标使用 SVG 图标
86
     */
87
    @Input() thyIconPrefix = 'wtf';
88

89
    /**
90
     * 图标,SVG 图标名称
91
     */
92
    @Input('thyIcon')
93
    set thyIcon(value: string) {
94
        if (value) {
95
            if (value.includes('wtf')) {
96
                this.iconClass = `${this.thyIconPrefix} ${value}`;
97
            } else {
98
                this.svgIconName = value;
99
            }
100
        } else {
101
            this.iconClass = null;
102
            this.svgIconName = null;
103
        }
104
    }
105

106
    /**
107
     * 头部自定义标题模板,`<ng-template #headerTitle></ng-template>`
108
     * @type TemplateRef
109
     */
110
    @ContentChild('headerTitle')
111
    public titleTemplateRef: TemplateRef<any>;
112

113
    /**
114
     * 头部自定义内容模板,`<ng-template #headerContent></ng-template>`
115
     * @type TemplateRef
116
     */
117
    @ContentChild('headerContent')
118
    public contentTemplateRef: TemplateRef<any>;
119

120
    /**
121
     * 头部自定义操作模板,`<ng-template #headerOperation></ng-template>`
122
     * @type TemplateRef
123
     */
124
    @ContentChild('headerOperation')
125
    public operationTemplateRef: TemplateRef<any>;
126
}
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