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

atinc / ngx-tethys / 1f1d1fba-9a96-4521-a558-afec2e37e7d1

30 Aug 2023 08:59AM UTC coverage: 90.195% (+0.08%) from 90.118%
1f1d1fba-9a96-4521-a558-afec2e37e7d1

Pull #2821

circleci

why520crazy
refactor: update
Pull Request #2821: feat(grid): add thyFlex and thyFlexItem #INFR-9429

5167 of 6387 branches covered (0.0%)

Branch coverage included in aggregate %.

62 of 62 new or added lines in 5 files covered. (100.0%)

13009 of 13765 relevant lines covered (94.51%)

972.1 hits per line

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

87.5
/src/grid/thy-col.directive.ts
1
import { Directive, Input, OnChanges, Optional, Host, AfterViewInit, OnInit, SimpleChanges } from '@angular/core';
2
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3
import { useHostRenderer } from '@tethys/cdk/dom';
4
import { ThyRowDirective } from './thy-row.directive';
5

6
export interface ThyColEmbeddedProperty {
7
    span?: number;
8
    pull?: number;
9
    push?: number;
10
    offset?: number;
11
    order?: number;
1✔
12
}
13

22✔
14
export type ThySpan = number | null | 'auto';
22✔
15

16
/**
17
 * 栅格列指令
8✔
18
 * @name thyCol
8✔
19
 * @order 35
8✔
20
 */
21
@Directive({
22
    selector: '[thyCol]',
8✔
23
    host: {
24
        class: 'thy-col'
25
    },
14✔
26
    standalone: true
27
})
28
export class ThyColDirective implements OnInit, OnChanges, AfterViewInit {
8!
29
    /**
8✔
30
     * 栅格项的占位列数,thySpan 如果传递了值,以 thySpan 为准
10✔
31
     */
4✔
32
    @Input() thyCol: ThySpan;
33

10✔
34
    /**
2✔
35
     * 栅格项的占位列数
2✔
36
     */
37
    @Input() thySpan: ThySpan;
10!
38

×
39
    get span() {
×
40
        const span = this.thySpan ?? this.thyCol;
41
        return span || 24;
42
    }
43

44
    private hostRenderer = useHostRenderer();
45

22✔
46
    private takeUntilDestroyed = takeUntilDestroyed();
47

48
    constructor(@Optional() @Host() public thyRowDirective: ThyRowDirective) {}
49

1✔
50
    ngOnInit() {
51
        this.updateHostClass();
52
    }
1✔
53

54
    ngOnChanges(changes: SimpleChanges): void {
55
        this.updateHostClass();
56
    }
57

1✔
58
    ngAfterViewInit(): void {
59
        if (this.thyRowDirective) {
60
            this.thyRowDirective.actualGutter$.pipe(this.takeUntilDestroyed).subscribe(([horizontalGutter, verticalGutter]) => {
61
                const renderGutter = (name: string, gutter: number) => {
62
                    this.hostRenderer.setStyle(name, `${gutter / 2}px`);
63
                };
64
                if (horizontalGutter > 0) {
65
                    renderGutter('padding-left', horizontalGutter);
66
                    renderGutter('padding-right', horizontalGutter);
67
                }
68
                if (verticalGutter > 0) {
69
                    renderGutter('padding-top', verticalGutter);
70
                    renderGutter('padding-bottom', verticalGutter);
71
                }
72
            });
73
        }
74
    }
75

76
    private updateHostClass() {
77
        this.hostRenderer.updateClassByMap({
78
            [`thy-col-${this.span}`]: true
79
        });
80
    }
81
}
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