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

atinc / ngx-tethys / 5ba5b9d7-3ca9-4ff2-bbba-bde58c0f849f

22 Feb 2024 09:41AM UTC coverage: 90.604%. Remained the same
5ba5b9d7-3ca9-4ff2-bbba-bde58c0f849f

Pull #3027

circleci

minlovehua
feat(schematics): provide schematics for removing the suffix of standalone components #INFR-11662
Pull Request #3027: refactor: remove the component suffix for standalone components and provide schematics #INFR-10654

5425 of 6642 branches covered (81.68%)

Branch coverage included in aggregate %.

323 of 333 new or added lines in 193 files covered. (97.0%)

36 existing lines in 8 files now uncovered.

13504 of 14250 relevant lines covered (94.76%)

981.28 hits per line

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

95.45
/src/color-picker/color-picker-panel.component.ts
1
import { ChangeDetectionStrategy, Component, HostBinding, Input, OnInit, ViewContainerRef } from '@angular/core';
2
import { InputBoolean } from 'ngx-tethys/core';
3
import { ThyPopover, ThyPopoverRef } from 'ngx-tethys/popover';
4
import { ThyColorPickerCustomPanel } from './color-picker-custom-panel.component';
5
import { ThyColor } from './helpers/color.class';
6
import { ThyIcon } from 'ngx-tethys/icon';
7
import { NgIf, NgClass, NgTemplateOutlet, NgFor, NgStyle } from '@angular/common';
8

9
/**
10
 * @internal
11
 */
12
@Component({
13
    selector: 'thy-color-picker-panel',
1✔
14
    templateUrl: './color-picker-panel.component.html',
15
    changeDetection: ChangeDetectionStrategy.OnPush,
23✔
16
    host: {
17
        '[class.pt-4]': '!transparentColorSelectable'
18
    },
3✔
19
    standalone: true,
20
    imports: [NgIf, NgClass, NgTemplateOutlet, NgFor, ThyIcon, NgStyle]
21
})
40✔
22
export class ThyColorPickerPanel implements OnInit {
40✔
23
    @HostBinding('class.thy-color-picker-panel') className = true;
40✔
24

40✔
25
    @Input() color: string;
40✔
26

27
    @Input() colorChange: (color: string) => {};
28

36✔
29
    @Input() set defaultColor(value: string) {
36✔
30
        this.customDefaultColor = value;
10✔
31
    }
32

33
    get defaultColor() {
34
        return new ThyColor(this.customDefaultColor).toHexString(true);
3✔
35
    }
3✔
36

3✔
37
    @Input() @InputBoolean() transparentColorSelectable: boolean;
38

39
    @Input() defaultColors: string[];
7✔
40

6✔
41
    public customDefaultColor: string;
42

43
    recentColors: string[] = [];
44

45
    newColor: string;
46

47
    customPanelPopoverRef: ThyPopoverRef<ThyColorPickerCustomPanel>;
48

49
    constructor(
50
        private thyPopover: ThyPopover,
51
        private viewContainerRef: ViewContainerRef,
NEW
52
        private thyPopoverRef: ThyPopoverRef<ThyColorPickerPanel>
×
53
    ) {}
×
54

55
    ngOnInit(): void {
56
        const colors = localStorage.getItem('recentColors');
57
        if (colors) {
58
            this.recentColors = JSON.parse(colors);
7✔
59
        }
7✔
60
    }
2✔
61

2✔
62
    selectColor(color: string) {
1✔
63
        this.color = color;
64
        this.colorChange(this.color);
2✔
65
        this.thyPopoverRef.close();
2✔
66
    }
2✔
67

68
    showMoreColor(event: Event) {
7✔
69
        if (!this.customPanelPopoverRef) {
70
            this.customPanelPopoverRef = this.thyPopover.open(ThyColorPickerCustomPanel, {
71
                origin: event.currentTarget as HTMLElement,
72
                offset: -4,
13✔
73
                placement: 'rightBottom',
13✔
74
                manualClosure: true,
13✔
75
                width: '260px',
76
                hasBackdrop: false,
1✔
77
                viewContainerRef: this.viewContainerRef,
78
                originActiveClass: 'thy-color-picker-active',
79
                initialState: {
80
                    color: this.color,
81
                    pickerColorChange: (value: string) => {
1✔
82
                        this.newColor = value;
83
                        this.colorChange(value);
84
                    }
85
                }
86
            });
87
        }
88
        this.customPanelPopoverRef?.afterClosed().subscribe(() => {
89
            if (this.newColor) {
90
                const index = this.recentColors.findIndex(item => item === this.newColor);
1✔
91
                if (index !== -1) {
92
                    this.recentColors.splice(index, 1);
93
                }
94
                this.recentColors.unshift(this.newColor);
1✔
95
                this.recentColors = this.recentColors.slice(0, 10);
96
                localStorage.setItem('recentColors', JSON.stringify(this.recentColors));
97
            }
98
            this.thyPopoverRef.close();
99
        });
100
    }
101

102
    getIconColor(item: string) {
103
        const rgba = new ThyColor(item).rgba;
104
        const hsp = 0.299 * rgba.red + 0.587 * rgba.green + 0.114 * rgba.blue;
105
        return hsp > 192 ? 'black' : 'white';
106
    }
107
}
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