-
Notifications
You must be signed in to change notification settings - Fork 6.7k
/
button.ts
85 lines (81 loc) · 2.74 KB
/
button.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Platform} from '@angular/cdk/platform';
import {
ChangeDetectionStrategy,
Component,
ElementRef,
Inject,
NgZone,
Optional,
ViewEncapsulation,
ANIMATION_MODULE_TYPE,
} from '@angular/core';
import {MAT_ANCHOR_HOST, MAT_BUTTON_HOST, MatAnchorBase, MatButtonBase} from './button-base';
/**
* Material Design button component. Users interact with a button to perform an action.
* See https://material.io/components/buttons
*
* The `MatButton` class applies to native button elements and captures the appearances for
* "text button", "outlined button", and "contained button" per the Material Design
* specification. `MatButton` additionally captures an additional "flat" appearance, which matches
* "contained" but without elevation.
*/
@Component({
selector: `
button[mat-button], button[mat-raised-button], button[mat-flat-button],
button[mat-stroked-button]
`,
templateUrl: 'button.html',
styleUrls: ['button.css', 'button-high-contrast.css'],
host: MAT_BUTTON_HOST,
exportAs: 'matButton',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class MatButton extends MatButtonBase {
constructor(
elementRef: ElementRef,
platform: Platform,
ngZone: NgZone,
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
) {
super(elementRef, platform, ngZone, animationMode);
}
}
/**
* Material Design button component for anchor elements. Anchor elements are used to provide
* links for the user to navigate across different routes or pages.
* See https://material.io/components/buttons
*
* The `MatAnchor` class applies to native anchor elements and captures the appearances for
* "text button", "outlined button", and "contained button" per the Material Design
* specification. `MatAnchor` additionally captures an additional "flat" appearance, which matches
* "contained" but without elevation.
*/
@Component({
selector: `a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button]`,
exportAs: 'matButton, matAnchor',
host: MAT_ANCHOR_HOST,
templateUrl: 'button.html',
styleUrls: ['button.css', 'button-high-contrast.css'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class MatAnchor extends MatAnchorBase {
constructor(
elementRef: ElementRef,
platform: Platform,
ngZone: NgZone,
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
) {
super(elementRef, platform, ngZone, animationMode);
}
}