• 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

23.08
/src/dot/dot.component.ts
1
import { isThemeColor, ThyThemeColor } from 'ngx-tethys/core';
2

3
import { ChangeDetectionStrategy, Component, ElementRef, Renderer2, ViewEncapsulation, effect, inject, input } from '@angular/core';
4

5
export type ThyColorType = ThyThemeColor | string;
1✔
6
export type ThySizeType = 'xs' | 'sm' | 'md' | 'lg' | 'xlg';
1✔
7
export type ThyThemeType = 'outline' | 'fill';
1✔
8
export type ThyShapeType = 'square' | 'circle';
1✔
9

1✔
10
export const COMPONENT_CLASS_NAME = 'thy-dot';
11

12
export const DEFAULT_COLOR_NAME = 'primary';
13
export const DEFAULT_SIZE_NAME = 'sm';
14
export const DEFAULT_THEME_NAME = 'fill';
15
export const DEFAULT_SHAPE_NAME = 'circle';
1✔
16

17
/**
×
18
 * 显示一个点的组件
×
19
 * @name thy-dot,[thy-dot],[thyDot]
×
20
 * @order 10
×
21
 */
22
@Component({
×
23
    selector: 'thy-dot,[thy-dot],[thyDot]',
×
24
    template: '',
25
    encapsulation: ViewEncapsulation.None,
×
26
    changeDetection: ChangeDetectionStrategy.OnPush,
×
27
    host: {
28
        class: 'thy-dot',
×
29
        '[class.dot-theme-fill]': 'thyTheme() === "fill"',
×
30
        '[class.dot-theme-outline]': 'thyTheme() === "outline"',
31
        '[class.dot-shape-square]': 'thyShape() === "square"',
×
32
        '[class.dot-shape-circle]': 'thyShape() === "circle"',
×
33
        '[class.dot-size-md]': 'thySize() === "md"',
×
34
        '[class.dot-size-sm]': 'thySize() === "sm"',
35
        '[class.dot-size-xs]': 'thySize() === "xs"',
36
        '[class.dot-size-lg]': 'thySize() === "lg"',
37
        '[class.dot-size-xlg]': 'thySize() === "xlg"'
×
38
    }
×
39
})
×
40
export class ThyDot {
×
41
    private el = inject(ElementRef);
×
42
    private renderer = inject(Renderer2);
×
43
    private nativeElement: HTMLElement;
44

45
    constructor() {
×
46
        this.nativeElement = this.el.nativeElement;
47

48
        effect(() => {
1✔
49
            this.updateColorStyle();
1✔
50
        });
51
    }
52

53
    /**
54
     * 颜色,可选值为:`primary` `success` `info` `warning` `danger` `default` `light`和自定义颜色,如`#2cccda` `red`  `rgb(153, 153, 153)`
55
     * @type ThyThemeColor | string
56
     */
1✔
57
    readonly thyColor = input<ThyColorType, ThyColorType>(DEFAULT_COLOR_NAME, {
58
        transform: (value: ThyColorType) => value || DEFAULT_COLOR_NAME
59
    });
60

61
    /**
62
     * 大小
63
     * @type xs | sm | md | lg | xlg
64
     */
65
    readonly thySize = input<ThySizeType, ThySizeType>(DEFAULT_SIZE_NAME, {
66
        transform: (value: ThySizeType) => value || DEFAULT_SIZE_NAME
67
    });
68

69
    /**
70
     * 主题
71
     * @type outline(线框) | fill(填充)
72
     */
73
    readonly thyTheme = input<ThyThemeType, ThyThemeType>(DEFAULT_THEME_NAME, {
74
        transform: (value: ThyThemeType) => value || DEFAULT_THEME_NAME
75
    });
76

77
    /**
78
     * 形状
79
     * @type circle(圆形) | square(方形)
80
     */
81
    readonly thyShape = input<ThyShapeType, ThyShapeType>(DEFAULT_SHAPE_NAME, {
82
        transform: (value: ThyShapeType) => value || DEFAULT_SHAPE_NAME
83
    });
84

85
    updateColorStyle() {
86
        Array.from(this.nativeElement.classList)
87
            .filter(it => /^dot-color-[\w]+$/.test(it))
88
            .forEach(it => this.renderer.removeClass(this.nativeElement, it));
89

90
        if (isThemeColor(this.thyColor())) {
91
            this.renderer.setStyle(this.nativeElement, 'borderColor', 'none');
92
            this.renderer.addClass(this.nativeElement, `dot-color-${this.thyColor()}`);
93
        } else {
94
            this.renderer.setStyle(this.nativeElement, 'borderColor', this.thyColor());
95
        }
96
    }
97
}
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