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

atinc / ngx-tethys / 3a07857c-fe40-47f4-bc02-6b91359dbc8f

30 Aug 2023 09:02AM UTC coverage: 90.195% (+0.08%) from 90.118%
3a07857c-fe40-47f4-bc02-6b91359dbc8f

Pull #2821

circleci

why520crazy
docs: add display block
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

81.48
/src/grid/thy-row.directive.ts
1
import { Directive, Input, OnChanges, OnInit, AfterViewInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
import { ReplaySubject } from 'rxjs';
3
import { isString } from 'ngx-tethys/util';
4
import { useHostRenderer } from '@tethys/cdk/dom';
5

6
export type ThyRowJustify = 'start' | 'end' | 'center' | 'space-around' | 'space-between';
7
export type ThyRowAlign = 'top' | 'middle' | 'bottom';
8

9
/**
10
 * 栅格行指令
11
 * @name thyRow
1✔
12
 * @order 30
13
 */
4✔
14
@Directive({
4✔
15
    selector: '[thyRow]',
16
    host: {
17
        class: 'thy-row'
4✔
18
    },
19
    standalone: true
20
})
4✔
21
export class ThyRowDirective implements OnInit, OnChanges, AfterViewInit {
22
    /**
23
     * 栅格的间距
24
     */
8✔
25
    @Input() thyGutter: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number };
8✔
26

8✔
27
    public actualGutter$ = new ReplaySubject<[number, number]>(1);
2✔
28

29
    private hostRenderer = useHostRenderer();
8✔
30

1✔
31
    constructor() {}
1✔
32

33
    ngOnInit() {
8!
34
        this.setGutterStyle();
×
35
    }
×
36

37
    ngOnChanges() {
38
        this.setGutterStyle();
39
    }
8!
40

×
41
    ngAfterViewInit(): void {}
42

8✔
43
    private setGutterStyle() {
44
        const [horizontalGutter, verticalGutter] = this.getGutter();
1✔
45
        this.actualGutter$.next([horizontalGutter, verticalGutter]);
1✔
46
        const renderGutter = (name: string, gutter: number) => {
47
            this.hostRenderer.setStyle(name, `-${gutter / 2}px`);
48
        };
49
        if (horizontalGutter > 0) {
1✔
50
            renderGutter('margin-left', horizontalGutter);
51
            renderGutter('margin-right', horizontalGutter);
52
        }
53
        if (verticalGutter > 0) {
54
            renderGutter('margin-top', verticalGutter);
55
            renderGutter('margin-bottom', verticalGutter);
56
        }
57
    }
58

59
    private getGutter() {
60
        if (isString(this.thyGutter)) {
61
            throw Error(`thyGutter value can not be string type`);
62
        }
63
        return [this.thyGutter as number, 0];
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