• 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

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

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

×
30
    @Input() color: ThyColor;
×
31

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

35
    constructor(private readonly renderer: Renderer2) {}
×
36

×
37
    @ViewChild('pointer', { static: true })
38
    public pointer: ElementRef;
1✔
39

40
    ngOnChanges(changes: SimpleChanges): void {
41
        if (changes.color && changes.color.previousValue !== changes.color.currentValue) {
1✔
42
            this.changePointerPosition(this.color.hue);
43
        }
44
    }
45

46
    private changePointerPosition(hue: number): void {
47
        const x = (hue / 360) * 100;
48
        this.renderer.setStyle(this.pointer.nativeElement, 'left', `${x}%`);
1✔
49
    }
50

51
    handleChange(event: {
52
        x: number;
53
        y: number;
54
        top: number;
55
        left: number;
56
        containerHeight: number;
57
        containerWidth: number;
58
        $event: Event;
59
    }) {
60
        let x;
61
        if (event.left < 0) {
62
            x = 0;
63
        } else if (event.left > event.containerWidth) {
64
            x = 1;
65
        } else {
66
            x = Math.round((event.left * 100) / event.containerWidth) / 100;
67
        }
68
        this.changePointerPosition(x * 360);
69
        this.colorChange.emit(new ThyColor({ h: x * 360, s: this.color.saturation, v: this.color.value, alpha: this.color.alpha }));
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