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

atinc / ngx-tethys / 1a2b40f4-d0f1-4a92-b98b-b0c5ec4535e4

21 May 2025 02:14AM UTC coverage: 90.22%. Remained the same
1a2b40f4-d0f1-4a92-b98b-b0c5ec4535e4

push

circleci

web-flow
feat(colorPicker): migrate to signal for colorPicker (#3450)

5560 of 6827 branches covered (81.44%)

Branch coverage included in aggregate %.

60 of 67 new or added lines in 8 files covered. (89.55%)

5 existing lines in 3 files now uncovered.

13646 of 14461 relevant lines covered (94.36%)

902.91 hits per line

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

79.41
/src/color-picker/parts/inputs/inputs.component.ts
1
import { Component, effect, HostBinding, input, OnInit, output, signal, WritableSignal } from '@angular/core';
2
import { FormsModule } from '@angular/forms';
3
import { ThyInputDirective, ThyInputGroup } from 'ngx-tethys/input';
4
import { ThyInputNumber } from 'ngx-tethys/input-number';
5
import { ThyEnterDirective } from 'ngx-tethys/shared';
6
import { ThyColor } from '../../helpers/color.class';
7

8
/**
9
 * @internal
10
 */
11
@Component({
12
    selector: 'thy-color-inputs',
13
    templateUrl: './inputs.component.html',
1✔
14
    imports: [ThyInputDirective, FormsModule, ThyEnterDirective, ThyInputNumber, ThyInputGroup]
15
})
10✔
16
export class ThyColorInputs implements OnInit {
10✔
17
    @HostBinding('class.thy-color-inputs') className = true;
10✔
18

10✔
19
    readonly color = input<ThyColor>();
10✔
20

10✔
21
    readonly colorChange = output<ThyColor>();
12!
22

12!
23
    readonly hex: WritableSignal<string> = signal('');
24

25
    readonly alpha: WritableSignal<number> = signal(100);
26

27
    constructor() {
28
        effect(() => {
3✔
29
            this.hex.set(this.color()?.toHexString(false).slice(1, 7) || '');
3✔
30
            this.alpha.set(Math.round(this.color()?.rgba.alpha * 100) || 100);
2✔
31
        });
2!
NEW
32
    }
×
33

NEW
34
    ngOnInit(): void {}
×
35

36
    onInputChange(event: Event, type: string) {
37
        let newColor;
2✔
38
        const alpha = this.alpha() / 100;
2!
UNCOV
39
        if (type === 'hex') {
×
40
            let finalDisplayValue = this.hex();
41
            if (this.hex().length === 3) {
2✔
42
                finalDisplayValue = this.hex()
43
                    .split('')
44
                    .map(value => value + value)
1✔
45
                    .join('');
46
            }
3✔
47
            finalDisplayValue = `#${finalDisplayValue}`;
48
            if (alpha !== 1) {
1✔
49
                finalDisplayValue += ((1 << 8) | Math.round(alpha * 255)).toString(16).substr(1);
1✔
50
            }
51
            newColor = new ThyColor(finalDisplayValue);
52
        } else {
53
            newColor = new ThyColor().setRgba(this.color().rgba.red, this.color().rgba.green, this.color().rgba.blue, alpha);
54
        }
55
        this.colorChange.emit(newColor);
1✔
56
    }
57
}
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