• 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

16.0
/src/grid/thy-grid-item.component.ts
1
import { ChangeDetectionStrategy, Component, ElementRef, Input, Optional, OnDestroy, OnInit, Inject } from '@angular/core';
2
import { MixinBase, mixinUnsubscribe } from 'ngx-tethys/core';
3
import { takeUntil } from 'rxjs/operators';
4
import { ThyGridToken, THY_GRID_COMPONENT } from './grid.token';
5
import { ThyGridResponsiveDescription, THY_GRID_ITEM_DEFAULT_SPAN } from './thy-grid.component';
6
import { useHostRenderer } from '@tethys/cdk/dom';
7

8
/**
9
 * 栅格项组件
10
 * @name thy-grid-item,[thyGridItem]
11
 */
12
@Component({
1✔
13
    selector: 'thy-grid-item,[thyGridItem]',
14
    template: '<ng-content></ng-content>',
×
15
    changeDetection: ChangeDetectionStrategy.OnPush,
×
16
    host: {
×
17
        class: 'thy-grid-item'
×
18
    },
×
19
    standalone: true
×
20
})
×
21
export class ThyGridItemComponent extends mixinUnsubscribe(MixinBase) implements OnInit, OnDestroy {
×
22
    /**
23
     * 栅格项的占位列数,为 0 时会隐藏该栅格项
24
     * @default 1
×
25
     */
×
26
    @Input() thySpan: number | ThyGridResponsiveDescription = THY_GRID_ITEM_DEFAULT_SPAN;
27

28
    /**
29
     * 栅格项左侧的偏移列数
×
30
     */
×
31
    @Input() thyOffset: number | ThyGridResponsiveDescription = 0;
×
32

×
33
    private hostRenderer = useHostRenderer();
34

35
    public span: number = THY_GRID_ITEM_DEFAULT_SPAN;
×
36

37
    public offset: number = 0;
1✔
38

39
    constructor(public elementRef: ElementRef, @Optional() @Inject(THY_GRID_COMPONENT) private grid: ThyGridToken) {
40
        super();
41
    }
1✔
42

43
    ngOnInit(): void {
44
        this.grid.gridItemPropValueChange$.pipe(takeUntil(this.ngUnsubscribe$)).subscribe(() => {
45
            this.setGridItemStyle();
46
        });
1✔
47
    }
48

49
    private setGridItemStyle() {
50
        const xGap: number = this.grid?.xGap || 0;
51

52
        this.hostRenderer.setStyle('display', this.span === 0 ? 'none' : '');
53

54
        this.hostRenderer.setStyle('grid-column', `span ${this.span}`);
55

56
        this.hostRenderer.setStyle(
57
            'margin-left',
58
            this.offset ? `calc(((100% - ${(this.span - 1) * xGap}px) / ${this.span} + ${xGap}px) * ${this.offset})` : ''
59
        );
60
    }
61

62
    ngOnDestroy(): void {
63
        super.ngOnDestroy();
64
    }
65
}
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