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

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

6.15 hits per line

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

13.04
/src/grid/thy-grid-item.component.ts
1
import { ChangeDetectionStrategy, Component, ElementRef, OnInit, inject, DestroyRef, input } from '@angular/core';
2
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3
import { THY_GRID_COMPONENT } from './grid.token';
4
import { ThyGridResponsiveDescription, THY_GRID_ITEM_DEFAULT_SPAN } from './grid.type';
5
import { useHostRenderer } from '@tethys/cdk/dom';
6

7
/**
8
 * 栅格项组件
9
 * @name thy-grid-item,[thyGridItem]
10
 * @order 15
11
 */
12
@Component({
13
    selector: 'thy-grid-item,[thyGridItem]',
1✔
14
    template: '<ng-content></ng-content>',
15
    changeDetection: ChangeDetectionStrategy.OnPush,
×
16
    host: {
×
17
        class: 'thy-grid-item'
×
18
    }
×
19
})
×
20
export class ThyGridItem implements OnInit {
×
21
    elementRef = inject(ElementRef);
×
22
    private grid = inject(THY_GRID_COMPONENT, { optional: true })!;
×
23

24
    /**
25
     * 栅格项的占位列数,为 0 时会隐藏该栅格项
×
26
     * @default 1
×
27
     */
28
    readonly thySpan = input<number | ThyGridResponsiveDescription>(THY_GRID_ITEM_DEFAULT_SPAN);
29

30
    /**
×
31
     * 栅格项左侧的偏移列数
×
32
     */
×
33
    readonly thyOffset = input<number | ThyGridResponsiveDescription>(0);
×
34

35
    private readonly destroyRef = inject(DestroyRef);
1✔
36

37
    private hostRenderer = useHostRenderer();
38

39
    public span: number = THY_GRID_ITEM_DEFAULT_SPAN;
40

1✔
41
    public offset: number = 0;
42

43
    ngOnInit(): void {
44
        this.grid.gridItemPropValueChange$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
45
            this.setGridItemStyle();
46
        });
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
}
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

© 2026 Coveralls, Inc