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

atinc / ngx-tethys / 0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

04 Sep 2023 08:40AM UTC coverage: 15.616% (-74.6%) from 90.2%
0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

Pull #2829

circleci

cmm-va
fix: add test
Pull Request #2829: fix: add tabIndex

300 of 6386 branches covered (0.0%)

Branch coverage included in aggregate %.

78 of 78 new or added lines in 26 files covered. (100.0%)

2849 of 13779 relevant lines covered (20.68%)

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

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

×
34
    private hostRenderer = useHostRenderer();
35

36
    public span: number = THY_GRID_ITEM_DEFAULT_SPAN;
×
37

38
    public offset: number = 0;
1✔
39

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

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

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

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

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

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

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