• 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

9.09
/src/color-picker/parts/saturation/saturation.component.ts
1
import {
2
    Component,
3
    ElementRef,
4
    EventEmitter,
5
    HostBinding,
6
    Input,
7
    OnChanges,
8
    Output,
9
    Renderer2,
1✔
10
    SimpleChanges,
11
    ViewChild
×
12
} from '@angular/core';
×
13
import { ThyCoordinatesDirective } from '../../coordinates.directive';
×
14
import ThyColor from '../../helpers/color.class';
15

16
/**
17
 * @internal
×
18
 */
×
19
@Component({
×
20
    selector: 'thy-saturation',
21
    templateUrl: './saturation.component.html',
22
    standalone: true,
×
23
    imports: [ThyCoordinatesDirective]
24
})
25
export class ThySaturationComponent implements OnChanges {
×
26
    @HostBinding('class.thy-saturation') className = true;
×
27

28
    @ViewChild('panel', { static: true })
29
    public panel: ElementRef;
×
30

×
31
    @ViewChild('pointer', { static: true })
×
32
    public pointer: ElementRef;
33

×
34
    @Output()
×
35
    public colorChange = new EventEmitter<ThyColor>(false);
36

×
37
    @Input()
×
38
    public color: ThyColor;
39

×
40
    ngOnChanges(changes: SimpleChanges): void {
×
41
        if (changes.color && changes.color.previousValue !== changes.color.currentValue) {
42
            this.setBackground();
×
43
            this.changePointerPosition(this.color.saturation, this.color.value);
×
44
        }
×
45
    }
×
46

×
47
    constructor(private readonly renderer: Renderer2) {}
×
48

49
    setBackground() {
1✔
50
        this.renderer.setStyle(this.panel.nativeElement, 'background', `hsl(${this.color.hue},100%,50%)`);
51
    }
52

1✔
53
    changePointerPosition(s: number, v: number) {
54
        this.renderer.setStyle(this.pointer.nativeElement, 'left', `${s}%`);
55
        this.renderer.setStyle(this.pointer.nativeElement, 'top', `${100 - v}%`);
56
    }
57

58
    handleChange(event: {
59
        x: number;
60
        y: number;
1✔
61
        top: number;
62
        left: number;
63
        containerHeight: number;
64
        containerWidth: number;
65
        $event: Event;
66
    }) {
67
        let x = event.left,
68
            y = event.top;
69
        if (event.left < 0) {
70
            x = 0;
71
        } else if (event.left > event.containerWidth) {
72
            x = event.containerWidth;
73
        }
74
        if (event.top < 0) {
75
            y = 0;
76
        } else if (event.top > event.containerHeight) {
77
            y = event.containerHeight;
78
        }
79

80
        const s = x / event.containerWidth;
81
        let v = 1 - y / event.containerHeight;
82
        v = v > 0 ? v : 0;
83
        v = v > 1 ? 1 : v;
84

85
        this.changePointerPosition(s * 100, v * 100);
86

87
        this.colorChange.emit(new ThyColor({ h: this.color.hue, s: s * 100, v: v * 100, alpha: this.color.alpha }));
88
    }
89
}
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